[libvirt] [PATCH 00/17] qemu: Drop QEMU_CAPS_DEVICE part 2

This is the second series dropping QEMU_CAPS_DEVICE. It handles qemu_command.c and all remaining uses of QEMU_CAPS_DEVICE. Every qemu binary after v0.12.1 has the -device option, but many platforms cannot actually use it, because they are based around hardcoded machine models that cannot be extended. For these machine types, old style options work in _some_ scenarios, basically only situations where we are specifying host side config, where modern machines would use -chardev and -netdev. Those code paths are already preserved for the only scenario that's actually been tested to work (qemu-system-arm -M vexpress and some other arm pieces), so they aren't going anywhere. But all other old style command line options can be dropped AFAICT. See individual patches for descriptions. Cole Robinson (17): qemu: domain: Consistently use goto in PostParse qemu: Validate type != xen at parse time qemu: command: Drop xen disk and vga handling qemu: command: Don't unset QEMU_CAPS_DEVICE for -drive sd qemu: Drop some simple uses of QEMU_CAPS_DEVICE qemu: command: Drop QEMU_CAPS_DEVICE for device aliases qemu: command: drop QEMU_CAPS_DEVICE for PCI address assign qemu: command: drop QEMU_CAPS_DEVICE for controller cli qemu: command: drop QEMU_CAPS_DEVICE for net cli qemu: command: drop QEMU_CAPS_DEVICE for serial/parallel cli qemu: command: drop QEMU_CAPS_DEVICE for watchdog cli qemu: command: drop QEMU_CAPS_DEVICE for video cli qemu: command: Drop QEMU_CAPS_DEVICE for USB qemu: command: Drop old style -soundhw usage qemu: zap QEMU_CAPS_BALLOON qemu: zap QEMU_CAPS_PCIDEVICE qemu: zap QEMU_CAPS_DEVICE src/qemu/qemu_capabilities.c | 20 +- src/qemu/qemu_capabilities.h | 6 +- src/qemu/qemu_command.c | 1137 ++++++++------------ src/qemu/qemu_domain.c | 20 +- src/qemu/qemu_hostdev.c | 4 +- .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args | 25 - .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml | 45 - tests/qemuargv2xmltest.c | 1 - tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 2 - tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 2 - tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 2 - tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 2 - tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 - tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 2 - tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 2 - tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 2 - tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 2 - tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 2 - tests/qemuhelptest.c | 45 +- tests/qemuhotplugtest.c | 1 - .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args | 26 - tests/qemuxml2argvtest.c | 34 +- .../qemuxml2xmlout-disk-xenvbd.xml | 45 - tests/qemuxml2xmltest.c | 1 - 24 files changed, 476 insertions(+), 954 deletions(-) delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml -- 2.5.0

Isn't strictly required, but I have upcoming patches in here and it's just easier to be consistent. --- src/qemu/qemu_domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0fa2dbe..9b456e8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1248,13 +1248,13 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (def->os.bootloader || def->os.bootloaderArgs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("bootloader is not supported by QEMU")); - return ret; + goto cleanup; } /* check for emulator and create a default one if needed */ if (!def->emulator && !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) - return ret; + goto cleanup; if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) -- 2.5.0

There's a validation check at VM startup time that rejects type=xen or os type=xen|linux. The latter bit is already validated in generic domain_conf.c code, so it can be dropped. The former bit is can be done at XML parse time, so move it there. --- src/qemu/qemu_command.c | 8 -------- src/qemu/qemu_domain.c | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5d3ab3a..75fb352 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9557,14 +9557,6 @@ qemuBuildCommandLine(virConnectPtr conn, } virCommandAddArgList(cmd, "-uuid", uuid, NULL); - if (def->virtType == VIR_DOMAIN_VIRT_XEN || - def->os.type == VIR_DOMAIN_OSTYPE_XEN || - def->os.type == VIR_DOMAIN_OSTYPE_LINUX) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("qemu emulator '%s' does not support xen"), - def->emulator); - goto error; - } if ((def->os.smbios_mode != VIR_DOMAIN_SMBIOS_NONE) && (def->os.smbios_mode != VIR_DOMAIN_SMBIOS_EMULATE)) { diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9b456e8..a1dd604 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1251,6 +1251,13 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } + if (def->virtType == VIR_DOMAIN_VIRT_XEN) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu emulator '%s' does not support xen"), + def->emulator); + goto cleanup; + } + /* check for emulator and create a default one if needed */ if (!def->emulator && !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) -- 2.5.0

