]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: build command line for virtio-input-host device
authorJán Tomko <jtomko@redhat.com>
Fri, 20 Nov 2015 07:57:16 +0000 (08:57 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 30 Nov 2015 12:00:04 +0000 (13:00 +0100)
<input type='passthrough' bus='virtio'>
  <source evdev='/dev/input/event1234'/>
</input>

results in:

-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234

https://bugzilla.redhat.com/show_bug.cgi?id=1231114

src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 394cec70003d55bf65163fe40882739120018556..4ff31dc071c95e11c056f353ff28925a556adf31 100644 (file)
@@ -5778,7 +5778,14 @@ qemuBuildVirtioInputDevStr(virDomainDefPtr def,
         virBufferAsprintf(&buf, "virtio-keyboard%s,id=%s", suffix, dev->info.alias);
         break;
     case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
-        /* TBD */
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_INPUT_HOST)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("virtio-input-host is not supported by this QEMU binary"));
+            goto error;
+        }
+        virBufferAsprintf(&buf, "virtio-input-host%s,id=%s,evdev=", suffix, dev->info.alias);
+        virBufferEscape(&buf, ',', ",", "%s", dev->source.evdev);
+        break;
     case VIR_DOMAIN_INPUT_TYPE_LAST:
         break;
     }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args
new file mode 100644 (file)
index 0000000..4be1ef5
--- /dev/null
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-device virtio-input-host-pci,id=input0,evdev=/dev/input/event1234,bus=pci.0,\
+addr=0x4 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 0ad9d5a64f797937da40652195119d29f0030ec0..6513651853061c466ad108d32102727246686b34 100644 (file)
@@ -1760,6 +1760,7 @@ mymain(void)
 
     DO_TEST("virtio-input", QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_KEYBOARD,
             QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET);
+    DO_TEST("virtio-input-passthrough", QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_INPUT_HOST);
 
     qemuTestDriverFree(&driver);