[libvirt] [PATCH v3 0/7] qemu: Better xml->argv testing and add support for write-cache for disks (blockdev-add saga)

Version 3: - renamed the testing macros - removed hand-rolled code to compare versions - fixed the test case to demonstrate usage of the new test-suite - reworded comment in test suite on how to use it Peter Krempa (7): tests: qemu: Add helper code to lookup latest capability file tests: qemuxml2argv: Add infrastructure to pass output file suffix tests: qemuxml2argv: Add infrastructure for testing with real qemuCaps qemu: domain: Add helper for translating disk cachemode to qemu flags tests: qemuxml2argv: Test formatting of 'write-cache' parameter qemu: caps: Add capability for 'write-cache' parameter of disk frontends qemu: Format 'write-cache' parameter for disk frontends src/qemu/qemu_capabilities.c | 5 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 27 +++++++ src/qemu/qemu_domain.c | 75 +++++++++++++++++++ src/qemu/qemu_domain.h | 6 ++ tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + .../disk-drive-write-cache.x86_64-2.6.0.args | 43 +++++++++++ .../disk-drive-write-cache.x86_64-2.7.0.args | 45 ++++++++++++ .../disk-drive-write-cache.x86_64-latest.args | 47 ++++++++++++ tests/qemuxml2argvdata/disk-drive-write-cache.xml | 45 ++++++++++++ tests/qemuxml2argvtest.c | 83 +++++++++++++++++++++- tests/testutilsqemu.c | 63 ++++++++++++++++ tests/testutilsqemu.h | 5 ++ 28 files changed, 458 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.xml -- 2.16.2

The helper iterates the directory with files for the capability test and looks up the most recent one for the given architecture. This will allow testing against the newest qemu capabilities so that we can catch regressions in behaviour more easily. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/testutilsqemu.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 5 ++++ 2 files changed, 68 insertions(+) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 9671a46f12..3222d7864c 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -674,3 +674,66 @@ testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, } #endif + + +char * +testQemuGetLatestCapsForArch(const char *dirname, + const char *arch, + const char *suffix) +{ + struct dirent *ent; + DIR *dir = NULL; + int rc; + char *fullsuffix = NULL; + char *tmp = NULL; + unsigned long maxver = 0; + unsigned long ver; + const char *maxname = NULL; + char *ret = NULL; + + if (virAsprintf(&fullsuffix, "%s.%s", arch, suffix) < 0) + goto cleanup; + + if (virDirOpen(&dir, dirname) < 0) + goto cleanup; + + while ((rc = virDirRead(dir, &ent, dirname)) > 0) { + VIR_FREE(tmp); + + if ((rc = VIR_STRDUP(tmp, STRSKIP(ent->d_name, "caps_"))) < 0) + goto cleanup; + + if (rc == 0) + continue; + + if (virFileStripSuffix(tmp, fullsuffix) != 1) + continue; + + if (virParseVersionString(tmp, &ver, false) < 0) { + VIR_TEST_DEBUG("skipping caps file '%s'\n", ent->d_name); + continue; + } + + if (ver > maxver) { + maxname = ent->d_name; + maxver = ver; + } + } + + if (rc < 0) + goto cleanup; + + if (!maxname) { + VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'\n", + arch, dirname); + goto cleanup; + } + + ignore_value(virAsprintf(&ret, "%s/%s", dirname, maxname)); + + cleanup: + VIR_FREE(tmp); + VIR_FREE(fullsuffix); + virDirClose(&dir); + return ret; +} diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 7ae8324933..efb1baeadd 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -39,4 +39,9 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache, int testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, int gic); + +char *testQemuGetLatestCapsForArch(const char *dirname, + const char *arch, + const char *suffix); + #endif -- 2.16.2

On Wed, Apr 18, 2018 at 05:33:32PM +0200, Peter Krempa wrote:
The helper iterates the directory with files for the capability test and looks up the most recent one for the given architecture. This will allow testing against the newest qemu capabilities so that we can catch regressions in behaviour more easily.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/testutilsqemu.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 5 ++++ 2 files changed, 68 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