Yet more leftover bits from xenner days --- src/qemu/qemu_command.c | 180 +++++++++------------ src/qemu/qemu_domain.c | 9 ++ .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args | 25 --- .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml | 45 ------ tests/qemuargv2xmltest.c | 1 - .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args | 26 --- tests/qemuxml2argvtest.c | 2 +- .../qemuxml2xmlout-disk-xenvbd.xml | 45 ------ tests/qemuxml2xmltest.c | 1 - 9 files changed, 90 insertions(+), 244 deletions(-) delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 75fb352..bf6eb9f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -822,9 +822,6 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) case VIR_DOMAIN_DISK_BUS_VIRTIO: ret = virAsprintf(&dev_name, "virtio%d", devid); break; - case VIR_DOMAIN_DISK_BUS_XEN: - ret = virAsprintf(&dev_name, "xenblk%d", devid); - break; case VIR_DOMAIN_DISK_BUS_SD: ret = virAsprintf(&dev_name, "sd%d", devid); break; @@ -3811,9 +3808,8 @@ qemuBuildDriveStr(virConnectPtr conn, idx = -1; break; - case VIR_DOMAIN_DISK_BUS_XEN: case VIR_DOMAIN_DISK_BUS_SD: - /* Xen and SD have no address type currently, so assign + /* SD disks have no address type currently, so assign * based on index */ break; } @@ -7839,10 +7835,6 @@ qemuBuildObsoleteAccelArg(virCommandPtr cmd, } break; - case VIR_DOMAIN_VIRT_XEN: - /* XXX better check for xenner */ - break; - default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("the QEMU binary does not support %s"), @@ -10242,8 +10234,7 @@ qemuBuildCommandLine(virConnectPtr conn, static PCI addresses, so we don't really care that we can't use -device */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - if (disk->bus != VIR_DOMAIN_DISK_BUS_XEN && - disk->bus != VIR_DOMAIN_DISK_BUS_SD) { + if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) { withDeviceArg = true; } else { virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE); @@ -10766,96 +10757,92 @@ qemuBuildCommandLine(virConnectPtr conn, VIR_FREE(str); } } else { - if (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_XEN) { - /* nothing - vga has no effect on Xen pvfb */ - } else { - if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_QXL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("This QEMU does not support QXL graphics adapters")); - goto error; - } + if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_QXL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("This QEMU does not support QXL graphics adapters")); + goto error; + } - const char *vgastr = qemuVideoTypeToString(primaryVideoType); - if (!vgastr || STREQ(vgastr, "")) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("video type %s is not supported with QEMU"), - virDomainVideoTypeToString(primaryVideoType)); - goto error; - } + const char *vgastr = qemuVideoTypeToString(primaryVideoType); + if (!vgastr || STREQ(vgastr, "")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type %s is not supported with QEMU"), + virDomainVideoTypeToString(primaryVideoType)); + goto error; + } - virCommandAddArgList(cmd, "-vga", vgastr, NULL); + virCommandAddArgList(cmd, "-vga", vgastr, NULL); - /* If we cannot use --device option to specify the video device - * in QEMU we will fallback to the old --vga option. To get the - * correct device name for the --vga option the 'qemuVideo' is - * used, but to set some device attributes we need to use the - * --global option and for that we need to specify the device - * name the same as for --device option and for that we need to - * use 'qemuDeviceVideo'. - * - * See 'Graphics Devices' section in docs/qdev-device-use.txt in - * QEMU repository. - */ - const char *dev = qemuDeviceVideoTypeToString(primaryVideoType); - - if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL && - (def->videos[0]->vram || def->videos[0]->ram) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - unsigned int ram = def->videos[0]->ram; - unsigned int vram = def->videos[0]->vram; - unsigned int vgamem = def->videos[0]->vgamem; - - if (vram > (UINT_MAX / 1024)) { - virReportError(VIR_ERR_OVERFLOW, - _("value for 'vram' must be less than '%u'"), - UINT_MAX / 1024); - goto error; - } - if (ram > (UINT_MAX / 1024)) { - virReportError(VIR_ERR_OVERFLOW, - _("value for 'ram' must be less than '%u'"), - UINT_MAX / 1024); - goto error; - } + /* If we cannot use --device option to specify the video device + * in QEMU we will fallback to the old --vga option. To get the + * correct device name for the --vga option the 'qemuVideo' is + * used, but to set some device attributes we need to use the + * --global option and for that we need to specify the device + * name the same as for --device option and for that we need to + * use 'qemuDeviceVideo'. + * + * See 'Graphics Devices' section in docs/qdev-device-use.txt in + * QEMU repository. + */ + const char *dev = qemuDeviceVideoTypeToString(primaryVideoType); - if (ram) { - virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "%s.ram_size=%u", - dev, ram * 1024); - } - if (vram) { - virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "%s.vram_size=%u", - dev, vram * 1024); - } - if (vgamem && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) { - virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u", - dev, vgamem / 1024); - } - } + if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL && + (def->videos[0]->vram || def->videos[0]->ram) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + unsigned int ram = def->videos[0]->ram; + unsigned int vram = def->videos[0]->vram; + unsigned int vgamem = def->videos[0]->vgamem; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - def->videos[0]->vram && - ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || - (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) { - unsigned int vram = def->videos[0]->vram; - - if (vram < 1024) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("value for 'vgamem' must be at " - "least 1 MiB (1024 KiB)")); - goto error; - } + if (vram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_OVERFLOW, + _("value for 'vram' must be less than '%u'"), + UINT_MAX / 1024); + goto error; + } + if (ram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_OVERFLOW, + _("value for 'ram' must be less than '%u'"), + UINT_MAX / 1024); + goto error; + } + if (ram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "%s.ram_size=%u", + dev, ram * 1024); + } + if (vram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "%s.vram_size=%u", + dev, vram * 1024); + } + if (vgamem && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) { virCommandAddArg(cmd, "-global"); virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u", - dev, vram / 1024); + dev, vgamem / 1024); + } + } + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && + def->videos[0]->vram && + ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || + (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) { + unsigned int vram = def->videos[0]->vram; + + if (vram < 1024) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("value for 'vgamem' must be at " + "least 1 MiB (1024 KiB)")); + goto error; } + + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u", + dev, vram / 1024); } if (def->nvideos > 1) { @@ -12000,8 +11987,6 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; } else if (STREQ(values[i], "virtio")) { def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO; - } else if (STREQ(values[i], "xen")) { - def->bus = VIR_DOMAIN_DISK_BUS_XEN; } else if (STREQ(values[i], "sd")) { def->bus = VIR_DOMAIN_DISK_BUS_SD; } @@ -12165,8 +12150,6 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, ignore_value(VIR_STRDUP(def->dst, "sda")); } else if (def->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) { ignore_value(VIR_STRDUP(def->dst, "vda")); - } else if (def->bus == VIR_DOMAIN_DISK_BUS_XEN) { - ignore_value(VIR_STRDUP(def->dst, "xvda")); } else if (def->bus == VIR_DOMAIN_DISK_BUS_FDC) { ignore_value(VIR_STRDUP(def->dst, "fda")); } else { @@ -13925,10 +13908,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, virDomainVideoDefPtr vid; if (VIR_ALLOC(vid) < 0) goto error; - if (def->virtType == VIR_DOMAIN_VIRT_XEN) - vid->type = VIR_DOMAIN_VIDEO_TYPE_XEN; - else - vid->type = video; + vid->type = video; vid->vram = virDomainVideoDefaultRAM(def, vid->type); if (vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { vid->ram = virDomainVideoDefaultRAM(def, vid->type); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a1dd604..aa12f88 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1243,6 +1243,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, { virQEMUDriverPtr driver = opaque; virQEMUCapsPtr qemuCaps = NULL; + size_t i; int ret = -1; if (def->os.bootloader || def->os.bootloaderArgs) { @@ -1251,6 +1252,14 @@ qemuDomainDefPostParse(virDomainDefPtr def, goto cleanup; } + for (i = 0; i < def->ndisks; i++) { + if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_XEN) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemu does not support disk bus 'xen'")); + goto cleanup; + } + } + if (def->virtType == VIR_DOMAIN_VIRT_XEN) { virReportError(VIR_ERR_INTERNAL_ERROR, _("qemu emulator '%s' does not support xen"), diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args b/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args deleted file mode 100644 index 07fb4e4..0000000 --- a/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args +++ /dev/null @@ -1,25 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/home/test \ -USER=test \ -LOGNAME=test \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu \ --name QEMUGuest1 \ --S \ --M pc \ --m 214 \ --smp 1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --nographic \ --monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi \ --boot c \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=ide,bus=0,unit=0 \ --drive file=/dev/HostVG/QEMUGuest2,format=raw,if=ide,media=cdrom,bus=1,unit=0 \ --drive file=/tmp/data.img,format=raw,if=xen,index=0 \ --drive file=/tmp/logs.img,format=raw,if=xen,index=6 \ --net none \ --serial none \ --parallel none diff --git a/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml b/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml deleted file mode 100644 index e0bad71..0000000 --- a/tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml +++ /dev/null @@ -1,45 +0,0 @@ -<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'>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</emulator> - <disk type='block' device='disk'> - <driver name='qemu' type='raw'/> - <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='cdrom'> - <driver name='qemu' type='raw'/> - <source dev='/dev/HostVG/QEMUGuest2'/> - <target dev='hdc' bus='ide'/> - <readonly/> - <address type='drive' controller='0' bus='1' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='/tmp/data.img'/> - <target dev='xvda' bus='xen'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='/tmp/logs.img'/> - <target dev='xvdg' bus='xen'/> - </disk> - <controller type='usb' index='0'/> - <controller type='ide' index='0'/> - <controller type='pci' index='0' model='pci-root'/> - <memballoon model='none'/> - </devices> -</domain> diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index d6189c7..43f3a78 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -189,7 +189,6 @@ mymain(void) DO_TEST("disk-floppy"); DO_TEST("disk-many"); DO_TEST("disk-virtio"); - DO_TEST("disk-xenvbd"); DO_TEST("disk-drive-boot-disk"); DO_TEST("disk-drive-boot-cdrom"); DO_TEST("disk-drive-fmt-qcow"); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args deleted file mode 100644 index 8bd9dbd..0000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args +++ /dev/null @@ -1,26 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/home/test \ -USER=test \ -LOGNAME=test \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu \ --name QEMUGuest1 \ --S \ --M pc \ --m 214 \ --smp 1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --nographic \ --nodefaults \ --monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi \ --boot c \ --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 \ --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=xen,index=0 \ --drive file=/tmp/logs.img,format=raw,if=xen,index=6 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6b47d3a..d3454db 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -752,7 +752,7 @@ mymain(void) DO_TEST("disk-order", QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI, QEMU_CAPS_VIRTIO_BLK_SG_IO); - DO_TEST("disk-xenvbd", QEMU_CAPS_DRIVE_BOOT); + DO_TEST_PARSE_ERROR("disk-xenvbd", NONE); DO_TEST("disk-drive-boot-disk", QEMU_CAPS_DRIVE_BOOT); DO_TEST("disk-drive-boot-cdrom", diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml deleted file mode 100644 index e0bad71..0000000 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml +++ /dev/null @@ -1,45 +0,0 @@ -<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'>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</emulator> - <disk type='block' device='disk'> - <driver name='qemu' type='raw'/> - <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='cdrom'> - <driver name='qemu' type='raw'/> - <source dev='/dev/HostVG/QEMUGuest2'/> - <target dev='hdc' bus='ide'/> - <readonly/> - <address type='drive' controller='0' bus='1' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='/tmp/data.img'/> - <target dev='xvda' bus='xen'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='raw'/> - <source file='/tmp/logs.img'/> - <target dev='xvdg' bus='xen'/> - </disk> - <controller type='usb' index='0'/> - <controller type='ide' index='0'/> - <controller type='pci' index='0' model='pci-root'/> - <memballoon model='none'/> - </devices> -</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 6b9c153..be10b66 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -334,7 +334,6 @@ mymain(void) DO_TEST("disk-cdrom"); DO_TEST("disk-floppy"); DO_TEST("disk-many"); - DO_TEST("disk-xenvbd"); DO_TEST("disk-usb-device"); DO_TEST("disk-virtio"); DO_TEST("floppy-drive-fat"); -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
Yet more leftover bits from xenner days --- src/qemu/qemu_command.c | 180 +++++++++------------ src/qemu/qemu_domain.c | 9 ++ .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args | 25 --- .../qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml | 45 ------ tests/qemuargv2xmltest.c | 1 - .../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args | 26 --- tests/qemuxml2argvtest.c | 2 +- .../qemuxml2xmlout-disk-xenvbd.xml | 45 ------ tests/qemuxml2xmltest.c | 1 - 9 files changed, 90 insertions(+), 244 deletions(-) delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.args delete mode 100644 tests/qemuargv2xmldata/qemuargv2xml-disk-xenvbd.xml delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-xenvbd.xml
Trimmed whitespace-less diff attached - Cole

Since -device can't be used with bus=sd disks, we would unset QEMU_CAPS_DEVICE temporarily for these disks. However since QEMU_CAPS_DEVICE is going away, we don't want code to key off that anymore. Push the bus=sd check down into BuildDriveStr, and use that to hit the different code paths. --- src/qemu/qemu_command.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bf6eb9f..dade9f5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3734,6 +3734,9 @@ qemuBuildDriveStr(virConnectPtr conn, int busid = -1, unitid = -1; char *source = NULL; int actualType = virStorageSourceGetActualType(disk->src); + bool usesDeviceArg = ( + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && + (disk->bus != VIR_DOMAIN_DISK_BUS_SD)); if (idx < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3872,7 +3875,7 @@ qemuBuildDriveStr(virConnectPtr conn, } VIR_FREE(source); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) + if (usesDeviceArg) virBufferAddLit(&opt, "if=none"); else virBufferAsprintf(&opt, "if=%s", bus); @@ -3889,7 +3892,7 @@ qemuBuildDriveStr(virConnectPtr conn, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + if (usesDeviceArg) { virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias); } else { if (busid == -1 && unitid == -1) { @@ -10184,7 +10187,6 @@ qemuBuildCommandLine(virConnectPtr conn, int bootindex = 0; virDomainDiskDefPtr disk = def->disks[i]; bool withDeviceArg = false; - bool deviceFlagMasked = false; /* Unless we have -device, then USB disks need special handling */ @@ -10228,24 +10230,16 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, "-drive"); - /* Unfortunately it is not possible to use - -device for floppies, xen PV, or SD - devices. Fortunately, those don't need - static PCI addresses, so we don't really - care that we can't use -device */ + /* Unfortunately it is not possible to use -device for SD devices. + Fortunately, those don't need static PCI addresses, so we don't + really care that we can't use -device */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) { + if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) withDeviceArg = true; - } else { - virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE); - deviceFlagMasked = true; - } } optstr = qemuBuildDriveStr(conn, disk, emitBootindex ? false : !!bootindex, qemuCaps); - if (deviceFlagMasked) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); if (!optstr) goto error; virCommandAddArg(cmd, optstr); -- 2.5.0

--- src/qemu/qemu_command.c | 82 +++++++++---------------------------------------- 1 file changed, 15 insertions(+), 67 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dade9f5..594cee6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -471,12 +471,9 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, static bool qemuDomainSupportsNicdev(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED, virDomainNetDefPtr net) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - return false; - /* non-virtio ARM nics require legacy -net nic */ if (((def->os.arch == VIR_ARCH_ARMV7L) || (def->os.arch == VIR_ARCH_AARCH64)) && @@ -1185,9 +1182,6 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) } } - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - return 0; - for (i = 0; i < def->nfss; i++) { if (virAsprintf(&def->fss[i]->info.alias, "fs%zu", i) < 0) return -1; @@ -1873,7 +1867,6 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, VIR_WARN("Unable to release CCW address on %s", NULLSTR(devstr)); else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) && virDomainPCIAddressReleaseSlot(priv->pciaddrs, &info->addr.pci) < 0) VIR_WARN("Unable to release PCI address on %s", @@ -3734,9 +3727,7 @@ qemuBuildDriveStr(virConnectPtr conn, int busid = -1, unitid = -1; char *source = NULL; int actualType = virStorageSourceGetActualType(disk->src); - bool usesDeviceArg = ( - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - (disk->bus != VIR_DOMAIN_DISK_BUS_SD)); + bool usesDeviceArg = (disk->bus != VIR_DOMAIN_DISK_BUS_SD); if (idx < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -9632,22 +9623,15 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none"); } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - /* Disable global config files and default devices */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_USER_CONFIG)) - virCommandAddArg(cmd, "-no-user-config"); - else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NODEFCONFIG)) - virCommandAddArg(cmd, "-nodefconfig"); - virCommandAddArg(cmd, "-nodefaults"); - } + /* Disable global config files and default devices */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_USER_CONFIG)) + virCommandAddArg(cmd, "-no-user-config"); + else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NODEFCONFIG)) + virCommandAddArg(cmd, "-nodefconfig"); + virCommandAddArg(cmd, "-nodefaults"); /* Serial graphics adapter */ if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu does not support -device")); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu does not support SGA")); @@ -10233,10 +10217,8 @@ qemuBuildCommandLine(virConnectPtr conn, /* Unfortunately it is not possible to use -device for SD devices. Fortunately, those don't need static PCI addresses, so we don't really care that we can't use -device */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) - withDeviceArg = true; - } + if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) + withDeviceArg = true; optstr = qemuBuildDriveStr(conn, disk, emitBootindex ? false : !!bootindex, qemuCaps); @@ -10519,8 +10501,7 @@ qemuBuildCommandLine(virConnectPtr conn, char *devstr; /* Use -chardev with -device if they are available */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) { virCommandAddArg(cmd, "-chardev"); if (!(devstr = qemuBuildChrChardevStr(¶llel->source, parallel->info.alias, @@ -10547,8 +10528,7 @@ qemuBuildCommandLine(virConnectPtr conn, switch (channel->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("guestfwd requires QEMU to support -chardev & -device")); goto error; @@ -10569,12 +10549,6 @@ qemuBuildCommandLine(virConnectPtr conn, break; case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio channel requires QEMU to support -device")); - goto error; - } - /* * TODO: Refactor so that we generate this (and onther * things) somewhere else then where we are building the @@ -10622,11 +10596,6 @@ qemuBuildCommandLine(virConnectPtr conn, switch (console->targetType) { case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP: case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("sclp console requires QEMU to support -device")); - goto error; - } if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCLP_S390)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("sclp console requires QEMU to support s390-sclp")); @@ -10646,12 +10615,6 @@ qemuBuildCommandLine(virConnectPtr conn, break; case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("virtio channel requires QEMU to support -device")); - goto error; - } - virCommandAddArg(cmd, "-chardev"); if (!(devstr = qemuBuildChrChardevStr(&console->source, console->info.alias, @@ -10782,8 +10745,7 @@ qemuBuildCommandLine(virConnectPtr conn, const char *dev = qemuDeviceVideoTypeToString(primaryVideoType); if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL && - (def->videos[0]->vram || def->videos[0]->ram) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { + (def->videos[0]->vram || def->videos[0]->ram)) { unsigned int ram = def->videos[0]->ram; unsigned int vram = def->videos[0]->vram; unsigned int vgamem = def->videos[0]->vgamem; @@ -10819,8 +10781,7 @@ qemuBuildCommandLine(virConnectPtr conn, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - def->videos[0]->vram && + if (def->videos[0]->vram && ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA && @@ -10866,11 +10827,6 @@ qemuBuildCommandLine(virConnectPtr conn, } } - } else { - /* If we have -device, then we set -nodefault already */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_NONE)) - virCommandAddArgList(cmd, "-vga", "none", NULL); } /* Add sound hardware */ @@ -11009,13 +10965,6 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, devstr); VIR_FREE(devstr); - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("redirected devices are not supported by this QEMU")); - goto error; - } - - virCommandAddArg(cmd, "-device"); if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, qemuCaps))) goto error; @@ -11156,8 +11105,7 @@ qemuBuildCommandLine(virConnectPtr conn, /* SCSI */ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) { char *drvstr; virCommandAddArg(cmd, "-drive"); -- 2.5.0

--- src/qemu/qemu_command.c | 86 ++++--------------------------------------------- 1 file changed, 7 insertions(+), 79 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 594cee6..3ab53be 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -772,74 +772,16 @@ int qemuDomainNetVLAN(virDomainNetDefPtr def) char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED) { char *ret; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - ignore_value(virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX, - disk->info.alias)); - } else { - ignore_value(VIR_STRDUP(ret, disk->info.alias)); - } + ignore_value(virAsprintf(&ret, "%s%s", QEMU_DRIVE_HOST_PREFIX, + disk->info.alias)); return ret; } -/* Names used before -drive supported the id= option */ -static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) -{ - int busid, devid; - int ret; - char *dev_name; - - if (virDiskNameToBusDeviceIndex(disk, &busid, &devid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot convert disk '%s' to bus/device index"), - disk->dst); - return -1; - } - - switch (disk->bus) { - case VIR_DOMAIN_DISK_BUS_IDE: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) - ret = virAsprintf(&dev_name, "ide%d-hd%d", busid, devid); - else - ret = virAsprintf(&dev_name, "ide%d-cd%d", busid, devid); - break; - case VIR_DOMAIN_DISK_BUS_SCSI: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) - ret = virAsprintf(&dev_name, "scsi%d-hd%d", busid, devid); - else - ret = virAsprintf(&dev_name, "scsi%d-cd%d", busid, devid); - break; - case VIR_DOMAIN_DISK_BUS_FDC: - ret = virAsprintf(&dev_name, "floppy%d", devid); - break; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - ret = virAsprintf(&dev_name, "virtio%d", devid); - break; - case VIR_DOMAIN_DISK_BUS_SD: - ret = virAsprintf(&dev_name, "sd%d", devid); - break; - case VIR_DOMAIN_DISK_BUS_USB: - ret = virAsprintf(&dev_name, "usb%d", devid); - break; - default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported disk name mapping for bus '%s'"), - virDomainDiskBusTypeToString(disk->bus)); - return -1; - } - - if (ret == -1) - return -1; - - disk->info.alias = dev_name; - - return 0; -} - static int qemuSetSCSIControllerModel(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, @@ -898,11 +840,10 @@ qemuSetSCSIControllerModel(virDomainDefPtr def, return 0; } -/* Our custom -drive naming scheme used with id= */ -static int -qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def, - virDomainDiskDefPtr disk, - virQEMUCapsPtr qemuCaps) +int +qemuAssignDeviceDiskAlias(virDomainDefPtr def, + virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps) { const char *prefix = virDomainDiskBusTypeToString(disk->bus); int controllerModel = -1; @@ -941,19 +882,6 @@ qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def, return 0; } - -int -qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef, - virDomainDiskDefPtr def, - virQEMUCapsPtr qemuCaps) -{ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - return qemuAssignDeviceDiskAliasCustom(vmdef, def, qemuCaps); - else - return qemuAssignDeviceDiskAliasFixed(def); -} - - int qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx) { -- 2.5.0

All the logic was in a QEMU_CAPS_DEVICE conditional. Unindent it --- src/qemu/qemu_command.c | 238 ++++++++++++++++++++++++------------------------ 1 file changed, 117 insertions(+), 121 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3ab53be..f2e9f6a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2164,149 +2164,145 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, int ret = -1; virDomainPCIAddressSetPtr addrs = NULL; qemuDomainObjPrivatePtr priv = NULL; + int max_idx = -1; + int nbuses = 0; + size_t i; + int rv; + bool buses_reserved = true; + virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCI; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - int max_idx = -1; - int nbuses = 0; - size_t i; - int rv; - bool buses_reserved = true; + for (i = 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if ((int) def->controllers[i]->idx > max_idx) + max_idx = def->controllers[i]->idx; + } + } - virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCI; + nbuses = max_idx + 1; - for (i = 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - if ((int) def->controllers[i]->idx > max_idx) - max_idx = def->controllers[i]->idx; - } - } + if (nbuses > 0 && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) { + virDomainDeviceInfo info; - nbuses = max_idx + 1; + /* 1st pass to figure out how many PCI bridges we need */ + if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, true))) + goto cleanup; - if (nbuses > 0 && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) { - virDomainDeviceInfo info; + if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0) + goto cleanup; - /* 1st pass to figure out how many PCI bridges we need */ - if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, true))) - goto cleanup; + for (i = 0; i < addrs->nbuses; i++) { + if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i])) + buses_reserved = false; + } - if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0) - goto cleanup; + /* Reserve 1 extra slot for a (potential) bridge only if buses + * are not fully reserved yet + */ + if (!buses_reserved && + virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0) + goto cleanup; - for (i = 0; i < addrs->nbuses; i++) { - if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i])) - buses_reserved = false; - } + if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0) + goto cleanup; - /* Reserve 1 extra slot for a (potential) bridge only if buses - * are not fully reserved yet - */ - if (!buses_reserved && - virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0) - goto cleanup; + for (i = 1; i < addrs->nbuses; i++) { + virDomainPCIAddressBusPtr bus = &addrs->buses[i]; - if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0) + if ((rv = virDomainDefMaybeAddController( + def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, + i, bus->model)) < 0) + goto cleanup; + /* If we added a new bridge, we will need one more address */ + if (rv > 0 && + virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0) goto cleanup; + } + nbuses = addrs->nbuses; + virDomainPCIAddressSetFree(addrs); + addrs = NULL; - for (i = 1; i < addrs->nbuses; i++) { - virDomainPCIAddressBusPtr bus = &addrs->buses[i]; + } else if (max_idx > 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("PCI bridges are not supported " + "by this QEMU binary")); + goto cleanup; + } - if ((rv = virDomainDefMaybeAddController( - def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, - i, bus->model)) < 0) - goto cleanup; - /* If we added a new bridge, we will need one more address */ - if (rv > 0 && - virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0) - goto cleanup; - } - nbuses = addrs->nbuses; - virDomainPCIAddressSetFree(addrs); - addrs = NULL; + if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, false))) + goto cleanup; - } else if (max_idx > 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("PCI bridges are not supported " - "by this QEMU binary")); + if (qemuDomainSupportsPCI(def, qemuCaps)) { + if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0) goto cleanup; - } - if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, false))) + if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0) goto cleanup; - if (qemuDomainSupportsPCI(def, qemuCaps)) { - if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0) - goto cleanup; - - if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0) - goto cleanup; - - for (i = 0; i < def->ncontrollers; i++) { - virDomainControllerDefPtr cont = def->controllers[i]; - int idx = cont->idx; - virDevicePCIAddressPtr addr; - virDomainPCIControllerOptsPtr options; + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr cont = def->controllers[i]; + int idx = cont->idx; + virDevicePCIAddressPtr addr; + virDomainPCIControllerOptsPtr options; - if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI) - continue; + if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_PCI) + continue; - addr = &cont->info.addr.pci; - options = &cont->opts.pciopts; + addr = &cont->info.addr.pci; + options = &cont->opts.pciopts; - /* set defaults for any other auto-generated config - * options for this controller that haven't been - * specified in config. - */ - switch ((virDomainControllerModelPCI)cont->model) { - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) - options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE; - if (options->chassisNr == -1) - options->chassisNr = cont->idx; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) - options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) - options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; - if (options->chassis == -1) - options->chassis = cont->idx; - if (options->port == -1) - options->port = (addr->slot << 3) + addr->function; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: - if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) - options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: - if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) - options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM; - if (options->chassis == -1) - options->chassis = cont->idx; - if (options->port == -1) - options->port = addr->slot; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: - break; - } + /* set defaults for any other auto-generated config + * options for this controller that haven't been + * specified in config. + */ + switch ((virDomainControllerModelPCI)cont->model) { + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) + options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE; + if (options->chassisNr == -1) + options->chassisNr = cont->idx; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) + options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) + options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; + if (options->chassis == -1) + options->chassis = cont->idx; + if (options->port == -1) + options->port = (addr->slot << 3) + addr->function; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) + options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + if (options->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) + options->modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM; + if (options->chassis == -1) + options->chassis = cont->idx; + if (options->port == -1) + options->port = addr->slot; + break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + break; + } - /* check if every PCI bridge controller's ID is greater than - * the bus it is placed onto - */ - if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE && - idx <= addr->bus) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("failed to create PCI bridge " - "on bus %d: too many devices with fixed " - "addresses"), - addr->bus); - goto cleanup; - } + /* check if every PCI bridge controller's ID is greater than + * the bus it is placed onto + */ + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE && + idx <= addr->bus) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("failed to create PCI bridge " + "on bus %d: too many devices with fixed " + "addresses"), + addr->bus); + goto cleanup; } } } -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
All the logic was in a QEMU_CAPS_DEVICE conditional. Unindent it --- src/qemu/qemu_command.c | 238 ++++++++++++++++++++++++------------------------ 1 file changed, 117 insertions(+), 121 deletions(-)
Whitespace-less diff attached - Cole

