[PATCH 101/103] qemuBuildHubCommandLine: Generate via JSON

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 'usb-hub' device doesn't have any special properties.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d0bf3dbb30..306dcc6b8c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4860,19 +4860,27 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def,
 }


-static char *
-qemuBuildHubDevStr(const virDomainDef *def,
+static int
+qemuBuildHubDevCmd(virCommand *cmd,
+                   const virDomainDef *def,
                    virDomainHubDef *dev,
-                   virQEMUCaps *qemuCaps G_GNUC_UNUSED)
+                   virQEMUCaps *qemuCaps)
 {
-    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+    g_autoptr(virJSONValue) props = NULL;

-    virBufferAddLit(&buf, "usb-hub");
-    virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
-    if (qemuBuildDeviceAddressStr(&buf, def, &dev->info) < 0)
-        return NULL;
+    if (virJSONValueObjectCreate(&props,
+                                 "s:driver", "usb-hub",
+                                 "s:id", dev->info.alias,
+                                 NULL) < 0)
+        return -1;

-    return virBufferContentAndReset(&buf);
+    if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0)
+        return -1;
+
+    if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+        return -1;
+
+    return 0;
 }


@@ -4884,13 +4892,8 @@ qemuBuildHubCommandLine(virCommand *cmd,
     size_t i;

     for (i = 0; i < def->nhubs; i++) {
-        virDomainHubDef *hub = def->hubs[i];
-        g_autofree char *optstr = NULL;
-
-        virCommandAddArg(cmd, "-device");
-        if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps)))
+        if (qemuBuildHubDevCmd(cmd, def, def->hubs[i], qemuCaps) < 0)
             return -1;
-        virCommandAddArg(cmd, optstr);
     }

     return 0;
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux