[libvirt] [PATCH 00/12] qemu: command: Move frontend disk attributes to -device (blockdev-add saga)

For legacy reasons we've formatted some attributes of the disk frontend in -drive which now mostly holds backend arguments. (-drive was used by itself some time ago and still is for sdcards) Since we will no longer use -drive with -blockdev, some of them need to be moved (and the rest interpreted with -blockdev). Peter Krempa (12): qemu: command: Split out geometry frontend attribute formatting from -drive qemu: command: Format frontend props with -device rather than -drive tests: qemuxml2xml: Run the 'disk-serial' test tests: qemuxml2argv: Test SD card with serial number qemu: command: Move disk 'serial' into frontend parameter formatter qemu: command: Move around order of generating -drive arguments qemu: command: Refactor logic when formatting -drive qemu: command: Move disk trhottling argument building into a separate function qemu: command: Move formatting of disk io error policy from -drive qemu: command: Move around logic for formatting bootindex qemu: command: Move formatting of 'boot' attribute to -device qemu: command: Explain formatting of 'media=cdrom' in -drive src/qemu/qemu_command.c | 252 ++++++++++++--------- src/qemu/qemu_command.h | 2 +- src/qemu/qemu_hotplug.c | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-cdrom.args | 2 +- .../qemuxml2argv-boot-complex-bootindex.args | 2 +- .../qemuxml2argv-boot-complex.args | 6 +- ...xml2argv-boot-menu-disable-drive-bootindex.args | 2 +- .../qemuxml2argv-boot-menu-disable-drive.args | 2 +- .../qemuxml2argv-boot-menu-disable.args | 2 +- .../qemuxml2argv-boot-menu-enable-bootindex.args | 2 +- ...qemuxml2argv-boot-menu-enable-with-timeout.args | 2 +- .../qemuxml2argv-boot-menu-enable.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-multi.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-order.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-strict.args | 2 +- .../qemuxml2argv-controller-order.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args | 4 +- .../qemuxml2argv-disk-cdrom-empty.args | 2 +- .../qemuxml2argv-disk-cdrom-network-ftp.args | 2 +- .../qemuxml2argv-disk-cdrom-network-ftps.args | 2 +- .../qemuxml2argv-disk-cdrom-network-http.args | 2 +- .../qemuxml2argv-disk-cdrom-network-https.args | 2 +- .../qemuxml2argv-disk-cdrom-network-tftp.args | 2 +- ...qemuxml2argv-disk-cdrom-tray-no-device-cap.args | 2 +- .../qemuxml2argv-disk-cdrom-tray.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-disk-cdrom.args | 2 +- .../qemuxml2argv-disk-copy_on_read.args | 2 +- .../qemuxml2argv-disk-drive-boot-cdrom.args | 4 +- .../qemuxml2argv-disk-drive-boot-disk.args | 4 +- .../qemuxml2argv-disk-drive-cache-directsync.args | 4 +- .../qemuxml2argv-disk-drive-cache-unsafe.args | 4 +- .../qemuxml2argv-disk-drive-cache-v2-none.args | 4 +- .../qemuxml2argv-disk-drive-cache-v2-wb.args | 4 +- .../qemuxml2argv-disk-drive-cache-v2-wt.args | 4 +- .../qemuxml2argv-disk-drive-detect-zeroes.args | 2 +- .../qemuxml2argv-disk-drive-discard.args | 2 +- ...uxml2argv-disk-drive-error-policy-enospace.args | 9 +- .../qemuxml2argv-disk-drive-error-policy-stop.args | 9 +- ...gv-disk-drive-error-policy-wreport-rignore.args | 9 +- .../qemuxml2argv-disk-drive-fmt-qcow.args | 4 +- .../qemuxml2argv-disk-drive-no-boot.args | 4 +- .../qemuxml2argv-disk-drive-readonly-disk.args | 2 +- ...qemuxml2argv-disk-drive-readonly-no-device.args | 2 +- .../qemuxml2argv-disk-drive-shared.args | 9 +- .../qemuxml2argv-disk-geometry.args | 6 +- .../qemuxml2argv-disk-ide-wwn.args | 5 +- .../qemuxml2argv-disk-ioeventfd.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-disk-order.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-disk-serial.args | 9 +- .../qemuxml2argvdata/qemuxml2argv-disk-serial.xml | 5 + .../qemuxml2argv-disk-snapshot.args | 4 +- .../qemuxml2argv-disk-source-pool-mode.args | 12 +- .../qemuxml2argv-disk-source-pool.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-disk-virtio.args | 4 +- tests/qemuxml2argvdata/qemuxml2argv-event_idx.args | 2 +- .../qemuxml2argv-graphics-spice-timeout.args | 2 +- .../qemuxml2argv-hugepages-numa.args | 2 +- .../qemuxml2argv-pci-autoadd-addr.args | 4 +- .../qemuxml2argv-pci-autoadd-idx.args | 4 +- .../qemuxml2argv-pci-autofill-addr.args | 4 +- .../qemuxml2argvdata/qemuxml2argv-pci-bridge.args | 4 +- tests/qemuxml2argvdata/qemuxml2argv-pci-many.args | 4 +- .../qemuxml2argv-user-aliases.args | 2 +- .../qemuxml2xmlout-disk-serial.xml | 47 ++++ tests/qemuxml2xmltest.c | 2 + 65 files changed, 305 insertions(+), 219 deletions(-) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml -- 2.14.3

