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

[libvirt] [PATCH 08/10] Convert USB hostdevices over to -device



The old syntax was

   -usbdevice host:PRODUCT:VENDOR

Or

   -usbdevice host:BUS.DEV

The new syntax is

   -device usb-host,product=PRODUCT,vendor=VENDOR

Or

   -device usb-host,hostbus=BUS,hostaddr=DEV
---
 src/qemu/qemu_conf.c |   39 ++++++++++++++++++++++++++++-----------
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7582319..ac322a7 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2596,8 +2596,13 @@ int qemudBuildCommandLine(virConnectPtr conn,
         virDomainInputDefPtr input = def->inputs[i];
 
         if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
-            ADD_ARG_LIT("-usbdevice");
-            ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
+            if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+                ADD_ARG_LIT("-device");
+                ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "usb-mouse" : "usb-tablet");
+            } else {
+                ADD_ARG_LIT("-usbdevice");
+                ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
+            }
         }
     }
 
@@ -2814,22 +2819,34 @@ int qemudBuildCommandLine(virConnectPtr conn,
         /* USB */
         if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
-            if(hostdev->source.subsys.u.usb.vendor) {
-                    ret = virAsprintf(&usbdev, "host:%.4x:%.4x",
-                               hostdev->source.subsys.u.usb.vendor,
-                               hostdev->source.subsys.u.usb.product);
 
+            if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+                ADD_ARG_LIT("-device");
+                if (hostdev->source.subsys.u.usb.vendor) {
+                    ret = virAsprintf(&usbdev, "usb-host,vendor=%.4x,product=%.4x",
+                                      hostdev->source.subsys.u.usb.vendor,
+                                      hostdev->source.subsys.u.usb.product);
+                } else {
+                    ret = virAsprintf(&usbdev, "usb-host,hostbus=%.3d,hostaddr=%.3d",
+                                      hostdev->source.subsys.u.usb.bus,
+                                      hostdev->source.subsys.u.usb.device);
+                }
             } else {
+                ADD_ARG_LIT("-usbdevice");
+                if (hostdev->source.subsys.u.usb.vendor) {
+                    ret = virAsprintf(&usbdev, "host:%.4x:%.4x",
+                                      hostdev->source.subsys.u.usb.vendor,
+                                      hostdev->source.subsys.u.usb.product);
+                } else {
                     ret = virAsprintf(&usbdev, "host:%.3d.%.3d",
-                               hostdev->source.subsys.u.usb.bus,
-                               hostdev->source.subsys.u.usb.device);
+                                      hostdev->source.subsys.u.usb.bus,
+                                      hostdev->source.subsys.u.usb.device);
+                }
             }
             if (ret < 0)
                 goto error;
 
-            ADD_ARG_LIT("-usbdevice");
-            ADD_ARG_LIT(usbdev);
-            VIR_FREE(usbdev);
+            ADD_ARG(usbdev);
         }
 
         /* PCI */
-- 
1.6.5.2


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