All the logic was in a QEMU_CAPS_DEVICE conditional. Unindent it --- src/qemu/qemu_command.c | 112 ++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 57 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f2e9f6a..a943d69 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9986,73 +9986,71 @@ qemuBuildCommandLine(virConnectPtr conn, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - for (j = 0; j < ARRAY_CARDINALITY(contOrder); j++) { - for (i = 0; i < def->ncontrollers; i++) { - virDomainControllerDefPtr cont = def->controllers[i]; - char *devstr; + for (j = 0; j < ARRAY_CARDINALITY(contOrder); j++) { + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr cont = def->controllers[i]; + char *devstr; - if (cont->type != contOrder[j]) - continue; + if (cont->type != contOrder[j]) + continue; - /* skip USB controllers with type none.*/ - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { - usbcontroller = -1; /* mark we don't want a controller */ + /* skip USB controllers with type none.*/ + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { + usbcontroller = -1; /* mark we don't want a controller */ + continue; + } + + /* skip pci-root/pcie-root */ + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && + (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT || + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) + continue; + + /* first SATA controller on Q35 machines is implicit */ + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA && + cont->idx == 0 && qemuDomainMachineIsQ35(def)) continue; - } - /* skip pci-root/pcie-root */ - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && - (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT || - cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) + /* first IDE controller is implicit on various machines */ + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE && + cont->idx == 0 && qemuDomainMachineHasBuiltinIDE(def)) continue; - /* first SATA controller on Q35 machines is implicit */ - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA && - cont->idx == 0 && qemuDomainMachineIsQ35(def)) - continue; - - /* first IDE controller is implicit on various machines */ - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE && - cont->idx == 0 && qemuDomainMachineHasBuiltinIDE(def)) - continue; - - if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model == -1 && - !qemuDomainMachineIsQ35(def)) { - bool need_legacy = false; - - /* We're not using legacy usb controller for q35 */ - if (ARCH_IS_PPC64(def->os.arch)) { - /* For ppc64 the legacy was OHCI */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) - need_legacy = true; - } else { - /* For anything else, we used PIIX3_USB_UHCI */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) - need_legacy = true; - } + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && + cont->model == -1 && + !qemuDomainMachineIsQ35(def)) { + bool need_legacy = false; - if (need_legacy) { - if (usblegacy) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Multiple legacy USB controllers are " - "not supported")); - goto error; - } - usblegacy = true; - continue; - } + /* We're not using legacy usb controller for q35 */ + if (ARCH_IS_PPC64(def->os.arch)) { + /* For ppc64 the legacy was OHCI */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) + need_legacy = true; + } else { + /* For anything else, we used PIIX3_USB_UHCI */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) + need_legacy = true; } - virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildControllerDevStr(def, cont, qemuCaps, - &usbcontroller))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); + if (need_legacy) { + if (usblegacy) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Multiple legacy USB controllers are " + "not supported")); + goto error; + } + usblegacy = true; + continue; + } } + + virCommandAddArg(cmd, "-device"); + if (!(devstr = qemuBuildControllerDevStr(def, cont, qemuCaps, + &usbcontroller))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); } } -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
All the logic was in a QEMU_CAPS_DEVICE conditional. Unindent it --- src/qemu/qemu_command.c | 112 ++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 57 deletions(-)
Whitespace-less diff attached - Cole

