[PATCH 5/6] qemu: Format 'write-cache' parameter for disk frontends

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The disk cache mode translates to various frontend and backend
attributes for the qemu block layer. For the frontend device the
'writeback' parameter is used and provided as 'write-cache'. Implement
this so that we can later switch to using -blockdev where we will not
pass the cachemode directly any more.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bbd3cd0a7d..83e263e9f9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1882,6 +1882,30 @@ qemuCheckIOThreads(const virDomainDef *def,
 }


+static int
+qemuBuildDriveDevCacheStr(virDomainDiskDefPtr disk,
+                          virBufferPtr buf,
+                          virQEMUCapsPtr qemuCaps)
+{
+    bool wb;
+
+    if (disk->cachemode == VIR_DOMAIN_DISK_CACHE_DEFAULT)
+        return 0;
+
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DISK_WRITE_CACHE))
+        return 0;
+
+    if (qemuDomainDiskCachemodeFlags(disk->cachemode, &wb, NULL, NULL) < 0)
+        return -1;
+
+    virBufferStrcat(buf, ",write-cache=",
+                    virTristateSwitchTypeToString(virTristateSwitchFromBool(wb)),
+                    NULL);
+
+    return 0;
+}
+
+
 char *
 qemuBuildDriveDevStr(const virDomainDef *def,
                      virDomainDiskDefPtr disk,
@@ -2194,6 +2218,9 @@ qemuBuildDriveDevStr(const virDomainDef *def,
         }
     }

+    if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0)
+        goto error;
+
     if (virBufferCheckError(&opt) < 0)
         goto error;

-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux