]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Move initialization of disk cachemode for <shareable> disks
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Mar 2018 09:11:26 +0000 (11:11 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Apr 2018 13:48:38 +0000 (15:48 +0200)
The qemu command line generator code set disk caching of shareable disks
to 'none' when formatting the command line silently. Move this code to a
common place when preparing the domain definition for startup so that it
does not have to be duplicated.

The new test case shows that the actual cache mode will now be recorded
in the live XML definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2startupxmloutdata/disk-drive-shared.xml

index be70c22332068aa113ae0c0d773baa94ad1f00df..bbd3cd0a7d377c140e2ac4b7528964c8be8bd222 100644 (file)
@@ -1804,8 +1804,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
     if (disk->cachemode) {
         virBufferAsprintf(&opt, ",cache=%s",
                           qemuDiskCacheV2TypeToString(disk->cachemode));
-    } else if (disk->src->shared && !disk->src->readonly) {
-        virBufferAddLit(&opt, ",cache=none");
     }
 
     if (disk->copy_on_read) {
index 827df4a5cca83949462b6ddae5124054da479054..9d1c33b54a3066b9288c3b23be2813ea55335acf 100644 (file)
@@ -11891,11 +11891,22 @@ qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk,
 }
 
 
+static void
+qemuDomainPrepareDiskCachemode(virDomainDiskDefPtr disk)
+{
+    if (disk->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT &&
+        disk->src->shared && !disk->src->readonly)
+        disk->cachemode = VIR_DOMAIN_DISK_CACHE_DISABLE;
+}
+
+
 int
 qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
                             qemuDomainObjPrivatePtr priv,
                             virQEMUDriverConfigPtr cfg)
 {
+    qemuDomainPrepareDiskCachemode(disk);
+
     if (qemuDomainPrepareDiskSourceTLS(disk->src, cfg) < 0)
         return -1;
 
index f4d2871ae74b97765bc0a523ea2c02a75591bd44..60b7eca7885a4f2300d3032dea11b64460023dcb 100644 (file)
@@ -15,7 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu-system-i686</emulator>
     <disk type='block' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='raw' cache='none'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <shareable/>