-net none is never required anymore, even platforms that can't use -device abide -nodefaults. Additionally we conditionalized the cli building on nnets != 0, but that was redundant. --- src/qemu/qemu_command.c | 72 +++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a943d69..55c869e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9276,6 +9276,7 @@ qemuBuildCommandLine(virConnectPtr conn, virBuffer fdc_opts = VIR_BUFFER_INITIALIZER; char *fdc_opts_str = NULL; int bootCD = 0, bootFloppy = 0, bootDisk = 0, bootHostdevNet = 0; + int bootNet = 0; VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d " @@ -10228,53 +10229,46 @@ qemuBuildCommandLine(virConnectPtr conn, } } - if (!def->nnets) { - /* If we have -device, then we set -nodefault already */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - virCommandAddArgList(cmd, "-net", "none", NULL); - } else { - int bootNet = 0; - if (emitBootindex) { - /* convert <boot dev='network'/> to bootindex since we didn't emit - * -boot n - */ - for (i = 0; i < def->os.nBootDevs; i++) { - if (def->os.bootDevs[i] == VIR_DOMAIN_BOOT_NET) { - bootNet = i + 1; - break; - } + if (emitBootindex) { + /* convert <boot dev='network'/> to bootindex since we didn't emit + * -boot n + */ + for (i = 0; i < def->os.nBootDevs; i++) { + if (def->os.bootDevs[i] == VIR_DOMAIN_BOOT_NET) { + bootNet = i + 1; + break; } } + } - for (i = 0; i < def->nnets; i++) { - virDomainNetDefPtr net = def->nets[i]; - int vlan; + for (i = 0; i < def->nnets; i++) { + virDomainNetDefPtr net = def->nets[i]; + int vlan; - /* VLANs are not used with -netdev, so don't record them */ - if (qemuDomainSupportsNetdev(def, qemuCaps, net)) - vlan = -1; - else - vlan = i; + /* VLANs are not used with -netdev, so don't record them */ + if (qemuDomainSupportsNetdev(def, qemuCaps, net)) + vlan = -1; + else + vlan = i; - if (qemuBuildInterfaceCommandLine(cmd, driver, def, net, - qemuCaps, vlan, bootNet, vmop, - standalone, nnicindexes, nicindexes) < 0) - goto error; + if (qemuBuildInterfaceCommandLine(cmd, driver, def, net, + qemuCaps, vlan, bootNet, vmop, + standalone, nnicindexes, nicindexes) < 0) + goto error; - last_good_net = i; - /* if this interface is a type='hostdev' interface and we - * haven't yet added a "bootindex" parameter to an - * emulated network device, save the bootindex - hostdev - * interface commandlines will be built later on when we - * cycle through all the hostdevs, and we'll use it then. - */ - if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV && - bootHostdevNet == 0) { - bootHostdevNet = bootNet; - } - bootNet = 0; + last_good_net = i; + /* if this interface is a type='hostdev' interface and we + * haven't yet added a "bootindex" parameter to an + * emulated network device, save the bootindex - hostdev + * interface commandlines will be built later on when we + * cycle through all the hostdevs, and we'll use it then. + */ + if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV && + bootHostdevNet == 0) { + bootHostdevNet = bootNet; } + bootNet = 0; } if (def->nsmartcards) { -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
-net none is never required anymore, even platforms that can't use -device abide -nodefaults.
Additionally we conditionalized the cli building on nnets != 0, but that was redundant.
Whitespace-less diff attached - Cole

-serial none and -parallel none are never required anymore, even platforms that can't use -device abide -nodefaults. Additionally we conditionalized the cli building on nparallels != 0, but that was pointless. --- src/qemu/qemu_command.c | 50 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 55c869e..e3c6a51 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10403,38 +10403,28 @@ qemuBuildCommandLine(virConnectPtr conn, actualSerials++; } - /* If we have -device, then we set -nodefault already */ - if (!actualSerials && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - virCommandAddArgList(cmd, "-serial", "none", NULL); - - if (!def->nparallels) { - /* If we have -device, then we set -nodefault already */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) - virCommandAddArgList(cmd, "-parallel", "none", NULL); - } else { - for (i = 0; i < def->nparallels; i++) { - virDomainChrDefPtr parallel = def->parallels[i]; - char *devstr; + for (i = 0; i < def->nparallels; i++) { + virDomainChrDefPtr parallel = def->parallels[i]; + char *devstr; - /* Use -chardev with -device if they are available */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) { - virCommandAddArg(cmd, "-chardev"); - if (!(devstr = qemuBuildChrChardevStr(¶llel->source, - parallel->info.alias, - qemuCaps))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); + /* Use -chardev with -device if they are available */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) { + virCommandAddArg(cmd, "-chardev"); + if (!(devstr = qemuBuildChrChardevStr(¶llel->source, + parallel->info.alias, + qemuCaps))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); - if (qemuBuildChrDeviceCommandLine(cmd, def, parallel, qemuCaps) < 0) - goto error; - } else { - virCommandAddArg(cmd, "-parallel"); - if (!(devstr = qemuBuildChrArgStr(¶llel->source, NULL))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - } + if (qemuBuildChrDeviceCommandLine(cmd, def, parallel, qemuCaps) < 0) + goto error; + } else { + virCommandAddArg(cmd, "-parallel"); + if (!(devstr = qemuBuildChrArgStr(¶llel->source, NULL))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); } } -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
-serial none and -parallel none are never required anymore, even platforms that can't use -device abide -nodefaults.
Additionally we conditionalized the cli building on nparallels != 0, but that was pointless.
Whitespace-less diff attached - Cole

The -watchdog path will never be triggered. --- src/qemu/qemu_command.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e3c6a51..516f351 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10822,25 +10822,11 @@ qemuBuildCommandLine(virConnectPtr conn, virDomainWatchdogDefPtr watchdog = def->watchdog; char *optstr; - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virCommandAddArg(cmd, "-device"); - - optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps); - if (!optstr) - goto error; - } else { - virCommandAddArg(cmd, "-watchdog"); - - const char *model = virDomainWatchdogModelTypeToString(watchdog->model); - if (!model) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing watchdog model")); - goto error; - } + virCommandAddArg(cmd, "-device"); - if (VIR_STRDUP(optstr, model) < 0) - goto error; - } + optstr = qemuBuildWatchdogDevStr(def, watchdog, qemuCaps); + if (!optstr) + goto error; virCommandAddArg(cmd, optstr); VIR_FREE(optstr); -- 2.5.0

The whole block was also conditionalized on nvideos >= 1, which the loop will handle fine after the QEMU_CAPS_DEVICE check is dropped. --- src/qemu/qemu_command.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 516f351..d48f173 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10706,33 +10706,24 @@ qemuBuildCommandLine(virConnectPtr conn, dev, vram / 1024); } - if (def->nvideos > 1) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - for (i = 1; i < def->nvideos; i++) { - char *str; - if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("video type %s is only valid as primary video card"), - virDomainVideoTypeToString(def->videos[0]->type)); - goto error; - } - - virCommandAddArg(cmd, "-device"); - - if (!(str = qemuBuildDeviceVideoStr(def, def->videos[i], qemuCaps, false))) - goto error; - - virCommandAddArg(cmd, str); - VIR_FREE(str); - } - } else { + for (i = 1; i < def->nvideos; i++) { + char *str; + if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("only one video card is currently supported")); + _("video type %s is only valid as primary video card"), + virDomainVideoTypeToString(def->videos[0]->type)); goto error; } + + virCommandAddArg(cmd, "-device"); + + if (!(str = qemuBuildDeviceVideoStr(def, def->videos[i], qemuCaps, false))) + goto error; + + virCommandAddArg(cmd, str); + VIR_FREE(str); } } - } /* Add sound hardware */ -- 2.5.0