Historically we've formatted a lot of the attributes of a disk (disk geometry, etc) with -drive. Since we use -device now, they should be formatted there. Extract them to a separate function for keeping compatibility with SDcards which still use only -drive. Start this by moving the geometry into a separate function. --- src/qemu/qemu_command.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e3c2d7e24f..9dac68981a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1609,6 +1609,26 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, } +static void +qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, + virBufferPtr buf) +{ + /* generate geometry command string */ + if (disk->geometry.cylinders > 0 && + disk->geometry.heads > 0 && + disk->geometry.sectors > 0) { + virBufferAsprintf(buf, ",cyls=%u,heads=%u,secs=%u", + disk->geometry.cylinders, + disk->geometry.heads, + disk->geometry.sectors); + + if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT) + virBufferAsprintf(buf, ",trans=%s", + virDomainDiskGeometryTransTypeToString(disk->geometry.trans)); + } +} + + char * qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, @@ -1616,8 +1636,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps) { virBuffer opt = VIR_BUFFER_INITIALIZER; - const char *trans = - virDomainDiskGeometryTransTypeToString(disk->geometry.trans); bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus); /* if we are using -device this will be checked elsewhere */ @@ -1671,19 +1689,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=on"); - /* generate geometry command string */ - if (disk->geometry.cylinders > 0 && - disk->geometry.heads > 0 && - disk->geometry.sectors > 0) { - - virBufferAsprintf(&opt, ",cyls=%u,heads=%u,secs=%u", - disk->geometry.cylinders, - disk->geometry.heads, - disk->geometry.sectors); - - if (disk->geometry.trans != VIR_DOMAIN_DISK_TRANS_DEFAULT) - virBufferAsprintf(&opt, ",trans=%s", trans); - } + qemuBuildDiskFrontendAttributes(disk, &opt); if (disk->serial && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) { -- 2.14.3

Historically we've formatted a lot of the attributes of a disk (disk geometry, etc) with -drive. Since we use -device now, they should be formatted there. --- src/qemu/qemu_command.c | 5 ++++- tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9dac68981a..8c7bb245ed 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1689,7 +1689,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=on"); - qemuBuildDiskFrontendAttributes(disk, &opt); + if (!emitDeviceSyntax) + qemuBuildDiskFrontendAttributes(disk, &opt); if (disk->serial && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) { @@ -2124,6 +2125,8 @@ qemuBuildDriveDevStr(const virDomainDef *def, disk->blockio.physical_block_size); } + qemuBuildDiskFrontendAttributes(disk, &opt); + if (disk->wwn) { if (STRPREFIX(disk->wwn, "0x")) virBufferAsprintf(&opt, ",wwn=%s", disk->wwn); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args index 3badaae28c..2b92dde39f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0,\ -cyls=16383,heads=16,secs=63,trans=lba \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,cyls=16383,\ +heads=16,secs=63,trans=lba \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -- 2.14.3

On Mon, Nov 20, 2017 at 18:25:19 +0100, Peter Krempa wrote:
Historically we've formatted a lot of the attributes of a disk (disk geometry, etc) with -drive. Since we use -device now, they should be formatted there. --- src/qemu/qemu_command.c | 5 ++++- tests/qemuxml2argvdata/qemuxml2argv-disk-geometry.args | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-)
So, SNACK to this. Qemu moved the parameters at some time but this does not do any capability checking so it may have broken older qemus. I'll strip this patch and the fallout from this series and just send the refactors. Later on I'll conditionally enable this when we start using -blockdev and thus these would be lost.

--- .../qemuxml2xmlout-disk-serial.xml | 42 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml new file mode 100644 index 0000000000..14625a4164 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml @@ -0,0 +1,42 @@ +<domain type='kvm'> + <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'>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'> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <serial> WD-WMAP9A966149</serial> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <disk type='block' device='disk'> + <source dev='/dev/HostVG/AllSerialChars'/> + <target dev='hdb' bus='ide'/> + <serial>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ .+</serial> + <address type='drive' controller='0' bus='0' target='0' unit='2'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 99d831c32a..d66cf155d4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -712,6 +712,8 @@ mymain(void) DO_TEST("disk-drive-discard", NONE); DO_TEST("disk-drive-detect-zeroes", NONE); + DO_TEST("disk-serial", NONE); + DO_TEST("virtio-rng-random", NONE); DO_TEST("virtio-rng-egd", NONE); -- 2.14.3

--- tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args | 1 + tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml | 5 +++++ tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args index a44af97fb7..18acb4f7af 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args @@ -25,4 +25,5 @@ serial=\ \ WD-WMAP9A966149' \ -drive 'file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2,\ serial=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_\ .+' \ -device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \ +-drive file=/some/file,format=raw,if=sd,index=0,serial=sdserial \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml index ccd78204bf..ea71f2c339 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.xml @@ -26,6 +26,11 @@ <serial>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ .+</serial> <address type='drive' controller='0' bus='0' target='0' unit='2'/> </disk> + <disk type='file' device='disk'> + <source file='/some/file'/> + <target dev='sda' bus='sd'/> + <serial>sdserial</serial> + </disk> <controller type='usb' index='0'/> <controller type='ide' index='0'/> <memballoon model='virtio'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml index 14625a4164..5a26e549df 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-serial.xml @@ -26,6 +26,11 @@ <serial>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ .+</serial> <address type='drive' controller='0' bus='0' target='0' unit='2'/> </disk> + <disk type='file' device='disk'> + <source file='/some/file'/> + <target dev='sda' bus='sd'/> + <serial>sdserial</serial> + </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> -- 2.14.3

Disk serial is not a property of the image but of the disk frontend. Account for this appropriately. --- src/qemu/qemu_command.c | 17 +++++++++-------- .../qemuxml2argv-disk-drive-shared.args | 5 +++-- tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args | 5 ++--- tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args | 8 ++++---- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8c7bb245ed..49fd05034b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1611,6 +1611,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, static void qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, virBufferPtr buf) { /* generate geometry command string */ @@ -1626,6 +1627,12 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virBufferAsprintf(buf, ",trans=%s", virDomainDiskGeometryTransTypeToString(disk->geometry.trans)); } + + if (disk->serial && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) { + virBufferAddLit(buf, ",serial="); + virBufferEscape(buf, '\\', " ", "%s", disk->serial); + } } @@ -1690,13 +1697,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAddLit(&opt, ",readonly=on"); if (!emitDeviceSyntax) - qemuBuildDiskFrontendAttributes(disk, &opt); - - if (disk->serial && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) { - virBufferAddLit(&opt, ",serial="); - virBufferEscape(&opt, '\\', " ", "%s", disk->serial); - } + qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); if (disk->cachemode) { virBufferAsprintf(&opt, ",cache=%s", @@ -2125,7 +2126,7 @@ qemuBuildDriveDevStr(const virDomainDef *def, disk->blockio.physical_block_size); } - qemuBuildDiskFrontendAttributes(disk, &opt); + qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); if (disk->wwn) { if (STRPREFIX(disk->wwn, "0x")) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args index 502157bf8c..2bcb875931 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args @@ -20,8 +20,9 @@ server,nowait \ -boot c \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ -serial=XYZXYZXYZYXXYZYZYXYZY,cache=none \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +cache=none \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ +serial=XYZXYZXYZYXXYZYZYXYZY \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ id=drive-ide0-1-0,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args index f2fb372a2a..b6138c9537 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-wwn.args @@ -19,8 +19,7 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\ -serial=WD-WMAP9A966149 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \ -device ide-hd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\ -wwn=0x5000c50015ea71ad \ +serial=WD-WMAP9A966149,wwn=0x5000c50015ea71ad \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args index 18acb4f7af..0a0171a067 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-serial.args @@ -19,11 +19,11 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive 'file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1,\ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-1 \ +-device 'ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,\ serial=\ \ WD-WMAP9A966149' \ --device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive 'file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2,\ +-drive file=/dev/HostVG/AllSerialChars,format=raw,if=none,id=drive-ide0-0-2 \ +-device 'ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2,\ serial=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_\ .+' \ --device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \ -drive file=/some/file,format=raw,if=sd,index=0,serial=sdserial \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -- 2.14.3

Move together sections which are conditionaly executed depending on whether -device will be used together with the -drive. --- src/qemu/qemu_command.c | 31 +++++++++++----------- .../qemuxml2argvdata/qemuxml2argv-boot-cdrom.args | 2 +- .../qemuxml2argv-boot-complex-bootindex.args | 2 +- .../qemuxml2argv-boot-complex.args | 2 +- ...xml2argv-boot-menu-disable-drive-bootindex.args | 2 +- .../qemuxml2argv-boot-menu-disable-drive.args | 2 +- .../qemuxml2argv-boot-menu-disable.args | 2 +- .../qemuxml2argv-boot-menu-enable-bootindex.args | 2 +- ...qemuxml2argv-boot-menu-enable-with-timeout.args | 2 +- .../qemuxml2argv-boot-menu-enable.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-multi.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-order.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-boot-strict.args | 2 +- .../qemuxml2argv-controller-order.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args | 4 +-- .../qemuxml2argv-disk-cdrom-empty.args | 2 +- .../qemuxml2argv-disk-cdrom-network-ftp.args | 2 +- .../qemuxml2argv-disk-cdrom-network-ftps.args | 2 +- .../qemuxml2argv-disk-cdrom-network-http.args | 2 +- .../qemuxml2argv-disk-cdrom-network-https.args | 2 +- .../qemuxml2argv-disk-cdrom-network-tftp.args | 2 +- ...qemuxml2argv-disk-cdrom-tray-no-device-cap.args | 2 +- .../qemuxml2argv-disk-cdrom-tray.args | 4 +-- .../qemuxml2argvdata/qemuxml2argv-disk-cdrom.args | 2 +- .../qemuxml2argv-disk-copy_on_read.args | 2 +- .../qemuxml2argv-disk-drive-boot-cdrom.args | 4 +-- .../qemuxml2argv-disk-drive-boot-disk.args | 4 +-- .../qemuxml2argv-disk-drive-cache-directsync.args | 4 +-- .../qemuxml2argv-disk-drive-cache-unsafe.args | 4 +-- .../qemuxml2argv-disk-drive-cache-v2-none.args | 4 +-- .../qemuxml2argv-disk-drive-cache-v2-wb.args | 4 +-- .../qemuxml2argv-disk-drive-cache-v2-wt.args | 4 +-- .../qemuxml2argv-disk-drive-detect-zeroes.args | 2 +- .../qemuxml2argv-disk-drive-discard.args | 2 +- ...uxml2argv-disk-drive-error-policy-enospace.args | 4 +-- .../qemuxml2argv-disk-drive-error-policy-stop.args | 4 +-- ...gv-disk-drive-error-policy-wreport-rignore.args | 4 +-- .../qemuxml2argv-disk-drive-fmt-qcow.args | 4 +-- .../qemuxml2argv-disk-drive-no-boot.args | 4 +-- .../qemuxml2argv-disk-drive-readonly-disk.args | 2 +- ...qemuxml2argv-disk-drive-readonly-no-device.args | 2 +- .../qemuxml2argv-disk-drive-shared.args | 4 +-- .../qemuxml2argv-disk-ioeventfd.args | 2 +- .../qemuxml2argvdata/qemuxml2argv-disk-order.args | 4 +-- .../qemuxml2argv-disk-snapshot.args | 4 +-- .../qemuxml2argv-disk-source-pool-mode.args | 12 ++++----- .../qemuxml2argv-disk-source-pool.args | 4 +-- .../qemuxml2argvdata/qemuxml2argv-disk-virtio.args | 4 +-- tests/qemuxml2argvdata/qemuxml2argv-event_idx.args | 2 +- .../qemuxml2argv-graphics-spice-timeout.args | 2 +- .../qemuxml2argv-hugepages-numa.args | 2 +- .../qemuxml2argv-pci-autoadd-addr.args | 4 +-- .../qemuxml2argv-pci-autoadd-idx.args | 4 +-- .../qemuxml2argv-pci-autofill-addr.args | 4 +-- .../qemuxml2argvdata/qemuxml2argv-pci-bridge.args | 4 +-- tests/qemuxml2argvdata/qemuxml2argv-pci-many.args | 4 +-- .../qemuxml2argv-user-aliases.args | 2 +- 57 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 49fd05034b..455cb7ae36 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1659,18 +1659,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAsprintf(&opt, "if=%s", virDomainDiskQEMUBusTypeToString(disk->bus)); - if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { - if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) - virBufferAddLit(&opt, ",media=cdrom"); - } else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) - virBufferAddLit(&opt, ",media=cdrom"); - } else { - virBufferAddLit(&opt, ",media=cdrom"); - } - } - if (emitDeviceSyntax) { char *drivealias = qemuAliasFromDisk(disk); if (!drivealias) @@ -1687,6 +1675,22 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } virBufferAsprintf(&opt, ",index=%d", idx); } + + if (!emitDeviceSyntax) + qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); + + if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { + if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) + virBufferAddLit(&opt, ",media=cdrom"); + } else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) + virBufferAddLit(&opt, ",media=cdrom"); + } else { + virBufferAddLit(&opt, ",media=cdrom"); + } + } + if (bootable && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) && (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || @@ -1696,9 +1700,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=on"); - if (!emitDeviceSyntax) - qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); - if (disk->cachemode) { virBufferAsprintf(&opt, ",cache=%s", qemuDiskCacheV2TypeToString(disk->cachemode)); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args index c0e8854213..9b5b612ed9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args @@ -19,6 +19,6 @@ server,nowait \ -no-acpi \ -boot d \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex-bootindex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex-bootindex.args index a503781a15..639acbd7b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex-bootindex.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex-bootindex.args @@ -28,7 +28,7 @@ id=virtio-disk1 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -drive file=/dev/HostVG/hdb,format=raw,if=none,id=drive-ide0-0-1 \ -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=/dev/HostVG/hdc,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/HostVG/hdc,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args index 600d393501..b7a2fc119a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args @@ -29,7 +29,7 @@ id=virtio-disk1 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -drive file=/dev/HostVG/hdb,format=raw,if=none,id=drive-ide0-0-1 \ -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=/dev/HostVG/hdc,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/HostVG/hdc,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive-bootindex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive-bootindex.args index 9fe4e13a35..4825880413 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive-bootindex.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive-bootindex.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot menu=off \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive.args index 31b2e2033c..caccedfc3c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable-drive.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot order=d,menu=off \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable.args index 31b2e2033c..caccedfc3c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-disable.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot order=d,menu=off \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args index 3b5fcd64fb..811dd58f1a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-bootindex.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot menu=on \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.args index 7602991982..90e3b55eea 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable-with-timeout.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot order=d,menu=on,splash-time=3000 \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable.args index 861cbac031..6d7b0b8d3b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-menu-enable.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot order=d,menu=on \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-multi.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-multi.args index 37cf3a2029..545105d509 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-multi.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-multi.args @@ -19,7 +19,7 @@ server,nowait \ -no-acpi \ -boot order=dcna,menu=on \ -usb \ --drive file=/dev/cdrom,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-order.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-order.args index 66eb4cdbaf..8c366f1ddf 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-order.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-order.args @@ -20,7 +20,7 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/root/boot.iso,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args index d9712f2d64..9aeb801993 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-strict.args @@ -29,7 +29,7 @@ id=virtio-disk1 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -drive file=/dev/HostVG/hdb,format=raw,if=none,id=drive-ide0-0-1 \ -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=/dev/HostVG/hdc,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/HostVG/hdc,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args index 60bdb37286..70a8ba9ce9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args @@ -26,7 +26,7 @@ aio=native \ -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/tmp/Fedora-17-x86_64-Live-Desktop.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-net-pci,vlan=0,id=net0,mac=52:54:00:4d:4b:19,bus=pci.0,addr=0x3 \ -net user,vlan=0,name=hostnet0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args index 32c0b77b4f..67b1776ca9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args @@ -22,7 +22,7 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=none,aio=native \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on,aio=threads \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on,aio=threads \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args index 1550cc128e..b53d547497 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args @@ -21,5 +21,5 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on \ +-drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args index 1cb062db11..ab51b19768 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftp.args @@ -19,6 +19,6 @@ server,nowait \ -boot d \ -usb \ -drive file=ftp://host.name:21/url/path/file.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args index a6d2435f67..aed2331e7a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-ftps.args @@ -19,6 +19,6 @@ server,nowait \ -boot d \ -usb \ -drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.args index edd632441e..2e20791095 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-http.args @@ -19,6 +19,6 @@ server,nowait \ -boot d \ -usb \ -drive file=http://host.name:80/url/path/file.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args index fbfd236102..9aae5bf4a4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-https.args @@ -19,6 +19,6 @@ server,nowait \ -boot d \ -usb \ -drive file=https://host.name:443/url/path/file.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.args index f8843c4380..005c87c691 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-network-tftp.args @@ -19,6 +19,6 @@ server,nowait \ -boot d \ -usb \ -drive file=tftp://host.name:69/url/path/file.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray-no-device-cap.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray-no-device-cap.args index 7442147f60..be4269718a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray-no-device-cap.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray-no-device-cap.args @@ -21,6 +21,6 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on \ +-drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray.args index 0c7ca87429..5df5b847f1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-tray.args @@ -24,8 +24,8 @@ id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ --drive if=none,media=cdrom,id=drive-ide0-1-1,readonly=on \ +-drive if=none,id=drive-ide0-1-1,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args index de46167a1f..583fddc94c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args @@ -21,6 +21,6 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/root/boot.iso,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args index 1aead99440..8353a1573b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-copy_on_read.args @@ -25,7 +25,7 @@ id=drive-virtio-disk0,copy-on-read=on \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-net-pci,tx=bh,vlan=0,id=net0,mac=52:54:00:e5:48:58,bus=pci.0,\ addr=0x3 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args index cae8f0503e..64ef2a1777 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args @@ -21,6 +21,6 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args index 3294ce1ded..37eb9d5e5f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args @@ -21,6 +21,6 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-directsync.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-directsync.args index 5f5b20b75c..0d557edd38 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-directsync.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-directsync.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=directsync \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-unsafe.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-unsafe.args index a3c3e7f7f3..12a12eac99 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-unsafe.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-unsafe.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=unsafe \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-none.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-none.args index 8893289151..b1e29d16de 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-none.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-none.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=none \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wb.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wb.args index 3657004b69..8189a11f83 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wb.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wb.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=writeback \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wt.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wt.args index 17e14113c2..01f39c7344 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wt.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-cache-v2-wt.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=writethrough \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args index f4d81e167b..6b146fc76a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-detect-zeroes.args @@ -24,6 +24,6 @@ id=drive-virtio-disk0,discard=unmap,detect-zeroes=unmap \ -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on,discard=ignore,detect-zeroes=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on,discard=ignore,detect-zeroes=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.args index dfd6b010cf..6e614ac995 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-discard.args @@ -24,6 +24,6 @@ id=drive-virtio-disk0,discard=unmap \ -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on,discard=ignore \ +id=drive-ide0-1-0,media=cdrom,readonly=on,discard=ignore \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args index 8a0e03efd1..704a571dd3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=none,werror=enospc \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args index 169efc38e2..2e87d727fb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=none,werror=stop,rerror=stop \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args index a11743f0c7..d3a9ec45eb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args @@ -22,6 +22,6 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ cache=none,werror=report,rerror=ignore \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fmt-qcow.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fmt-qcow.args index 4c65fa598e..00077bb168 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fmt-qcow.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fmt-qcow.args @@ -21,6 +21,6 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-no-boot.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-no-boot.args index 5efae6dd87..1dc1010f24 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-no-boot.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-no-boot.args @@ -21,8 +21,8 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ bootindex=2 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0,\ bootindex=1 \ -drive file=/dev/fd0,format=raw,if=none,id=drive-fdc0-0-0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args index a207e49f23..e4ceba1b1b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-disk.args @@ -22,7 +22,7 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/sr0,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/sr0,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args index a207e49f23..e4ceba1b1b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-readonly-no-device.args @@ -22,7 +22,7 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/sr0,format=raw,if=none,media=cdrom,id=drive-ide0-1-0,\ +-drive file=/dev/sr0,format=raw,if=none,id=drive-ide0-1-0,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args index 2bcb875931..4288dfc13a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args @@ -23,7 +23,7 @@ server,nowait \ cache=none \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ serial=XYZXYZXYZYXXYZYZYXYZY \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args index a14fbd19b3..e752b38744 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ioeventfd.args @@ -25,7 +25,7 @@ id=drive-virtio-disk0 \ -device virtio-blk-pci,ioeventfd=on,scsi=off,bus=pci.0,addr=0x4,\ drive=drive-virtio-disk0,id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-net-pci,tx=bh,ioeventfd=off,vlan=0,id=net0,\ mac=52:54:00:e5:48:58,bus=pci.0,addr=0x3 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-order.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-order.args index 63dc49d51f..740d0182f7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-order.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-order.args @@ -21,8 +21,8 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=/tmp/data.img,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.args index cf70560e98..4106c9fcfa 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.args @@ -25,7 +25,7 @@ cache=none \ -drive file=/dev/HostVG/QEMUGuest3,format=qcow2,if=none,id=drive-ide0-2-0,\ cache=none \ -device ide-drive,bus=ide.2,unit=0,drive=drive-ide0-2-0,id=ide0-2-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args index 5b4e65e109..1fcfe8caba 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args @@ -20,15 +20,15 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=/some/block/device/unit:0:0:1,if=none,media=cdrom,\ -id=drive-ide0-0-1,readonly=on \ +-drive file=/some/block/device/unit:0:0:1,if=none,id=drive-ide0-0-1,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=iscsi://iscsi.example.com:3260/demo-target/2,if=none,media=cdrom,\ -id=drive-ide0-0-2,readonly=on \ +-drive file=iscsi://iscsi.example.com:3260/demo-target/2,if=none,\ +id=drive-ide0-0-2,media=cdrom,readonly=on \ -device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \ -drive file=/tmp/idedisk.img,format=raw,if=none,id=drive-ide0-0-3 \ -device ide-drive,bus=ide.0,unit=3,drive=drive-ide0-0-3,id=ide0-0-3 \ --drive file=iscsi://iscsi.example.com:3260/demo-target/3,if=none,media=cdrom,\ -id=drive-ide0-0-4,readonly=on \ +-drive file=iscsi://iscsi.example.com:3260/demo-target/3,if=none,\ +id=drive-ide0-0-4,media=cdrom,readonly=on \ -device ide-drive,bus=ide.0,unit=4,drive=drive-ide0-0-4,id=ide0-0-4 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args index 99fba37304..101462f0d6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args @@ -20,10 +20,10 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=/some/block/device/cdrom,if=none,media=cdrom,id=drive-ide0-0-1,\ +-drive file=/some/block/device/cdrom,if=none,id=drive-ide0-0-1,media=cdrom,\ readonly=on \ -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on \ +-drive if=none,id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=/tmp/idedisk.img,format=raw,if=none,id=drive-ide0-0-2 \ -device ide-drive,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args index 47afebaf2e..273541b446 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args @@ -21,8 +21,8 @@ server,nowait \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=/tmp/data.img,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-event_idx.args b/tests/qemuxml2argvdata/qemuxml2argv-event_idx.args index 1c9f4f1152..ff7b0b6ea0 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-event_idx.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-event_idx.args @@ -25,7 +25,7 @@ id=drive-virtio-disk0 \ -device virtio-blk-pci,event_idx=on,scsi=off,bus=pci.0,addr=0x4,\ drive=drive-virtio-disk0,id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device virtio-net-pci,event_idx=off,vlan=0,id=net0,mac=52:54:00:e5:48:58,\ bus=pci.0,addr=0x3 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args index bb9d613959..06a1245763 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args @@ -25,7 +25,7 @@ id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -drive file=/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso,format=raw,if=none,\ -media=cdrom,id=drive-ide0-1-0,readonly=on \ +id=drive-ide0-1-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \ -net tap,fd=3,vlan=0,name=hostnet0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args index 067cea741e..8b7dae5cb0 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args @@ -38,7 +38,7 @@ addr=0x6 \ id=drive-virtio-disk0 \ -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,\ id=virtio-disk0 \ --drive if=none,media=cdrom,id=drive-ide0-0-0,readonly=on \ +-drive if=none,id=drive-ide0-0-0,media=cdrom,readonly=on \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -chardev socket,id=charchannel0,\ path=/var/lib/libvirt/qemu/channel/target/fedora.org.qemu.guest_agent.0,server,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-addr.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-addr.args index 0d3f25913d..b2395efe88 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-addr.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-addr.args @@ -25,8 +25,8 @@ server,nowait \ -device pci-bridge,chassis_nr=6,id=pci.6,bus=pci.0,addr=0x8 \ -device pci-bridge,chassis_nr=7,id=pci.7,bus=pci.0,addr=0x9 \ -usb \ --drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -vga cirrus \ -device virtio-balloon-pci,id=balloon0,bus=pci.7,addr=0x6 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args index 6b2f21bba0..d91720e9d7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-autoadd-idx.args @@ -26,8 +26,8 @@ server,nowait \ -device pci-bridge,chassis_nr=6,id=pci.6,bus=pci.0,addr=0x9 \ -device pci-bridge,chassis_nr=7,id=pci.7,bus=pci.0,addr=0xa \ -usb \ --drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -vga cirrus \ -device virtio-balloon-pci,id=balloon0,bus=pci.4,addr=0x6 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-autofill-addr.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-autofill-addr.args index 236f348895..791d141ab6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-autofill-addr.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-autofill-addr.args @@ -19,8 +19,8 @@ server,nowait \ -no-acpi \ -boot c \ -usb \ --drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\ -id=drive-virtio-disk0,readonly=on \ +-drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-virtio-disk0,\ +media=cdrom,readonly=on \ -device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ id=virtio-disk0 \ -vga cirrus \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.args index 616713d356..1d2a0428eb 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.args @@ -19,8 +19,8 @@ server,nowait \ -device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x3 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x4 \ -usb \ --drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -device rtl8139,vlan=0,id=net0,mac=52:54:00:f1:95:51,bus=pci.0,addr=0x5 \ -net user,vlan=0,name=hostnet0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-many.args b/tests/qemuxml2argvdata/qemuxml2argv-pci-many.args index 538f6fbd0e..458205540a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pci-many.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-many.args @@ -18,8 +18,8 @@ server,nowait \ -mon chardev=charmonitor,id=monitor,mode=readline \ -boot c \ -usb \ --drive file=/var/iso/f18kde.iso,format=raw,if=none,media=cdrom,\ -id=drive-ide0-1-0,readonly=on \ +-drive file=/var/iso/f18kde.iso,format=raw,if=none,id=drive-ide0-1-0,\ +media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=/var/lib/libvirt/images/test.img,format=raw,if=none,\ id=drive-virtio-disk0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args index 1719c1bc88..4c9c951cef 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases.args @@ -43,7 +43,7 @@ id=drive-ua-myEncryptedDisk1 \ -device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-ua-myEncryptedDisk1,\ id=ua-myEncryptedDisk1 \ -drive file=/home/zippy/tmp/install-amd64-minimal-20140619.iso,format=raw,\ -if=none,media=cdrom,id=drive-ua-WhatAnAwesomeCDROM,readonly=on,cache=none \ +if=none,id=drive-ua-WhatAnAwesomeCDROM,media=cdrom,readonly=on,cache=none \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ua-WhatAnAwesomeCDROM,\ id=ua-WhatAnAwesomeCDROM \ -device virtio-net-pci,vlan=0,id=ua-CheckoutThisNIC,mac=52:54:00:d6:c0:0b,\ -- 2.14.3

Move code from 3 conditional blocks into one. --- src/qemu/qemu_command.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 455cb7ae36..df3c14d627 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1653,16 +1653,12 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0) goto error; - if (emitDeviceSyntax) - virBufferAddLit(&opt, "if=none"); - else - virBufferAsprintf(&opt, "if=%s", - virDomainDiskQEMUBusTypeToString(disk->bus)); - if (emitDeviceSyntax) { char *drivealias = qemuAliasFromDisk(disk); if (!drivealias) goto error; + + virBufferAddLit(&opt, "if=none"); virBufferAsprintf(&opt, ",id=%s", drivealias); VIR_FREE(drivealias); } else { @@ -1673,11 +1669,11 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, _("unsupported disk type '%s'"), disk->dst); goto error; } + virBufferAsprintf(&opt, "if=%s", + virDomainDiskQEMUBusTypeToString(disk->bus)); virBufferAsprintf(&opt, ",index=%d", idx); - } - - if (!emitDeviceSyntax) qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); + } if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { -- 2.14.3

Isolate it from the other code. --- src/qemu/qemu_command.c | 75 +++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index df3c14d627..6ae738020d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1609,6 +1609,46 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, } +static void +qemuBuildDiskThrottling(virDomainDiskDefPtr disk, + virBufferPtr buf) +{ +#define IOTUNE_ADD(_field, _label) \ + if (disk->blkdeviotune._field) { \ + virBufferAsprintf(buf, ",throttling." _label "=%llu", \ + disk->blkdeviotune._field); \ + } + + IOTUNE_ADD(total_bytes_sec, "bps-total"); + IOTUNE_ADD(read_bytes_sec, "bps-read"); + IOTUNE_ADD(write_bytes_sec, "bps-write"); + IOTUNE_ADD(total_iops_sec, "iops-total"); + IOTUNE_ADD(read_iops_sec, "iops-read"); + IOTUNE_ADD(write_iops_sec, "iops-write"); + + IOTUNE_ADD(total_bytes_sec_max, "bps-total-max"); + IOTUNE_ADD(read_bytes_sec_max, "bps-read-max"); + IOTUNE_ADD(write_bytes_sec_max, "bps-write-max"); + IOTUNE_ADD(total_iops_sec_max, "iops-total-max"); + IOTUNE_ADD(read_iops_sec_max, "iops-read-max"); + IOTUNE_ADD(write_iops_sec_max, "iops-write-max"); + + IOTUNE_ADD(size_iops_sec, "iops-size"); + if (disk->blkdeviotune.group_name) { + virBufferEscapeString(buf, ",throttling.group=%s", + disk->blkdeviotune.group_name); + } + + IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length"); + IOTUNE_ADD(read_bytes_sec_max_length, "bps-read-max-length"); + IOTUNE_ADD(write_bytes_sec_max_length, "bps-write-max-length"); + IOTUNE_ADD(total_iops_sec_max_length, "iops-total-max-length"); + IOTUNE_ADD(read_iops_sec_max_length, "iops-read-max-length"); + IOTUNE_ADD(write_iops_sec_max_length, "iops-write-max-length"); +#undef IOTUNE_ADD +} + + static void qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, @@ -1761,40 +1801,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskIoTypeToString(disk->iomode)); } -#define IOTUNE_ADD(_field, _label) \ - if (disk->blkdeviotune._field) { \ - virBufferAsprintf(&opt, ",throttling." _label "=%llu", \ - disk->blkdeviotune._field); \ - } - - IOTUNE_ADD(total_bytes_sec, "bps-total"); - IOTUNE_ADD(read_bytes_sec, "bps-read"); - IOTUNE_ADD(write_bytes_sec, "bps-write"); - IOTUNE_ADD(total_iops_sec, "iops-total"); - IOTUNE_ADD(read_iops_sec, "iops-read"); - IOTUNE_ADD(write_iops_sec, "iops-write"); - - IOTUNE_ADD(total_bytes_sec_max, "bps-total-max"); - IOTUNE_ADD(read_bytes_sec_max, "bps-read-max"); - IOTUNE_ADD(write_bytes_sec_max, "bps-write-max"); - IOTUNE_ADD(total_iops_sec_max, "iops-total-max"); - IOTUNE_ADD(read_iops_sec_max, "iops-read-max"); - IOTUNE_ADD(write_iops_sec_max, "iops-write-max"); - - IOTUNE_ADD(size_iops_sec, "iops-size"); - if (disk->blkdeviotune.group_name) { - virBufferEscapeString(&opt, ",throttling.group=%s", - disk->blkdeviotune.group_name); - } - - IOTUNE_ADD(total_bytes_sec_max_length, "bps-total-max-length"); - IOTUNE_ADD(read_bytes_sec_max_length, "bps-read-max-length"); - IOTUNE_ADD(write_bytes_sec_max_length, "bps-write-max-length"); - IOTUNE_ADD(total_iops_sec_max_length, "iops-total-max-length"); - IOTUNE_ADD(read_iops_sec_max_length, "iops-read-max-length"); - IOTUNE_ADD(write_iops_sec_max_length, "iops-write-max-length"); - -#undef IOTUNE_ADD + qemuBuildDiskThrottling(disk, &opt); if (virBufferCheckError(&opt) < 0) goto error; -- 2.14.3

That's a disk frontend attribute. Move the code to a separate function since it's non-trivial and call it from the frontend attribute formatter. --- src/qemu/qemu_command.c | 62 +++++++++++++--------- ...uxml2argv-disk-drive-error-policy-enospace.args | 5 +- .../qemuxml2argv-disk-drive-error-policy-stop.args | 5 +- ...gv-disk-drive-error-policy-wreport-rignore.args | 5 +- 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6ae738020d..03a2e6855a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1649,6 +1649,41 @@ qemuBuildDiskThrottling(virDomainDiskDefPtr disk, } +static void +qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps, + virBufferPtr buf) +{ + const char *wpolicy = NULL; + const char *rpolicy = NULL; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) + return; + + if (disk->error_policy) + wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy); + + if (disk->rerror_policy) + rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy); + + if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) { + /* in the case of enospace, the option is spelled + * differently in qemu, and it's only valid for werror, + * not for rerror, so leave rerror NULL. + */ + wpolicy = "enospc"; + } else if (!rpolicy) { + /* for other policies, rpolicy can match wpolicy */ + rpolicy = wpolicy; + } + + if (wpolicy) + virBufferAsprintf(buf, ",werror=%s", wpolicy); + if (rpolicy) + virBufferAsprintf(buf, ",rerror=%s", rpolicy); +} + + static void qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, @@ -1673,6 +1708,8 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virBufferAddLit(buf, ",serial="); virBufferEscape(buf, '\\', " ", "%s", disk->serial); } + + qemuBuildDiskFrontendAttributeErrorPolicy(disk, qemuCaps, buf); } @@ -1771,31 +1808,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virDomainDiskDetectZeroesTypeToString(detect_zeroes)); } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MONITOR_JSON)) { - const char *wpolicy = NULL, *rpolicy = NULL; - - if (disk->error_policy) - wpolicy = virDomainDiskErrorPolicyTypeToString(disk->error_policy); - if (disk->rerror_policy) - rpolicy = virDomainDiskErrorPolicyTypeToString(disk->rerror_policy); - - if (disk->error_policy == VIR_DOMAIN_DISK_ERROR_POLICY_ENOSPACE) { - /* in the case of enospace, the option is spelled - * differently in qemu, and it's only valid for werror, - * not for rerror, so leave rerror NULL. - */ - wpolicy = "enospc"; - } else if (!rpolicy) { - /* for other policies, rpolicy can match wpolicy */ - rpolicy = wpolicy; - } - - if (wpolicy) - virBufferAsprintf(&opt, ",werror=%s", wpolicy); - if (rpolicy) - virBufferAsprintf(&opt, ",rerror=%s", rpolicy); - } - if (disk->iomode) { virBufferAsprintf(&opt, ",aio=%s", virDomainDiskIoTypeToString(disk->iomode)); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args index 704a571dd3..80422a8c88 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-enospace.args @@ -20,8 +20,9 @@ server,nowait \ -boot c \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ -cache=none,werror=enospc \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +cache=none \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ +werror=enospc \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args index 2e87d727fb..bcac9f2a8e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-stop.args @@ -20,8 +20,9 @@ server,nowait \ -boot c \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ -cache=none,werror=stop,rerror=stop \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +cache=none \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ +werror=stop,rerror=stop \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args index d3a9ec45eb..f558477230 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-error-policy-wreport-rignore.args @@ -20,8 +20,9 @@ server,nowait \ -boot c \ -usb \ -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\ -cache=none,werror=report,rerror=ignore \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +cache=none \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ +werror=report,rerror=ignore \ -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-1-0,\ media=cdrom,readonly=on \ -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -- 2.14.3

Propagate the raw bootindex and let the code decide whether to use it when formatting. --- src/qemu/qemu_command.c | 16 +++++++--------- src/qemu/qemu_command.h | 2 +- src/qemu/qemu_hotplug.c | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 03a2e6855a..89bc41e468 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1716,7 +1716,7 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, char * qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, - bool bootable, + int bootindex, virQEMUCapsPtr qemuCaps) { virBuffer opt = VIR_BUFFER_INITIALIZER; @@ -1764,12 +1764,14 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } - if (bootable && + if (bootindex && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) && (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) && disk->bus != VIR_DOMAIN_DISK_BUS_IDE) virBufferAddLit(&opt, ",boot=on"); + if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=on"); @@ -2219,7 +2221,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, for (i = 0; i < def->ndisks; i++) { char *optstr; unsigned int bootindex = 0; - bool driveBoot = false; virDomainDiskDefPtr disk = def->disks[i]; qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src); qemuDomainSecretInfoPtr secinfo = NULL; @@ -2248,10 +2249,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, bootDisk = 0; break; } - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { - driveBoot = !!bootindex; - bootindex = 0; - } } if (qemuBuildDiskSecinfoCommandLine(cmd, secinfo) < 0) @@ -2266,7 +2263,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, virCommandAddArg(cmd, "-drive"); - if (!(optstr = qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps))) + if (!(optstr = qemuBuildDriveStr(disk, cfg, bootindex, qemuCaps))) return -1; virCommandAddArg(cmd, optstr); @@ -2287,7 +2284,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, } VIR_FREE(optstr); - if (bootindex) { + if (bootindex && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) { if (virAsprintf(&optstr, "bootindex%c=%u", disk->info.addr.drive.unit ? 'B' : 'A', diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 2bcfc6c707..e60245427a 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -102,7 +102,7 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk); /* Both legacy & current support */ char *qemuBuildDriveStr(virDomainDiskDefPtr disk, virQEMUDriverConfigPtr cfg, - bool bootable, + int bootindex, virQEMUCapsPtr qemuCaps); /* Current, best practice */ diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 72a57d89ed..5c8054f72d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -409,7 +409,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn, disk->info.alias) < 0) goto error; - if (!(drivestr = qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps))) + if (!(drivestr = qemuBuildDriveStr(disk, cfg, 0, priv->qemuCaps))) goto error; if (!(drivealias = qemuAliasFromDisk(disk))) -- 2.14.3

