Move the USB controller validation checs out of qemu_command and into the proper qemu_domain validation helper. We will start slowly and also modity the xml2argv test to change from a RUN to PARSE failure check when the QEMU_CAPS_PIIX3_USB_UHCI is removed. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_command.c | 6 ------ src/qemu/qemu_domain.c | 18 +++++++++++++++++- tests/qemuxml2argvtest.c | 8 ++++---- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 56030c482..7ea01e008 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2542,12 +2542,6 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def, model = def->model; - if (model == -1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("no model provided for USB controller")); - return -1; - } - smodel = qemuControllerModelUSBTypeToString(model); flags = qemuControllerModelUSBToCaps(model); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2e82df4ff..3ab3aa181 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4345,6 +4345,19 @@ qemuDomainDeviceDefValidateControllerSATA(virQEMUCapsPtr qemuCaps) static int +qemuDomainDeviceDefValidateControllerUSB(const virDomainControllerDef *controller) +{ + if (controller->model == -1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("no model provided for USB controller")); + return -1; + } + + return 0; +} + + +static int qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller, const virDomainDef *def, virQEMUCapsPtr qemuCaps) @@ -4380,10 +4393,13 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller, ret = qemuDomainDeviceDefValidateControllerSATA(qemuCaps); break; + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + ret = qemuDomainDeviceDefValidateControllerUSB(controller); + break; + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: - case VIR_DOMAIN_CONTROLLER_TYPE_USB: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: break; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 385a54615..3fcc76baa 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1508,10 +1508,10 @@ mymain(void) QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI); - DO_TEST_FAILURE("usb-controller-default-unavailable-q35", - QEMU_CAPS_DEVICE_IOH3420, - QEMU_CAPS_PCI_OHCI, - QEMU_CAPS_NEC_USB_XHCI); + DO_TEST_PARSE_ERROR("usb-controller-default-unavailable-q35", + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_OHCI, + QEMU_CAPS_NEC_USB_XHCI); DO_TEST("usb-controller-explicit-q35", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_PCI_OHCI, -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list