Even platforms that don't handle -device well can still use -device for USB, they will just have a hardcoded USB bus. May still need extra libvirt changes to make that work, but that's applies to the current code too. --- src/qemu/qemu_command.c | 60 +++++++++---------------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d48f173..278f4f6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10095,22 +10095,6 @@ qemuBuildCommandLine(virConnectPtr conn, virDomainDiskDefPtr disk = def->disks[i]; bool withDeviceArg = false; - /* Unless we have -device, then USB disks need special - handling */ - if ((disk->bus == VIR_DOMAIN_DISK_BUS_USB) && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - virCommandAddArg(cmd, "-usbdevice"); - virCommandAddArgFormat(cmd, "disk:%s", disk->src->path); - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported usb disk type for '%s'"), - disk->src->path); - goto error; - } - continue; - } - /* PowerPC pseries based VMs do not support floppy device */ if ((disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) && ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) { @@ -10553,26 +10537,12 @@ qemuBuildCommandLine(virConnectPtr conn, virDomainInputDefPtr input = def->inputs[i]; if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - char *optstr; - virCommandAddArg(cmd, "-device"); - if (!(optstr = qemuBuildUSBInputDevStr(def, input, qemuCaps))) - goto error; - virCommandAddArg(cmd, optstr); - VIR_FREE(optstr); - } else { - switch (input->type) { - case VIR_DOMAIN_INPUT_TYPE_MOUSE: - virCommandAddArgList(cmd, "-usbdevice", "mouse", NULL); - break; - case VIR_DOMAIN_INPUT_TYPE_TABLET: - virCommandAddArgList(cmd, "-usbdevice", "tablet", NULL); - break; - case VIR_DOMAIN_INPUT_TYPE_KBD: - virCommandAddArgList(cmd, "-usbdevice", "keyboard", NULL); - break; - } - } + char *optstr; + virCommandAddArg(cmd, "-device"); + if (!(optstr = qemuBuildUSBInputDevStr(def, input, qemuCaps))) + goto error; + virCommandAddArg(cmd, optstr); + VIR_FREE(optstr); } else if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) { char *optstr; virCommandAddArg(cmd, "-device"); @@ -10909,19 +10879,11 @@ qemuBuildCommandLine(virConnectPtr conn, if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - virCommandAddArg(cmd, "-device"); - if (!(devstr = qemuBuildUSBHostdevDevStr(def, hostdev, qemuCaps))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - } else { - virCommandAddArg(cmd, "-usbdevice"); - if (!(devstr = qemuBuildUSBHostdevUSBDevStr(hostdev))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - } + virCommandAddArg(cmd, "-device"); + if (!(devstr = qemuBuildUSBHostdevDevStr(def, hostdev, qemuCaps))) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); } /* PCI */ -- 2.5.0

Even platforms that don't handle -device well cannot use this... they either have sound hardware baked in, or none at all. So this can be safely dropped. I changed the code a bit short circuit the loop for the pcspk case, which allows us to unindent the main logic some more --- src/qemu/qemu_command.c | 104 ++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 69 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 278f4f6..733d498 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10697,84 +10697,50 @@ qemuBuildCommandLine(virConnectPtr conn, } /* Add sound hardware */ - if (def->nsounds) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - for (i = 0; i < def->nsounds; i++) { - virDomainSoundDefPtr sound = def->sounds[i]; - char *str = NULL; - - /* Sadly pcspk device doesn't use -device syntax. Fortunately - * we don't need to set any PCI address on it, so we don't - * mind too much */ - if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) { - virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL); - } else { - virCommandAddArg(cmd, "-device"); - if (!(str = qemuBuildSoundDevStr(def, sound, qemuCaps))) - goto error; + for (i = 0; i < def->nsounds; i++) { + virDomainSoundDefPtr sound = def->sounds[i]; + char *str = NULL; + + /* Sadly pcspk device doesn't use -device syntax. Fortunately + * we don't need to set any PCI address on it, so we don't + * mind too much */ + if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) { + virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL); + continue; + } - virCommandAddArg(cmd, str); - VIR_FREE(str); - if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 || - sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) { - char *codecstr = NULL; + virCommandAddArg(cmd, "-device"); + if (!(str = qemuBuildSoundDevStr(def, sound, qemuCaps))) + goto error; - for (j = 0; j < sound->ncodecs; j++) { - virCommandAddArg(cmd, "-device"); - if (!(codecstr = qemuBuildSoundCodecStr(sound, sound->codecs[j], qemuCaps))) { - goto error; + virCommandAddArg(cmd, str); + VIR_FREE(str); + if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 || + sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) { + char *codecstr = NULL; - } - virCommandAddArg(cmd, codecstr); - VIR_FREE(codecstr); - } - if (j == 0) { - virDomainSoundCodecDef codec = { - VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX, - 0 - }; - virCommandAddArg(cmd, "-device"); - if (!(codecstr = qemuBuildSoundCodecStr(sound, &codec, qemuCaps))) { - goto error; + for (j = 0; j < sound->ncodecs; j++) { + virCommandAddArg(cmd, "-device"); + if (!(codecstr = qemuBuildSoundCodecStr(sound, sound->codecs[j], qemuCaps))) { + goto error; - } - virCommandAddArg(cmd, codecstr); - VIR_FREE(codecstr); - } - } } - } - } else { - int size = 100; - char *modstr; - if (VIR_ALLOC_N(modstr, size+1) < 0) - goto error; - - for (i = 0; i < def->nsounds && size > 0; i++) { - virDomainSoundDefPtr sound = def->sounds[i]; - const char *model = virDomainSoundModelTypeToString(sound->model); - if (!model) { - VIR_FREE(modstr); - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid sound model")); + virCommandAddArg(cmd, codecstr); + VIR_FREE(codecstr); + } + if (j == 0) { + virDomainSoundCodecDef codec = { + VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX, + 0 + }; + virCommandAddArg(cmd, "-device"); + if (!(codecstr = qemuBuildSoundCodecStr(sound, &codec, qemuCaps))) { goto error; - } - if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 || - sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) { - VIR_FREE(modstr); - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("this QEMU binary lacks hda support")); - goto error; } - - strncat(modstr, model, size); - size -= strlen(model); - if (i < (def->nsounds - 1)) - strncat(modstr, ",", size--); + virCommandAddArg(cmd, codecstr); + VIR_FREE(codecstr); } - virCommandAddArgList(cmd, "-soundhw", modstr, NULL); - VIR_FREE(modstr); } } -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
Even platforms that don't handle -device well cannot use this... they either have sound hardware baked in, or none at all. So this can be safely dropped.
I changed the code a bit short circuit the loop for the pcspk case, which allows us to unindent the main logic some more --- src/qemu/qemu_command.c | 104 ++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 69 deletions(-)
Whitespace-less diff attached - Cole

It's only usage is in a !QEMU_CAPS_DEVICE code path. Remove that code, and blacklist it --- src/qemu/qemu_capabilities.c | 3 --- src/qemu/qemu_capabilities.h | 2 +- src/qemu/qemu_command.c | 20 +++++++++----------- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 - tests/qemuhelptest.c | 8 -------- 14 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 3099e34..8c29165 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1156,8 +1156,6 @@ virQEMUCapsComputeCmdFlags(const char *help, if (strstr(help, "-chardev spiceport")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT); } - if (strstr(help, "-balloon")) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON); if (strstr(help, "-device")) { virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); /* @@ -3217,7 +3215,6 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV); virQEMUCapsSet(qemuCaps, QEMU_CAPS_MONITOR_JSON); - virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON); virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL); virQEMUCapsSet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e5353de..bca4ef4 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -81,7 +81,7 @@ typedef enum { QEMU_CAPS_MONITOR_JSON, /* JSON mode for monitor */ /* 25 */ - QEMU_CAPS_BALLOON, /* -balloon available */ + X_QEMU_CAPS_BALLOON, /* -balloon available */ QEMU_CAPS_DEVICE, /* Is the new -device arg available */ QEMU_CAPS_SDL, /* Is the new -sdl arg available */ QEMU_CAPS_SMP_TOPOLOGY, /* -smp has sockets/cores/threads */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 733d498..4007621 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10953,24 +10953,22 @@ qemuBuildCommandLine(virConnectPtr conn, if (def->memballoon && def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_NONE) { + char *optstr; + if (def->memballoon->model != VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Memory balloon device type '%s' is not supported by this version of qemu"), virDomainMemballoonModelTypeToString(def->memballoon->model)); goto error; } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - char *optstr; - virCommandAddArg(cmd, "-device"); - optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps); - if (!optstr) - goto error; - virCommandAddArg(cmd, optstr); - VIR_FREE(optstr); - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BALLOON)) { - virCommandAddArgList(cmd, "-balloon", "virtio", NULL); - } + virCommandAddArg(cmd, "-device"); + + optstr = qemuBuildMemballoonDevStr(def, def->memballoon, qemuCaps); + if (!optstr) + goto error; + virCommandAddArg(cmd, optstr); + VIR_FREE(optstr); } for (i = 0; i < def->nrngs; i++) { diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps index 34ddd80..af93904 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps index cb8eac9..87d9a89 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps index 86982f1..ae7f4a8 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 5401d65..0db8a48 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 63536a7..23e6920 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index 6717a94..db56973 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps index 332b85a..c98a7a5 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps index e411542..a8e9c16 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps index 931bc4f..15f56a3 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps index f32d5aa..9d5c15c 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='balloon'/> <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 35fc9c7..26455d5 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -157,7 +157,6 @@ mymain(void) QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_RTC, @@ -183,7 +182,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, @@ -231,7 +229,6 @@ mymain(void) QEMU_CAPS_MEM_PATH, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_RTC, @@ -263,7 +260,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, @@ -321,7 +317,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, @@ -376,7 +371,6 @@ mymain(void) QEMU_CAPS_MEM_PATH, QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, - QEMU_CAPS_BALLOON, QEMU_CAPS_MONITOR_JSON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, @@ -440,7 +434,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, @@ -519,7 +512,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_BALLOON, QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, -- 2.5.0

All code paths that use it are !QEMU_CAPS_DEVICE code paths, so they will never be hit. This means we can drop it entirely. --- src/qemu/qemu_capabilities.c | 6 +--- src/qemu/qemu_capabilities.h | 2 +- src/qemu/qemu_command.c | 70 ++++++++++++++++++-------------------------- src/qemu/qemu_hostdev.c | 4 +-- tests/qemuhelptest.c | 5 ---- tests/qemuxml2argvtest.c | 31 +++++++++----------- 6 files changed, 46 insertions(+), 72 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8c29165..b5ed30c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1143,8 +1143,6 @@ virQEMUCapsComputeCmdFlags(const char *help, virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_BOOT); if (strstr(help, "serial=s")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); - if (strstr(help, "-pcidevice")) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCIDEVICE); if (strstr(help, "host=[seg:]bus")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); if (strstr(help, "-mem-path")) @@ -4016,9 +4014,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO); } - if (supportsPassthroughKVM && - (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) { + if (supportsPassthroughKVM) { VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index bca4ef4..6ea8a78 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -69,7 +69,7 @@ typedef enum { /* 15 */ X_QEMU_CAPS_VGA, /* Is -vga avail */ X_QEMU_CAPS_0_10, /* features added in qemu-0.10.0 or later */ - QEMU_CAPS_PCIDEVICE, /* PCI device assignment supported */ + X_QEMU_CAPS_PCIDEVICE, /* -pcidevice supported */ QEMU_CAPS_MEM_PATH, /* mmap'ped guest backing supported */ QEMU_CAPS_DRIVE_SERIAL, /* -driver serial= available */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 4007621..1258ad4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10866,51 +10866,39 @@ qemuBuildCommandLine(virConnectPtr conn, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { - char *configfd_name = NULL; - int bootIndex = hostdev->info->bootIndex; + char *configfd_name = NULL; + int bootIndex = hostdev->info->bootIndex; - /* bootNet will be non-0 if boot order was set and no other - * net devices were encountered - */ - if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET && - bootIndex == 0) { - bootIndex = bootHostdevNet; - bootHostdevNet = 0; - } - if ((backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) { - int configfd = qemuOpenPCIConfig(hostdev); - - if (configfd >= 0) { - if (virAsprintf(&configfd_name, "%d", configfd) < 0) { - VIR_FORCE_CLOSE(configfd); - goto error; - } - - virCommandPassFD(cmd, configfd, - VIR_COMMAND_PASS_FD_CLOSE_PARENT); + /* bootNet will be non-0 if boot order was set and no other + * net devices were encountered + */ + if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET && + bootIndex == 0) { + bootIndex = bootHostdevNet; + bootHostdevNet = 0; + } + if ((backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_CONFIGFD)) { + int configfd = qemuOpenPCIConfig(hostdev); + + if (configfd >= 0) { + if (virAsprintf(&configfd_name, "%d", configfd) < 0) { + VIR_FORCE_CLOSE(configfd); + goto error; } + + virCommandPassFD(cmd, configfd, + VIR_COMMAND_PASS_FD_CLOSE_PARENT); } - virCommandAddArg(cmd, "-device"); - devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, - configfd_name, qemuCaps); - VIR_FREE(configfd_name); - if (!devstr) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE)) { - virCommandAddArg(cmd, "-pcidevice"); - if (!(devstr = qemuBuildPCIHostdevPCIDevStr(hostdev, qemuCaps))) - goto error; - virCommandAddArg(cmd, devstr); - VIR_FREE(devstr); - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("PCI device assignment is not supported by this version of qemu")); - goto error; } + virCommandAddArg(cmd, "-device"); + devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, + configfd_name, qemuCaps); + VIR_FREE(configfd_name); + if (!devstr) + goto error; + virCommandAddArg(cmd, devstr); + VIR_FREE(devstr); } /* SCSI */ diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index ca38a06..e16d5fd 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -197,9 +197,7 @@ qemuHostdevPreparePCIDevicesCheckSupport(virDomainHostdevDefPtr *hostdevs, if (supportsPassthroughVFIO && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) { *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO; - } else if (supportsPassthroughKVM && - (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCIDEVICE) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))) { + } else if (supportsPassthroughKVM) { *backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 26455d5..73b813e 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -177,7 +177,6 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_DRIVE_READONLY, - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_MEM_PATH, QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, @@ -225,7 +224,6 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_DRIVE_READONLY, - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_MEM_PATH, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, @@ -254,7 +252,6 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_DRIVE_READONLY, - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_MEM_PATH, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, @@ -312,7 +309,6 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_DRIVE_READONLY, - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_MEM_PATH, QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, @@ -367,7 +363,6 @@ mymain(void) QEMU_CAPS_KVM, QEMU_CAPS_DRIVE_SERIAL, QEMU_CAPS_DRIVE_READONLY, - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_MEM_PATH, QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d3454db..1c73e3f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -676,7 +676,7 @@ mymain(void) DO_TEST("cpu-eoi-disabled", QEMU_CAPS_ENABLE_KVM); DO_TEST("cpu-eoi-enabled", QEMU_CAPS_ENABLE_KVM); - DO_TEST("controller-order", QEMU_CAPS_PCIDEVICE, + DO_TEST("controller-order", QEMU_CAPS_KVM, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_BOOT_MENU, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DRIVE_AIO, @@ -990,21 +990,19 @@ mymain(void) DO_TEST("net-mcast", NONE); DO_TEST("net-udp", NONE); DO_TEST("net-hostdev", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG); + QEMU_CAPS_NODEFCONFIG); DO_TEST("net-hostdev-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); DO_TEST_FAILURE("net-hostdev-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG); DO_TEST("net-hostdev-vfio", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("net-hostdev-vfio-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); DO_TEST_FAILURE("net-hostdev-vfio-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("serial-vc", NONE); @@ -1231,20 +1229,19 @@ mymain(void) DO_TEST("hostdev-usb-address-device-boot", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_USB_HOST_BOOTINDEX); - DO_TEST("hostdev-pci-address", QEMU_CAPS_PCIDEVICE); + DO_TEST("hostdev-pci-address", NONE); DO_TEST("hostdev-pci-address-device", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG); + QEMU_CAPS_NODEFCONFIG); DO_TEST("hostdev-vfio", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_HOST_PCI_MULTIDOMAIN); DO_TEST_FAILURE("hostdev-vfio-multidomain", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("pci-rom", - QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, + QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_ROMBAR); DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, NONE); @@ -1693,14 +1690,14 @@ mymain(void) DO_TEST("fips-enabled", QEMU_CAPS_ENABLE_FIPS); - DO_TEST("shmem", QEMU_CAPS_PCIDEVICE, + DO_TEST("shmem", QEMU_CAPS_DEVICE_IVSHMEM); DO_TEST_FAILURE("shmem", NONE); - DO_TEST_FAILURE("shmem-invalid-size", QEMU_CAPS_PCIDEVICE, + DO_TEST_FAILURE("shmem-invalid-size", QEMU_CAPS_DEVICE_IVSHMEM); - DO_TEST_FAILURE("shmem-invalid-address", QEMU_CAPS_PCIDEVICE, + DO_TEST_FAILURE("shmem-invalid-address", QEMU_CAPS_DEVICE_IVSHMEM); - DO_TEST_FAILURE("shmem-small-size", QEMU_CAPS_PCIDEVICE, + DO_TEST_FAILURE("shmem-small-size", QEMU_CAPS_DEVICE_IVSHMEM); DO_TEST_PARSE_ERROR("shmem-msi-only", NONE); DO_TEST("cpu-host-passthrough-features", QEMU_CAPS_KVM, QEMU_CAPS_CPU_HOST); -- 2.5.0

Remove the last remnants and blacklist it --- src/qemu/qemu_capabilities.c | 11 +++------ src/qemu/qemu_capabilities.h | 2 +- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.5.0-1.caps | 1 - tests/qemucapabilitiesdata/caps_2.6.0-1.caps | 1 - tests/qemuhelptest.c | 32 +++++++++------------------ tests/qemuhotplugtest.c | 1 - tests/qemuxml2argvtest.c | 1 - 15 files changed, 15 insertions(+), 42 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b5ed30c..a4e74bc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1155,7 +1155,6 @@ virQEMUCapsComputeCmdFlags(const char *help, virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT); } if (strstr(help, "-device")) { - virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); /* * When -device was introduced, qemu already supported drive's * readonly option but didn't advertise that. @@ -3170,8 +3169,7 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu * understands the 0.13.0+ notion of "-device driver,". */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - strstr(help, "-device driver,?") && + if (strstr(help, "-device driver,?") && virQEMUCapsExtractDeviceStr(qemuCaps->binary, qemuCaps, runUid, runGid) < 0) { goto cleanup; @@ -3213,7 +3211,6 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps) virQEMUCapsSet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL); virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV); virQEMUCapsSet(qemuCaps, QEMU_CAPS_MONITOR_JSON); - virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE); virQEMUCapsSet(qemuCaps, QEMU_CAPS_SDL); virQEMUCapsSet(qemuCaps, QEMU_CAPS_SMP_TOPOLOGY); virQEMUCapsSet(qemuCaps, QEMU_CAPS_NETDEV); @@ -3827,8 +3824,7 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def, virQEMUCapsPtr qemuCaps, virDomainChrDefPtr chr) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) return false; if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) { @@ -3998,8 +3994,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI); diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6ea8a78..86c38d0 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -82,7 +82,7 @@ typedef enum { /* 25 */ X_QEMU_CAPS_BALLOON, /* -balloon available */ - QEMU_CAPS_DEVICE, /* Is the new -device arg available */ + X_QEMU_CAPS_DEVICE, /* -device available */ QEMU_CAPS_SDL, /* Is the new -sdl arg available */ QEMU_CAPS_SMP_TOPOLOGY, /* -smp has sockets/cores/threads */ QEMU_CAPS_NETDEV, /* -netdev flag & netdev_add/remove */ diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps index af93904..8ea30a9 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps index 87d9a89..682ba0f 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps index ae7f4a8..f9deeeb 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 0db8a48..85434b8 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 23e6920..7c88d1e 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index db56973..a37a7cf 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps index c98a7a5..f1ad74a 100644 --- a/tests/qemucapabilitiesdata/caps_2.1.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.1.1-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps index a8e9c16..53b24b7 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps index 15f56a3..fc41317 100644 --- a/tests/qemucapabilitiesdata/caps_2.5.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.5.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps index 9d5c15c..e2fe62b 100644 --- a/tests/qemucapabilitiesdata/caps_2.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.6.0-1.caps @@ -4,7 +4,6 @@ <flag name='chardev'/> <flag name='enable-kvm'/> <flag name='monitor-json'/> - <flag name='device'/> <flag name='sdl'/> <flag name='smp-topology'/> <flag name='netdev'/> diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 73b813e..fb3f2b5 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -70,19 +70,17 @@ static int testHelpStrParsing(const void *data) virQEMUCapsSet(flags, QEMU_CAPS_MONITOR_JSON); # endif - if (virQEMUCapsGet(info->flags, QEMU_CAPS_DEVICE)) { - VIR_FREE(path); - VIR_FREE(help); - if (virAsprintf(&path, "%s/qemuhelpdata/%s-device", abs_srcdir, - info->name) < 0) - goto cleanup; - - if (virtTestLoadFile(path, &help) < 0) - goto cleanup; - - if (virQEMUCapsParseDeviceStr(flags, help) < 0) - goto cleanup; - } + VIR_FREE(path); + VIR_FREE(help); + if (virAsprintf(&path, "%s/qemuhelpdata/%s-device", abs_srcdir, + info->name) < 0) + goto cleanup; + + if (virtTestLoadFile(path, &help) < 0) + goto cleanup; + + if (virQEMUCapsParseDeviceStr(flags, help) < 0) + goto cleanup; got = virQEMUCapsFlagsString(flags); expected = virQEMUCapsFlagsString(info->flags); @@ -157,7 +155,6 @@ mymain(void) QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_RTC, QEMU_CAPS_NO_HPET, @@ -181,7 +178,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, @@ -227,7 +223,6 @@ mymain(void) QEMU_CAPS_MEM_PATH, QEMU_CAPS_SDL, QEMU_CAPS_CHARDEV, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_RTC, QEMU_CAPS_VHOST_NET, @@ -257,7 +252,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, @@ -313,7 +307,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, @@ -367,7 +360,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, @@ -429,7 +421,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, @@ -507,7 +498,6 @@ mymain(void) QEMU_CAPS_CHARDEV, QEMU_CAPS_ENABLE_KVM, QEMU_CAPS_MONITOR_JSON, - QEMU_CAPS_DEVICE, QEMU_CAPS_SMP_TOPOLOGY, QEMU_CAPS_NETDEV, QEMU_CAPS_RTC, diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 102e052..3c1d1ec 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -71,7 +71,6 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, goto cleanup; /* for attach & detach qemu must support -device */ - virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE); if (event) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1c73e3f..0949c63 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -293,7 +293,6 @@ static int testCompareXMLToArgvFiles(const char *xml, virQEMUCapsSetList(extraFlags, QEMU_CAPS_NO_ACPI, - QEMU_CAPS_DEVICE, QEMU_CAPS_LAST); if (STREQ(vmdef->os.machine, "pc") && -- 2.5.0

On 01/22/2016 02:30 PM, Cole Robinson wrote:
This is the second series dropping QEMU_CAPS_DEVICE. It handles qemu_command.c and all remaining uses of QEMU_CAPS_DEVICE.
Every qemu binary after v0.12.1 has the -device option, but many platforms cannot actually use it, because they are based around hardcoded machine models that cannot be extended. For these machine types, old style options work in _some_ scenarios, basically only situations where we are specifying host side config, where modern machines would use -chardev and -netdev.
Those code paths are already preserved for the only scenario that's actually been tested to work (qemu-system-arm -M vexpress and some other arm pieces), so they aren't going anywhere. But all other old style command line options can be dropped AFAICT. See individual patches for descriptions.
Note, I'm pausing this series for now. I'm going to focus on getting the test suite bits committed before I rebase and revive this. thanks, Cole
participants (1)
-
Cole Robinson