bootable flag is a property of the frontend thus should be formatted with -device. Note: The combination of capability flags basically mandates qemu 0.12.3 - 1.0.0, which I did not test. --- src/qemu/qemu_command.c | 21 +++++++++++---------- .../qemuxml2argvdata/qemuxml2argv-boot-complex.args | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 89bc41e468..08d96ef562 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1687,6 +1687,7 @@ qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDefPtr disk, static void qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps, + int bootindex, virBufferPtr buf) { /* generate geometry command string */ @@ -1709,6 +1710,14 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk, virBufferEscape(buf, '\\', " ", "%s", disk->serial); } + if (bootindex && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) && + (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || + disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) && + disk->bus != VIR_DOMAIN_DISK_BUS_IDE) + virBufferAddLit(buf, ",boot=on"); + qemuBuildDiskFrontendAttributeErrorPolicy(disk, qemuCaps, buf); } @@ -1749,7 +1758,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, virBufferAsprintf(&opt, "if=%s", virDomainDiskQEMUBusTypeToString(disk->bus)); virBufferAsprintf(&opt, ",index=%d", idx); - qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); + qemuBuildDiskFrontendAttributes(disk, qemuCaps, bootindex, &opt); } if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { @@ -1764,14 +1773,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, } } - if (bootindex && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) && - (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || - disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) && - disk->bus != VIR_DOMAIN_DISK_BUS_IDE) - virBufferAddLit(&opt, ",boot=on"); - if (disk->src->readonly) virBufferAddLit(&opt, ",readonly=on"); @@ -2144,7 +2145,7 @@ qemuBuildDriveDevStr(const virDomainDef *def, disk->blockio.physical_block_size); } - qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt); + qemuBuildDiskFrontendAttributes(disk, qemuCaps, bootindex, &opt); if (disk->wwn) { if (STRPREFIX(disk->wwn, "0x")) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args index b7a2fc119a..78d6d2745a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args @@ -19,9 +19,9 @@ server,nowait \ -no-acpi \ -boot dnca \ -usb \ --drive file=/tmp/vda.img,format=raw,if=none,id=drive-virtio-disk0,boot=on \ +-drive file=/tmp/vda.img,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\ -id=virtio-disk0 \ +id=virtio-disk0,boot=on \ -drive file=/tmp/vdb.img,format=raw,if=none,id=drive-virtio-disk1 \ -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,\ id=virtio-disk1 \ -- 2.14.3

That is a frontend attribute but can't be moved. --- src/qemu/qemu_command.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 08d96ef562..26ad3fe1af 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1761,6 +1761,9 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, qemuBuildDiskFrontendAttributes(disk, qemuCaps, bootindex, &opt); } + /* While this is a frontend attribute, it only makes sense to be used when + * legacy -drive is used. In modern qemu the 'ide-cd' or 'scsi-cd' are used. + * virtio and other just ignore the attribute anyways */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) -- 2.14.3
participants (1)
-
Peter Krempa