]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: command: move qemuBuildHubDevStr caps validation to qemu_domain
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Mon, 9 Dec 2019 23:15:16 +0000 (20:15 -0300)
committerCole Robinson <crobinso@redhat.com>
Mon, 16 Dec 2019 22:50:43 +0000 (17:50 -0500)
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.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2xmltest.c

index f729253231b76fbed8aab7e64df68540ebc4baeb..74e4111f8cb1fd132830869876e35e43b141836a 100644 (file)
@@ -4779,19 +4779,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)
index 58199da7bac40cf87f11eae095a0c0df51ffb8a5..5bd5502c366355f4d1d600855504e4615a830f9d 100644 (file)
@@ -5345,6 +5345,27 @@ qemuDomainDeviceDefValidateNVRAM(virDomainNVRAMDefPtr nvram,
 }
 
 
+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)
@@ -7811,9 +7832,12 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         ret = qemuDomainDeviceDefValidateNVRAM(dev->data.nvram, def, qemuCaps);
         break;
 
+    case VIR_DOMAIN_DEVICE_HUB:
+        ret = qemuDomainDeviceDefValidateHub(dev->data.hub, qemuCaps);
+        break;
+
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_SOUND:
-    case VIR_DOMAIN_DEVICE_HUB:
     case VIR_DOMAIN_DEVICE_SHMEM:
     case VIR_DOMAIN_DEVICE_MEMORY:
     case VIR_DOMAIN_DEVICE_PANIC:
index 016a5c7df419215daa46ae159e810f400349246e..5c526237703d59c5df96f35e04d525c0a5b84c8c 100644 (file)
@@ -515,7 +515,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);