Qemu supports cache.* parameters since 1.6 version. However introspection
for their presence is available in later versions only.
---
I don't bothered to figuring out from what version introspection is
possible thus don't touch tests/qemucapabilitiesdata/caps_*.replies.
Hoever it would be nice to know this version. In this case version
checking can have upper bound and can be eventually dropped from
the code when libvirt drops support of this version.
---
.gnulib | 2 +-
src/qemu/qemu_capabilities.c | 12 ++++++++-
src/qemu/qemu_capabilities.h | 3 +++
src/qemu/qemu_command.c | 30 ++++++++++++++++++++++
tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml | 3 +++
tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 3 +++
.../caps_2.6.0-gicv2.aarch64.xml | 3 +++
.../caps_2.6.0-gicv3.aarch64.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 3 +++
tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 3 +++
14 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/.gnulib b/.gnulib
index e89b4a7..a2a3943 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit e89b4a7aefce9cb02963920712ba7cdd13641644
+Subproject commit a2a39436b65f329630df4a93ec4e30aeae403c54
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4d859c4..8e54f99 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -344,6 +344,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"query-hotpluggable-cpus",
"virtio-net.rx_queue_size", /* 235 */
+ "drive-cache.writeback",
+ "drive-cache.direct",
+ "drive-cache.no_flush",
);
@@ -2836,6 +2839,9 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] =
{
{ "machine", "vmport", QEMU_CAPS_MACHINE_VMPORT_OPT },
{ "drive", "discard", QEMU_CAPS_DRIVE_DISCARD },
{ "drive", "detect-zeroes", QEMU_CAPS_DRIVE_DETECT_ZEROES },
+ { "drive", "cache.writeback", QEMU_CAPS_DRIVE_CACHE_WRITEBACK },
+ { "drive", "cache.direct", QEMU_CAPS_DRIVE_CACHE_DIRECT },
+ { "drive", "cache.no-flush", QEMU_CAPS_DRIVE_CACHE_NO_FLUSH },
{ "realtime", "mlock", QEMU_CAPS_REALTIME_MLOCK },
{ "boot-opts", "strict", QEMU_CAPS_BOOT_STRICT },
{ "boot-opts", "reboot-timeout", QEMU_CAPS_REBOOT_TIMEOUT },
@@ -3756,8 +3762,12 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuCaps->version >= 1005000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT);
- if (qemuCaps->version >= 1006000)
+ if (qemuCaps->version >= 1006000) {
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_WRITEBACK);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_DIRECT);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_NO_FLUSH);
+ }
/* vmport option is supported v2.2.0 onwards */
if (qemuCaps->version >= 2002000)
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ba0ef48..01d37a9 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -378,6 +378,9 @@ typedef enum {
/* 235 */
QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, /* virtio-net-*.rx_queue_size */
+ QEMU_CAPS_DRIVE_CACHE_WRITEBACK, /* cache.writeback */
+ QEMU_CAPS_DRIVE_CACHE_DIRECT, /* cache.direct */
+ QEMU_CAPS_DRIVE_CACHE_NO_FLUSH, /* cache.no-flush */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f24a98b..347f902 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1635,6 +1635,36 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
virBufferAddLit(&opt, ",cache=none");
}
+ if (disk->cachetune.writeback > 0) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_WRITEBACK)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("disk cache writeback parameter is not "
+ "supported by this QEMU"));
+ }
+ virBufferAsprintf(&opt, ",cache.writeback=%s",
+ virTristateSwitchTypeToString(disk->cachetune.writeback));
+ }
+
+ if (disk->cachetune.direct > 0) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_DIRECT)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("disk cache direct parameter is not "
+ "supported by this QEMU"));
+ }
+ virBufferAsprintf(&opt, ",cache.direct=%s",
+ virTristateSwitchTypeToString(disk->cachetune.direct));
+ }
+
+ if (disk->cachetune.no_flush > 0) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_CACHE_NO_FLUSH)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("disk cache no_flush parameter is not "
+ "supported by this QEMU"));
+ }
+ virBufferAsprintf(&opt, ",cache.no-flush=%s",
+ virTristateSwitchTypeToString(disk->cachetune.no_flush));
+ }
+
if (disk->copy_on_read) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_COPY_ON_READ)) {
virBufferAsprintf(&opt, ",copy-on-read=%s",
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
index a6d4561..5a98598 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml
@@ -148,6 +148,9 @@
<flag name='device-tray-moved-event'/>
<flag name='nec-usb-xhci-ports'/>
<flag name='display'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>1006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
index f756a41..af2a4d4 100644
--- a/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml
@@ -150,6 +150,9 @@
<flag name='device-tray-moved-event'/>
<flag name='nec-usb-xhci-ports'/>
<flag name='display'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>1007000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
index a77ad9e..6508343 100644
--- a/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml
@@ -165,6 +165,9 @@
<flag name='name-guest'/>
<flag name='drive-detect-zeroes'/>
<flag name='display'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2001001</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
index db778ef..4c0c7a4 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
@@ -185,6 +185,9 @@
<flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
index fc915ad..5071351 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
@@ -190,6 +190,9 @@
<flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
index fd14665..c049320 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
@@ -159,6 +159,9 @@
<flag name='display'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
index eb708f8..d8a9ad2 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
@@ -159,6 +159,9 @@
<flag name='display'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
index 482b384..d2bd423 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml
@@ -153,6 +153,9 @@
<flag name='display'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2005094</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
index 60f1fcf..e88f2a0 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
@@ -196,6 +196,9 @@
<flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
index 98f3762..a572ea2 100644
--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
@@ -197,6 +197,9 @@
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
<flag name='query-hotpluggable-cpus'/>
+ <flag name='drive-cache.writeback'/>
+ <flag name='drive-cache.direct'/>
+ <flag name='drive-cache.no_flush'/>
<version>2007000</version>
<kvmVersion>0</kvmVersion>
<package> (v2.7.0)</package>
--
1.8.3.1