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(a)redhat.com>
---
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