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

[libvirt] [PATCH 28/34] Convert USB input devices to -device



---
 src/qemu/qemu_conf.c |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 1ea61a9..3b39a91 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2268,6 +2268,28 @@ error:
 }
 
 
+static char *qemuBuildUSBInputDevStr(virDomainInputDefPtr dev)
+{
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+    virBufferVSprintf(&buf, "%s",
+                      dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
+                      "usb-mouse" : "usb-tablet");
+    virBufferVSprintf(&buf, ",id=%s", dev->info.alias);
+
+    if (virBufferError(&buf)) {
+        virReportOOMError(NULL);
+        goto error;
+    }
+
+    return virBufferContentAndReset(&buf);
+
+error:
+    virBufferFreeAndReset(&buf);
+    return NULL;
+}
+
+
 static char *
 qemuBuildSoundDevStr(virDomainSoundDefPtr sound)
 {
@@ -3273,8 +3295,16 @@ 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) {
+                char *optstr;
+                ADD_ARG_LIT("-device");
+                if (!(optstr = qemuBuildUSBInputDevStr(input)))
+                    goto error;
+                ADD_ARG(optstr);
+            } else {
+                ADD_ARG_LIT("-usbdevice");
+                ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
+            }
         }
     }
 
-- 
1.6.5.2


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