Index: /trunk/src/VBox/Main/src-server/MediumImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 39798)
+++ /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 39799)
@@ -97,4 +97,5 @@
           hostDrive(false),
           implicit(false),
+          uOpenFlagsDef(VD_OPEN_FLAGS_IGNORE_FLUSH),
           numCreateDiffTasks(0),
           vdDiskIfaces(NULL),
@@ -153,4 +154,7 @@
 
     bool implicit : 1;
+
+    /** Default flags passed to VDOpen(). */
+    unsigned uOpenFlagsDef;
 
     uint32_t numCreateDiffTasks;
@@ -4912,5 +4916,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_READONLY,
+                             VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -4926,5 +4930,5 @@
                              (*it)->m->strFormat.c_str(),
                              (*it)->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_INFO,
+                             VD_OPEN_FLAGS_INFO | m->uOpenFlagsDef,
                              (*it)->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -5400,5 +5404,5 @@
                          format.c_str(),
                          location.c_str(),
-                         uOpenFlags,
+                         uOpenFlags | m->uOpenFlagsDef,
                          m->vdImageIfaces);
             if (RT_FAILURE(vrc))
@@ -5651,5 +5655,5 @@
                              format.c_str(),
                              location.c_str(),
-                             uOpenFlags & ~VD_OPEN_FLAGS_READONLY,
+                             (uOpenFlags & ~VD_OPEN_FLAGS_READONLY) | m->uOpenFlagsDef,
                              m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -6464,5 +6468,5 @@
                                &geo,
                                id.raw(),
-                               VD_OPEN_FLAGS_NORMAL,
+                               VD_OPEN_FLAGS_NORMAL | m->uOpenFlagsDef,
                                m->vdImageIfaces,
                                task.mVDOperationIfaces);
@@ -6603,5 +6607,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_READONLY,
+                             VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -6627,5 +6631,5 @@
                                targetId.raw(),
                                id.raw(),
-                               VD_OPEN_FLAGS_NORMAL,
+                               VD_OPEN_FLAGS_NORMAL | m->uOpenFlagsDef,
                                pTarget->m->vdImageIfaces,
                                task.mVDOperationIfaces);
@@ -6807,5 +6811,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             uOpenFlags,
+                             uOpenFlags | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -6839,5 +6843,5 @@
                                      (*it)->m->strFormat.c_str(),
                                      (*it)->m->strLocationFull.c_str(),
-                                     VD_OPEN_FLAGS_INFO,
+                                     VD_OPEN_FLAGS_INFO | m->uOpenFlagsDef,
                                      (*it)->m->vdImageIfaces);
                         if (RT_FAILURE(vrc))
@@ -7093,5 +7097,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_READONLY,
+                             VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -7162,5 +7166,5 @@
                                  pMedium->m->strFormat.c_str(),
                                  pMedium->m->strLocationFull.c_str(),
-                                 uOpenFlags,
+                                 uOpenFlags | m->uOpenFlagsDef,
                                  pMedium->m->vdImageIfaces);
                     if (RT_FAILURE(vrc))
@@ -7183,5 +7187,5 @@
                                  task.mVariant & ~MediumVariant_NoCreateDir,
                                  targetId.raw(),
-                                 VD_OPEN_FLAGS_NORMAL,
+                                 VD_OPEN_FLAGS_NORMAL | m->uOpenFlagsDef,
                                  NULL /* pVDIfsOperation */,
                                  pTarget->m->vdImageIfaces,
@@ -7201,5 +7205,5 @@
                                    task.mVariant & ~MediumVariant_NoCreateDir,
                                    targetId.raw(),
-                                   VD_OPEN_FLAGS_NORMAL,
+                                   VD_OPEN_FLAGS_NORMAL | m->uOpenFlagsDef,
                                    NULL /* pVDIfsOperation */,
                                    pTarget->m->vdImageIfaces,
@@ -7349,5 +7353,5 @@
                          format.c_str(),
                          location.c_str(),
-                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO,
+                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO | m->uOpenFlagsDef,
                          m->vdImageIfaces);
             if (RT_SUCCESS(vrc))
@@ -7447,5 +7451,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_READONLY,
+                             VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -7471,5 +7475,5 @@
                          parentFormat.c_str(),
                          parentLocation.c_str(),
-                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO,
+                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO | m->uOpenFlagsDef,
                          m->vdImageIfaces);
             if (RT_FAILURE(vrc))
@@ -7577,5 +7581,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             (it == mediumListLast) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
+                             m->uOpenFlagsDef | (it == mediumListLast) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -7674,5 +7678,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             (it == mediumListLast) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
+                             m->uOpenFlagsDef | (it == mediumListLast) ? VD_OPEN_FLAGS_NORMAL : VD_OPEN_FLAGS_READONLY,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -7768,5 +7772,5 @@
                              pMedium->m->strFormat.c_str(),
                              pMedium->m->strLocationFull.c_str(),
-                             VD_OPEN_FLAGS_READONLY,
+                             VD_OPEN_FLAGS_READONLY | m->uOpenFlagsDef,
                              pMedium->m->vdImageIfaces);
                 if (RT_FAILURE(vrc))
@@ -7891,5 +7895,5 @@
                          task.mFormat->getId().c_str(),
                          task.mFilename.c_str(),
-                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_SEQUENTIAL,
+                         VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_SEQUENTIAL | m->uOpenFlagsDef,
                          task.mVDImageIfaces);
             if (RT_FAILURE(vrc))
@@ -7958,5 +7962,5 @@
                                  pMedium->m->strFormat.c_str(),
                                  pMedium->m->strLocationFull.c_str(),
-                                 uOpenFlags,
+                                 uOpenFlags | m->uOpenFlagsDef,
                                  pMedium->m->vdImageIfaces);
                     if (RT_FAILURE(vrc))
