Move QEMU caps validation of QEMU_CAPS_USB_HUB to a new function in qemu_domain.c, qemuDomainDeviceDefValidateHub(). This function is called by qemuDomainDeviceDefValidate() to validate the sound device in domain define time. qemuxml2xmltest.c was adjusted to add the now required caps for domain definition. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/qemu_command.c | 13 ------------- src/qemu/qemu_domain.c | 26 +++++++++++++++++++++++++- tests/qemuxml2xmltest.c | 2 +- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3b4fae740c..0fa7f4693e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4736,19 +4736,6 @@ qemuBuildHubDevStr(const virDomainDef *def, { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - if (dev->type != VIR_DOMAIN_HUB_TYPE_USB) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("hub type %s not supported"), - virDomainHubTypeToString(dev->type)); - return NULL; - } - - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_HUB)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("usb-hub not supported by QEMU binary")); - return NULL; - } - virBufferAddLit(&buf, "usb-hub"); virBufferAsprintf(&buf, ",id=%s", dev->info.alias); if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ee9de98df1..fe24e736e8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5299,6 +5299,27 @@ qemuDomainDeviceDefValidateSound(virDomainSoundDefPtr sound, } +static int +qemuDomainDeviceDefValidateHub(virDomainHubDefPtr hub, + virQEMUCapsPtr qemuCaps) +{ + if (hub->type != VIR_DOMAIN_HUB_TYPE_USB) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("hub type %s not supported"), + virDomainHubTypeToString(hub->type)); + return -1; + } + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_HUB)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("usb-hub not supported by QEMU binary")); + return -1; + } + + return 0; +} + + static int qemuDomainDefValidate(const virDomainDef *def, void *opaque) @@ -7748,8 +7769,11 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, ret = qemuDomainDeviceDefValidateSound(dev->data.sound, qemuCaps); break; - case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_HUB: + ret = qemuDomainDeviceDefValidateHub(dev->data.hub, qemuCaps); + break; + + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_PANIC: diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index f3fec5ee19..0145970774 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -520,7 +520,7 @@ mymain(void) DO_TEST("ppc64-usb-controller-legacy", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_PIIX3_USB_UHCI); - DO_TEST("usb-port-missing", NONE); + DO_TEST("usb-port-missing", QEMU_CAPS_USB_HUB); DO_TEST("usb-redir", NONE); DO_TEST("usb-redir-filter", NONE); DO_TEST("usb-redir-filter-version", NONE); -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list