To allow having more than one output file in the qemuxml2argvtest add a suffix member to the testInfo struct which will allow testing the same XML file with multiple capabilities files. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvtest.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index aba946612f..6fe57c2a99 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -270,6 +270,7 @@ typedef enum { struct testInfo { const char *name; + const char *suffix; virQEMUCapsPtr qemuCaps; const char *migrateFrom; int migrateFd; @@ -442,6 +443,7 @@ testCompareXMLToArgv(const void *data) char *args = NULL; char *migrateURI = NULL; char *actualargv = NULL; + const char *suffix = info->suffix; unsigned int flags = info->flags; unsigned int parseFlags = info->parseFlags; int ret = -1; @@ -458,6 +460,9 @@ testCompareXMLToArgv(const void *data) if (!(conn = virGetConnect())) goto cleanup; + if (!suffix) + suffix = ""; + conn->secretDriver = &fakeSecretDriver; conn->storageDriver = &fakeStorageDriver; @@ -472,8 +477,8 @@ testCompareXMLToArgv(const void *data) if (virAsprintf(&xml, "%s/qemuxml2argvdata/%s.xml", abs_srcdir, info->name) < 0 || - virAsprintf(&args, "%s/qemuxml2argvdata/%s.args", - abs_srcdir, info->name) < 0) + virAsprintf(&args, "%s/qemuxml2argvdata/%s%s.args", + abs_srcdir, info->name, suffix) < 0) goto cleanup; if (info->migrateFrom && @@ -657,7 +662,7 @@ mymain(void) parseFlags, gic, ...) \ do { \ static struct testInfo info = { \ - name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \ + name, NULL, NULL, migrateFrom, migrateFd, (flags), parseFlags, \ false, NULL \ }; \ info.skipLegacyCPUs = skipLegacyCPUs; \ -- 2.16.2

Allow testing of XML->argv conversion with using a real capability map as used in the qemucapabilitiestest. This allows specifying the required qemu version with the test rather than having to enumerate all the required capabilities or allows to use the newest capabilities present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvtest.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6fe57c2a99..3c76d4c6ca 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -593,6 +593,7 @@ mymain(void) int ret = 0; char *fakerootdir; bool skipLegacyCPUs = false; + char *capslatest_x86_64 = NULL; if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) { fprintf(stderr, "Out of memory\n"); @@ -658,6 +659,73 @@ mymain(void) if (VIR_STRDUP_QUIET(driver.config->memoryBackingDir, "/var/lib/libvirt/qemu/ram") < 0) return EXIT_FAILURE; + if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch(abs_srcdir "/qemucapabilitiesdata", + "x86_64", "xml"))) + return EXIT_FAILURE; + + VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64); + + +/** + * The following set of macros allows testing of XML -> argv conversion with a + * real set of capabilities gathered from a real qemu copy. It is desired to use + * these for positive test cases as it provides combinations of flags which + * can be met in real life. + * + * The capabilities are taken from the real capabilities stored in + * tests/qemucapabilitiesdata. + * + * It is suggested to use the DO_TEST_CAPS_LATEST macro which always takes the + * most recent capability set. In cases when the new code would change behaviour + * the test cases should be forked using DO_TEST_CAPS_VER with the appropriate + * version. + */ +# define DO_TEST_CAPS_INTERNAL(name, suffix, migrateFrom, flags, parseFlags, \ + gic, arch, capsfile) \ + do { \ + static struct testInfo info = { \ + name, "." suffix, NULL, migrateFrom, migrateFrom ? 7 : -1,\ + (flags), parseFlags, false, NULL \ + }; \ + info.skipLegacyCPUs = skipLegacyCPUs; \ + if (testInitQEMUCaps(&info, gic) < 0) \ + return EXIT_FAILURE; \ + if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \ + capsfile))) \ + return EXIT_FAILURE; \ + if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \ + testCompareXMLToArgv, &info) < 0) \ + ret = -1; \ + virObjectUnref(info.qemuCaps); \ + virObjectUnref(info.vm); \ + } while (0) + +# define TEST_CAPS_PATH abs_srcdir "/qemucapabilitiesdata/caps_" + +# define DO_TEST_CAPS_ARCH_VER_FULL(name, flags, parseFlags, gic, arch, ver) \ + DO_TEST_CAPS_INTERNAL(name, arch "-" ver, NULL, flags, parseFlags, gic, \ + arch, TEST_CAPS_PATH ver "." arch ".xml") + +# define DO_TEST_CAPS_ARCH_VER(name, gic, arch, ver) \ + DO_TEST_CAPS_ARCH_VER_FULL(name, 0, 0, gic, arch, ver) + +# define DO_TEST_CAPS_VER(name, ver) \ + DO_TEST_CAPS_ARCH_VER(name, GIC_NONE, "x86_64", ver) + +# define DO_TEST_CAPS_LATEST(name) \ + DO_TEST_CAPS_INTERNAL(name, "x86_64-latest", NULL, 0, 0, GIC_NONE, "x86_64", \ + capslatest_x86_64) + +/** + * The following test macros should be used only in cases when the tests require + * testing of some non-standard combination of capability flags + */ +# define DO_TEST_CAPS_FULL(name, flags, parseFlags, ver) \ + DO_TEST_CAPS_ARCH(name, NULL, flags, parseFlags, GIC_NONE, "x86_64", ver) + +# define DO_TEST_CAPS(name, ver) \ + DO_TEST_CAPS_FULL(name, 0, 0, ver) + # define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \ parseFlags, gic, ...) \ do { \ @@ -2769,6 +2837,7 @@ mymain(void) qemuTestDriverFree(&driver); VIR_FREE(fakerootdir); + VIR_FREE(capslatest_x86_64); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.16.2

