Qemu < 0.10.0 did not support it, and virt-* tools now try to add this by default, so it's extra important we ensure the option exists. Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> --- src/qemu_conf.c | 5 ++++- src/qemu_conf.h | 1 + tests/qemuhelptest.c | 8 ++++---- tests/qemuxml2argvtest.c | 20 ++++++++++++-------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index a669c11..0c6221d 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -435,6 +435,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_DRIVE; if (strstr(help, "cache=writethrough|writeback|none")) flags |= QEMUD_CMD_FLAG_DRIVE_CACHE_V2; + if (strstr(help, "format=")) + flags |= QEMUD_CMD_FLAG_DRIVE_FORMAT; } if (strstr(help, "boot=on")) flags |= QEMUD_CMD_FLAG_DRIVE_BOOT; @@ -1231,7 +1233,8 @@ int qemudBuildCommandLine(virConnectPtr conn, if (bootable && disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) virBufferAddLit(&opt, ",boot=on"); - if (disk->driverType) + if (disk->driverType && + qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_FORMAT) virBufferVSprintf(&opt, ",format=%s", disk->driverType); if (disk->cachemode) { diff --git a/src/qemu_conf.h b/src/qemu_conf.h index 280ad25..c0ed46d 100644 --- a/src/qemu_conf.h +++ b/src/qemu_conf.h @@ -56,6 +56,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC = (1 << 11), /* New migration syntax after merge to QEMU with EXEC transport */ QEMUD_CMD_FLAG_DRIVE_CACHE_V2 = (1 << 12), /* Is the cache= flag wanting new v2 values */ QEMUD_CMD_FLAG_KVM = (1 << 13), /* Whether KVM is compiled in */ + QEMUD_CMD_FLAG_DRIVE_FORMAT = (1 << 14), /* Is -drive format= avail */ }; /* Main driver state */ diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 836010f..bf8a293 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -90,10 +90,10 @@ mymain(int argc, char **argv) } while (0) DO_TEST("qemu-0.9.1", 0x002f, 9001, 0, 0); - DO_TEST("kvm-74", 0x233e, 9001, 1, 74); - DO_TEST("qemu-0.10.5", 0x1c6f, 10005, 0, 0); - DO_TEST("qemu-kvm-0.10.5", 0x3d7e, 10005, 1, 0); - DO_TEST("kvm-86", 0x3d7e, 10050, 1, 0); + DO_TEST("kvm-74", 0x633e, 9001, 1, 74); + DO_TEST("qemu-0.10.5", 0x5c6f, 10005, 0, 0); + DO_TEST("qemu-kvm-0.10.5", 0x7d7e, 10005, 1, 0); + DO_TEST("kvm-86", 0x7d7e, 10050, 1, 0); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5ba6db3..28609eb 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -196,17 +196,21 @@ mymain(int argc, char **argv) DO_TEST("disk-drive-boot-cdrom", QEMUD_CMD_FLAG_DRIVE | QEMUD_CMD_FLAG_DRIVE_BOOT); DO_TEST("disk-drive-fmt-qcow", QEMUD_CMD_FLAG_DRIVE | - QEMUD_CMD_FLAG_DRIVE_BOOT); - DO_TEST("disk-drive-shared", QEMUD_CMD_FLAG_DRIVE); - DO_TEST("disk-drive-cache-v1-wt", QEMUD_CMD_FLAG_DRIVE); - DO_TEST("disk-drive-cache-v1-wb", QEMUD_CMD_FLAG_DRIVE); - DO_TEST("disk-drive-cache-v1-none", QEMUD_CMD_FLAG_DRIVE); + QEMUD_CMD_FLAG_DRIVE_BOOT | QEMUD_CMD_FLAG_DRIVE_FORMAT); + DO_TEST("disk-drive-shared", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DRIVE_FORMAT); + DO_TEST("disk-drive-cache-v1-wt", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DRIVE_FORMAT); + DO_TEST("disk-drive-cache-v1-wb", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DRIVE_FORMAT); + DO_TEST("disk-drive-cache-v1-none", QEMUD_CMD_FLAG_DRIVE | + QEMUD_CMD_FLAG_DRIVE_FORMAT); DO_TEST("disk-drive-cache-v2-wt", QEMUD_CMD_FLAG_DRIVE | - QEMUD_CMD_FLAG_DRIVE_CACHE_V2); + QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT); DO_TEST("disk-drive-cache-v2-wb", QEMUD_CMD_FLAG_DRIVE | - QEMUD_CMD_FLAG_DRIVE_CACHE_V2); + QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT); DO_TEST("disk-drive-cache-v2-none", QEMUD_CMD_FLAG_DRIVE | - QEMUD_CMD_FLAG_DRIVE_CACHE_V2); + QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT); DO_TEST("disk-usb", 0); DO_TEST("graphics-vnc", 0); -- 1.6.0.6 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list