On Wed, Apr 18, 2018 at 05:33:34PM +0200, Peter Krempa wrote:
Allow testing of XML->argv conversion with using a real capability map as used in the qemucapabilitiestest. This allows specifying the required qemu version with the test rather than having to enumerate all the required capabilities or allows to use the newest capabilities present.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemuxml2argvtest.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Add helper which will map values of disk cache mode to the flags which are accepted by various parts of the qemu block layer. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_domain.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 6 ++++ 2 files changed, 81 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 21897cb47a..e2a8450e2e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11866,6 +11866,81 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, } +/** + * qemuDomainDiskCachemodeFlags: + * + * Converts disk cachemode to the cache mode options for qemu. Returns -1 for + * invalid @cachemode values and fills the flags and returns 0 on success. + * Flags may be NULL. + */ +int +qemuDomainDiskCachemodeFlags(int cachemode, + bool *writeback, + bool *direct, + bool *noflush) +{ + bool dummy; + + if (!writeback) + writeback = &dummy; + + if (!direct) + direct = &dummy; + + if (!noflush) + noflush = &dummy; + + /* Mapping of cache modes to the attributes according to qemu-options.hx + * │ cache.writeback cache.direct cache.no-flush + * ─────────────┼───────────────────────────────────────────────── + * writeback │ true false false + * none │ true true false + * writethrough │ false false false + * directsync │ false true false + * unsafe │ true false true + */ + switch ((virDomainDiskCache) cachemode) { + case VIR_DOMAIN_DISK_CACHE_DISABLE: /* 'none' */ + *writeback = true; + *direct = true; + *noflush = false; + break; + + case VIR_DOMAIN_DISK_CACHE_WRITETHRU: + *writeback = false; + *direct = false; + *noflush = false; + break; + + case VIR_DOMAIN_DISK_CACHE_WRITEBACK: + *writeback = true; + *direct = false; + *noflush = false; + break; + + case VIR_DOMAIN_DISK_CACHE_DIRECTSYNC: + *writeback = false; + *direct = true; + *noflush = false; + break; + + case VIR_DOMAIN_DISK_CACHE_UNSAFE: + *writeback = true; + *direct = false; + *noflush = true; + break; + + case VIR_DOMAIN_DISK_CACHE_DEFAULT: + case VIR_DOMAIN_DISK_CACHE_LAST: + default: + virReportEnumRangeError(virDomainDiskCache, cachemode); + return -1; + } + + return 0; +} + + void qemuProcessEventFree(struct qemuProcessEvent *event) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 40d9a6f247..2c27dfb9f3 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -994,4 +994,10 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, qemuDomainObjPrivatePtr priv, virQEMUDriverConfigPtr cfg); +int +qemuDomainDiskCachemodeFlags(int cachemode, + bool *writeback, + bool *direct, + bool *noflush); + #endif /* __QEMU_DOMAIN_H__ */ -- 2.16.2

Prepare the tests for adding the new parameter. The parameter was introduced in qemu-2.7.0, so add a forked version of the test case to see that it is formatted properly. This test is also an example how the new testing macros should be used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .../disk-drive-write-cache.x86_64-2.6.0.args | 43 +++++++++++++++++++++ .../disk-drive-write-cache.x86_64-2.7.0.args | 43 +++++++++++++++++++++ .../disk-drive-write-cache.x86_64-latest.args | 45 ++++++++++++++++++++++ tests/qemuxml2argvdata/disk-drive-write-cache.xml | 45 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 5 files changed, 179 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.xml diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args new file mode 100644 index 0000000000..9af27dbbaf --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args @@ -0,0 +1,43 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-i440fx-2.6,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device lsi,id=scsi0,bus=pci.0,addr=0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ +cache=writeback \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\ +cache=none \ +-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\ +cache=writethrough \ +-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ +id=virtio-disk0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\ +cache=directsync \ +-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\ +removable=off \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args new file mode 100644 index 0000000000..9af27dbbaf --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args @@ -0,0 +1,43 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-i440fx-2.6,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device lsi,id=scsi0,bus=pci.0,addr=0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ +cache=writeback \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\ +cache=none \ +-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\ +cache=writethrough \ +-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ +id=virtio-disk0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\ +cache=directsync \ +-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\ +removable=off \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args new file mode 100644 index 0000000000..b4bef87529 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args @@ -0,0 +1,45 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc-i440fx-2.6,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device lsi,id=scsi0,bus=pci.0,addr=0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ +cache=writeback \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\ +cache=none \ +-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\ +cache=writethrough \ +-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ +id=virtio-disk0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\ +cache=directsync \ +-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\ +removable=off \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.xml b/tests/qemuxml2argvdata/disk-drive-write-cache.xml new file mode 100644 index 0000000000..6b762909b4 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.xml @@ -0,0 +1,45 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc-i440fx-2.6'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-i686</emulator> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2' cache='writeback'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2' cache='none'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='sda' bus='scsi'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2' cache='writethrough'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='vda' bus='virtio'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='qcow2' cache='directsync'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='sdb' bus='usb'/> + </disk> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3c76d4c6ca..74d930ebe2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1017,6 +1017,9 @@ mymain(void) DO_TEST("disk-drive-cache-v2-none", NONE); DO_TEST("disk-drive-cache-directsync", NONE); DO_TEST("disk-drive-cache-unsafe", NONE); + DO_TEST_CAPS_VER("disk-drive-write-cache", "2.6.0"); + DO_TEST_CAPS_VER("disk-drive-write-cache", "2.7.0"); + DO_TEST_CAPS_LATEST("disk-drive-write-cache"); DO_TEST("disk-drive-network-nbd", NONE); DO_TEST("disk-drive-network-nbd-export", NONE); DO_TEST("disk-drive-network-nbd-ipv6", NONE); -- 2.16.2

On Wed, Apr 18, 2018 at 05:33:36PM +0200, Peter Krempa wrote:
Prepare the tests for adding the new parameter. The parameter was introduced in qemu-2.7.0, so add a forked version of the test case to see that it is formatted properly.
This test is also an example how the new testing macros should be used.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- .../disk-drive-write-cache.x86_64-2.6.0.args | 43 +++++++++++++++++++++ .../disk-drive-write-cache.x86_64-2.7.0.args | 43 +++++++++++++++++++++ .../disk-drive-write-cache.x86_64-latest.args | 45 ++++++++++++++++++++++ tests/qemuxml2argvdata/disk-drive-write-cache.xml | 45 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 ++ 5 files changed, 179 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.6.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-drive-write-cache.xml
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

QEMU translates the cache mode of a disk internally into 3 flags. 'write-cache' is a flag of the frontend while others are flag of the backing storage. Add capability which will allow expressing it via the frontend attribute. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_capabilities.c | 5 +++++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 18 files changed, 22 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 42248dd19a..ad387e698c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -472,6 +472,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, /* 290 */ "query-cpus-fast", + "disk-write-cache", ); @@ -1118,6 +1119,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { { "disable-legacy", QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY }, { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM }, { "ats", QEMU_CAPS_VIRTIO_PCI_ATS }, + { "write-cache", QEMU_CAPS_DISK_WRITE_CACHE }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioNet[] = { @@ -1155,11 +1157,13 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsSCSIDisk[] = { { "channel", QEMU_CAPS_SCSI_DISK_CHANNEL }, { "wwn", QEMU_CAPS_SCSI_DISK_WWN }, { "share-rw", QEMU_CAPS_DISK_SHARE_RW }, + { "write-cache", QEMU_CAPS_DISK_WRITE_CACHE }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsIDEDrive[] = { { "wwn", QEMU_CAPS_IDE_DRIVE_WWN }, { "share-rw", QEMU_CAPS_DISK_SHARE_RW }, + { "write-cache", QEMU_CAPS_DISK_WRITE_CACHE }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsPiix4PM[] = { @@ -1191,6 +1195,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsQ35PCIHost[] = { static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsUSBStorage[] = { { "removable", QEMU_CAPS_USB_STORAGE_REMOVABLE }, { "share-rw", QEMU_CAPS_DISK_SHARE_RW }, + { "write-cache", QEMU_CAPS_DISK_WRITE_CACHE }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsKVMPit[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3962c9c443..f08cfc2611 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -456,6 +456,7 @@ typedef enum { /* 290 */ QEMU_CAPS_QUERY_CPUS_FAST, /* query-cpus-fast command */ + QEMU_CAPS_DISK_WRITE_CACHE, /* qemu block frontends support write-cache param */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml index 88616e57f0..527b425dee 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml @@ -152,6 +152,7 @@ <flag name='pl011'/> <flag name='dump-completed'/> <flag name='qcow2-luks'/> + <flag name='disk-write-cache'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>303541</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml index 91f80a277f..3ac6be2d88 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml @@ -151,6 +151,7 @@ <flag name='machine.pseries.max-cpu-compat'/> <flag name='dump-completed'/> <flag name='qcow2-luks'/> + <flag name='disk-write-cache'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>382824</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml index c599b66f56..b682d36c93 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -112,6 +112,7 @@ <flag name='iscsi.password-secret'/> <flag name='dump-completed'/> <flag name='qcow2-luks'/> + <flag name='disk-write-cache'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>303326</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml index 9e95b68457..8dd30ccbcf 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml @@ -195,6 +195,7 @@ <flag name='isa-serial'/> <flag name='dump-completed'/> <flag name='qcow2-luks'/> + <flag name='disk-write-cache'/> <version>2010000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>344938</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml index eb6ae2f39e..6dd392502e 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -117,6 +117,7 @@ <flag name='virtio-tablet-ccw'/> <flag name='qcow2-luks'/> <flag name='seccomp-blacklist'/> + <flag name='disk-write-cache'/> <version>2011000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>342058</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml index d50a440776..31c5d0dd23 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml @@ -156,6 +156,7 @@ <flag name='pcie-pci-bridge'/> <flag name='seccomp-blacklist'/> <flag name='query-cpus-fast'/> + <flag name='disk-write-cache'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>342346</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml index c4cdd248b0..7dead4a1f4 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml @@ -153,6 +153,7 @@ <flag name='qcow2-luks'/> <flag name='seccomp-blacklist'/> <flag name='query-cpus-fast'/> + <flag name='disk-write-cache'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>419215</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml index 122801dd30..70ae8f91c7 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -118,6 +118,7 @@ <flag name='qcow2-luks'/> <flag name='seccomp-blacklist'/> <flag name='query-cpus-fast'/> + <flag name='disk-write-cache'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml index 37c9243a58..d809a78380 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml @@ -194,6 +194,7 @@ <flag name='pcie-pci-bridge'/> <flag name='seccomp-blacklist'/> <flag name='query-cpus-fast'/> + <flag name='disk-write-cache'/> <version>2011090</version> <kvmVersion>0</kvmVersion> <microcodeVersion>390060</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml index a585af453c..34eed23694 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml @@ -102,6 +102,7 @@ <flag name='virtio-blk.num-queues'/> <flag name='sclplmconsole'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2007000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>216732</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml index 55c121c596..ee4b25d7fd 100644 --- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml @@ -175,6 +175,7 @@ <flag name='virtio-blk.num-queues'/> <flag name='isa-serial'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2007000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>239029</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml index 1ac60bb403..21046c0546 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -104,6 +104,7 @@ <flag name='virtio-blk.num-queues'/> <flag name='sclplmconsole'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2007093</version> <kvmVersion>0</kvmVersion> <microcodeVersion>241633</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml index 831a768977..c4801ac23a 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml @@ -177,6 +177,7 @@ <flag name='virtio-blk.num-queues'/> <flag name='isa-serial'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2008000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>255684</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml index 4998edf7a0..73f42a7392 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml @@ -143,6 +143,7 @@ <flag name='iscsi.password-secret'/> <flag name='isa-serial'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>346538</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml index d29994bbfd..30fce6ecf1 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -107,6 +107,7 @@ <flag name='disk-share-rw'/> <flag name='iscsi.password-secret'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>265051</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index d813a96a13..e1dc257a75 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -190,6 +190,7 @@ <flag name='iscsi.password-secret'/> <flag name='isa-serial'/> <flag name='dump-completed'/> + <flag name='disk-write-cache'/> <version>2009000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>320947</microcodeVersion> -- 2.16.2

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@redhat.com> --- src/qemu/qemu_command.c | 27 ++++++++++++++++++++++ .../disk-drive-write-cache.x86_64-2.7.0.args | 10 ++++---- .../disk-drive-write-cache.x86_64-latest.args | 10 ++++---- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 238c6ed620..b666f3715f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1824,6 +1824,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, @@ -2140,6 +2164,9 @@ qemuBuildDriveDevStr(const virDomainDef *def, } } + if (qemuBuildDriveDevCacheStr(disk, &opt, qemuCaps) < 0) + goto error; + if (virBufferCheckError(&opt) < 0) goto error; diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args index 9af27dbbaf..7b67f4369c 100644 --- a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-2.7.0.args @@ -28,16 +28,18 @@ server,nowait \ -device lsi,id=scsi0,bus=pci.0,addr=0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=writeback \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\ +write-cache=on \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\ cache=none \ --device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,\ +write-cache=on \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\ cache=writethrough \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ -id=virtio-disk0 \ +id=virtio-disk0,write-cache=off \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\ cache=directsync \ -device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\ -removable=off \ +removable=off,write-cache=off \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args index b4bef87529..a63c5b7477 100644 --- a/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-drive-write-cache.x86_64-latest.args @@ -28,18 +28,20 @@ server,nowait \ -device lsi,id=scsi0,bus=pci.0,addr=0x2 \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=writeback \ --device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1,\ +write-cache=on \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-scsi0-0-0,\ cache=none \ --device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-device scsi-hd,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0,\ +write-cache=on \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-virtio-disk0,\ cache=writethrough \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ -id=virtio-disk0 \ +id=virtio-disk0,write-cache=off \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-usb-disk1,\ cache=directsync \ -device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk1,id=usb-disk1,\ -removable=off \ +removable=off,write-cache=off \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on -- 2.16.2

On Wed, Apr 18, 2018 at 05:33:38PM +0200, Peter Krempa wrote:
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@redhat.com> --- src/qemu/qemu_command.c | 27 ++++++++++++++++++++++ .../disk-drive-write-cache.x86_64-2.7.0.args | 10 ++++---- .../disk-drive-write-cache.x86_64-latest.args | 10 ++++---- 3 files changed, 39 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa