[libvirt] [PATCH 0/8] qemu: add support for virtio-input devices

Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host. Requires kernel 4.1+ in the guest. https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114 Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device docs/formatdomain.html.in | 18 ++++- docs/schemas/domaincommon.rng | 50 ++++++++---- src/conf/domain_conf.c | 34 ++++++-- src/conf/domain_conf.h | 5 ++ src/qemu/qemu_capabilities.c | 12 +++ src/qemu/qemu_capabilities.h | 4 + src/qemu/qemu_cgroup.c | 25 ++++++ src/qemu/qemu_command.c | 92 +++++++++++++++++++++- src/security/security_dac.c | 72 +++++++++++++++++ src/security/security_selinux.c | 70 ++++++++++++++++ tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 4 + .../qemuxml2argv-virtio-input-passthrough.args | 22 ++++++ .../qemuxml2argv-virtio-input-passthrough.xml | 24 ++++++ .../qemuxml2argv-virtio-input.args | 23 ++++++ .../qemuxml2argvdata/qemuxml2argv-virtio-input.xml | 26 ++++++ tests/qemuxml2argvtest.c | 4 + tests/qemuxml2xmltest.c | 3 + 17 files changed, 462 insertions(+), 26 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml -- 2.4.6

Add capabilities for virtio-keyboard, virtio-mouse and virtio-tablet devices: name "virtio-keyboard-device", bus virtio-bus name "virtio-keyboard-pci", bus PCI name "virtio-mouse-device", bus virtio-bus name "virtio-mouse-pci", bus PCI name "virtio-tablet-device", bus virtio-bus name "virtio-tablet-pci", bus PCI Map both -device and -pci versions of the device to one capability. https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- src/qemu/qemu_capabilities.c | 9 +++++++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2813212..4c58a66 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -301,6 +301,9 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "gic-version", "incoming-defer", /* 200 */ + "virtio-keyboard", + "virtio-mouse", + "virtio-tablet", ); @@ -1543,6 +1546,12 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "virtio-net-ccw", QEMU_CAPS_DEVICE_VIRTIO_NET }, { "virtio-net-s390", QEMU_CAPS_DEVICE_VIRTIO_NET }, { "virtio-net-device", QEMU_CAPS_DEVICE_VIRTIO_NET }, + { "virtio-keyboard-device", QEMU_CAPS_VIRTIO_KEYBOARD }, + { "virtio-keyboard-pci", QEMU_CAPS_VIRTIO_KEYBOARD }, + { "virtio-mouse-device", QEMU_CAPS_VIRTIO_MOUSE }, + { "virtio-mouse-pci", QEMU_CAPS_VIRTIO_MOUSE }, + { "virtio-tablet-device", QEMU_CAPS_VIRTIO_TABLET }, + { "virtio-tablet-pci", QEMU_CAPS_VIRTIO_TABLET }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e3e40e5..d5421d8 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -327,6 +327,9 @@ typedef enum { /* 200 */ QEMU_CAPS_INCOMING_DEFER, /* -incoming defer and migrate_incoming */ + QEMU_CAPS_VIRTIO_KEYBOARD, /* -device virtio-keyboard-{device,pci} */ + QEMU_CAPS_VIRTIO_MOUSE, /* -device virtio-mouse-{device,pci} */ + QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps index 6694b7d..8cdf10d 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps @@ -162,4 +162,7 @@ <flag name='e1000'/> <flag name='virtio-net'/> <flag name='incoming-defer'/> + <flag name='virtio-keyboard'/> + <flag name='virtio-mouse'/> + <flag name='virtio-tablet'/> </qemuCaps> -- 2.4.6

To be used by the family of virtio input devices: <input type='mouse' bus='virtio'/> <input type='tablet' bus='virtio'/> <input type='keyboard' bus='virtio'/> https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- docs/formatdomain.html.in | 6 ++++- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 6 +++-- src/conf/domain_conf.h | 1 + .../qemuxml2argvdata/qemuxml2argv-virtio-input.xml | 26 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 2 ++ 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e5e0167..d334071 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4801,6 +4801,9 @@ qemu-kvm -net nic,model=? /dev/null <devices> <input type='mouse' bus='usb'/> <input type='keyboard' bus='usb'/> + <input type='mouse' bus='virtio'/> + <input type='keyboard' bus='virtio'/> + <input type='tablet' bus='virtio'/> </devices> ...</pre> @@ -4812,7 +4815,8 @@ qemu-kvm -net nic,model=? /dev/null The tablet provides absolute cursor movement, while the mouse uses relative movement. The optional <code>bus</code> attribute can be used to refine the exact device type. - It takes values "xen" (paravirtualized), "ps2" and "usb".</dd> + It takes values "xen" (paravirtualized), "ps2" and "usb" or + (<span class="since">since 1.3.0</span>) "virtio".</dd> </dl> <p> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 994face..b740db8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3591,6 +3591,7 @@ <value>ps2</value> <value>usb</value> <value>xen</value> + <value>virtio</value> </choice> </attribute> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0ac7dbf..419bfb9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -543,7 +543,8 @@ VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", "usb", "xen", - "parallels") + "parallels", + "virtio") VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, "sdl", @@ -22357,7 +22358,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, goto error; for (n = 0; n < def->ninputs; n++) - if (def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB && + if ((def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB || + def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) && virDomainInputDefFormat(buf, def->inputs[n], flags) < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8d43ee6..81c546d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1297,6 +1297,7 @@ typedef enum { VIR_DOMAIN_INPUT_BUS_USB, VIR_DOMAIN_INPUT_BUS_XEN, VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */ + VIR_DOMAIN_INPUT_BUS_VIRTIO, VIR_DOMAIN_INPUT_BUS_LAST } virDomainInputBus; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml new file mode 100644 index 0000000..11fb566 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml @@ -0,0 +1,26 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='virtio'/> + <input type='keyboard' bus='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> + </input> + <input type='tablet' bus='virtio'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index cbd4d0d..535dfb8 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -626,6 +626,8 @@ mymain(void) DO_TEST("memory-hotplug-dimm"); DO_TEST("net-udp"); + DO_TEST("virtio-input"); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.4.6

Add support for these qemu devices: virtio-mouse-{pci,device} virtio-keyboard-{pci,device} virtio-tablet-{pci,device} https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- src/qemu/qemu_command.c | 83 +++++++++++++++++++++- .../qemuxml2argv-virtio-input.args | 23 ++++++ tests/qemuxml2argvtest.c | 3 + 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 91c55cb..570904a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1284,6 +1284,12 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, } } + for (i = 0; i < def->ninputs; i++) { + if (def->inputs[i]->bus == VIR_DOMAIN_DISK_BUS_VIRTIO && + def->inputs[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) + def->inputs[i]->info.type = type; + } + for (i = 0; i < def->ncontrollers; i++) { if ((def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL || @@ -2681,7 +2687,14 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, goto error; } for (i = 0; i < def->ninputs; i++) { - /* Nada - none are PCI based (yet) */ + if (def->inputs[i]->bus != VIR_DOMAIN_INPUT_BUS_VIRTIO) + continue; + if (def->inputs[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) + continue; + + if (virDomainPCIAddressReserveNextSlot(addrs, + &def->inputs[i]->info, flags) < 0) + goto error; } for (i = 0; i < def->nparallels; i++) { /* Nada - none are PCI based (yet) */ @@ -5716,6 +5729,67 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev) return NULL; } +static char * +qemuBuildVirtioInputDevStr(virDomainDefPtr def, + virDomainInputDefPtr dev, + virQEMUCapsPtr qemuCaps) +{ + virBuffer buf = VIR_BUFFER_INITIALIZER; + const char *suffix; + + if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + suffix = "-pci"; + } else if (dev->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) { + suffix = "-device"; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported address type %s for virtio input device"), + virDomainDeviceAddressTypeToString(dev->info.type)); + goto error; + } + + switch ((virDomainInputType) dev->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_MOUSE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio-mouse is not supported by this QEMU binary")); + goto error; + } + virBufferAsprintf(&buf, "virtio-mouse%s,id=%s", suffix, dev->info.alias); + break; + case VIR_DOMAIN_INPUT_TYPE_TABLET: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TABLET)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio-tablet is not supported by this QEMU binary")); + goto error; + } + virBufferAsprintf(&buf, "virtio-tablet%s,id=%s", suffix, dev->info.alias); + break; + case VIR_DOMAIN_INPUT_TYPE_KBD: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_KEYBOARD)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio-keyboard is not supported by this QEMU binary")); + goto error; + } + virBufferAsprintf(&buf, "virtio-keyboard%s,id=%s", suffix, dev->info.alias); + break; + case VIR_DOMAIN_INPUT_TYPE_LAST: + break; + } + + if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0) + goto error; + + if (virBufferCheckError(&buf) < 0) + goto error; + + return virBufferContentAndReset(&buf); + + error: + virBufferFreeAndReset(&buf); + return NULL; +} + char * qemuBuildUSBInputDevStr(virDomainDefPtr def, virDomainInputDefPtr dev, @@ -10472,6 +10546,13 @@ qemuBuildCommandLine(virConnectPtr conn, break; } } + } else if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) { + char *optstr; + virCommandAddArg(cmd, "-device"); + if (!(optstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps))) + goto error; + virCommandAddArg(cmd, optstr); + VIR_FREE(optstr); } } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.args new file mode 100644 index 0000000..12dfdeb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.args @@ -0,0 +1,23 @@ +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-mouse-pci,id=input0,bus=pci.0,addr=0x4 \ +-device virtio-keyboard-pci,id=input1,bus=pci.0,addr=0xa \ +-device virtio-tablet-pci,id=input2,bus=pci.0,addr=0x5 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index dc8654e..bad65a6 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1748,6 +1748,9 @@ mymain(void) DO_TEST("qemu-ns-commandline-ns0", NONE); DO_TEST("qemu-ns-commandline-ns1", NONE); + DO_TEST("virtio-input", QEMU_CAPS_DEVICE, QEMU_CAPS_VIRTIO_KEYBOARD, + QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.4.6

Add QEMU_CAPS_VIRTIO_INPUT_HOST for both virtio-input-host-device and virtio-input-host-pci. --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.4.0-1.caps | 1 + 3 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 4c58a66..5fb957b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -304,6 +304,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-keyboard", "virtio-mouse", "virtio-tablet", + "virtio-input-host", ); @@ -1552,6 +1553,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "virtio-mouse-pci", QEMU_CAPS_VIRTIO_MOUSE }, { "virtio-tablet-device", QEMU_CAPS_VIRTIO_TABLET }, { "virtio-tablet-pci", QEMU_CAPS_VIRTIO_TABLET }, + { "virtio-input-host-device", QEMU_CAPS_VIRTIO_INPUT_HOST }, + { "virtio-input-host-pci", QEMU_CAPS_VIRTIO_INPUT_HOST }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index d5421d8..ad273f6 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -330,6 +330,7 @@ typedef enum { QEMU_CAPS_VIRTIO_KEYBOARD, /* -device virtio-keyboard-{device,pci} */ QEMU_CAPS_VIRTIO_MOUSE, /* -device virtio-mouse-{device,pci} */ QEMU_CAPS_VIRTIO_TABLET, /* -device virtio-tablet-{device,pci} */ + QEMU_CAPS_VIRTIO_INPUT_HOST, /* -device virtio-input-host-{device,pci} */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps index 8cdf10d..6096628 100644 --- a/tests/qemucapabilitiesdata/caps_2.4.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_2.4.0-1.caps @@ -165,4 +165,5 @@ <flag name='virtio-keyboard'/> <flag name='virtio-mouse'/> <flag name='virtio-tablet'/> + <flag name='virtio-input-host'/> </qemuCaps> -- 2.4.6

Add xml for the new virtio-input-host-pci device: <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event1234'/> </input> https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- docs/formatdomain.html.in | 12 +++++- docs/schemas/domaincommon.rng | 49 +++++++++++++++------- src/conf/domain_conf.c | 28 +++++++++++-- src/conf/domain_conf.h | 4 ++ src/qemu/qemu_command.c | 2 + .../qemuxml2argv-virtio-input-passthrough.xml | 24 +++++++++++ tests/qemuxml2xmltest.c | 1 + 7 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d334071..241ed2d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4804,14 +4804,18 @@ qemu-kvm -net nic,model=? /dev/null <input type='mouse' bus='virtio'/> <input type='keyboard' bus='virtio'/> <input type='tablet' bus='virtio'/> + <input type='passthrough' bus='virtio'> + <source evdev='/dev/input/event1/> + </input> </devices> ...</pre> <dl> <dt><code>input</code></dt> <dd>The <code>input</code> element has one mandatory attribute, - the <code>type</code> whose value can be 'mouse', 'tablet' or - (<span class="since">since 1.2.2</span>) 'keyboard'. + the <code>type</code> whose value can be 'mouse', 'tablet', + (<span class="since">since 1.2.2</span>) 'keyboard' or + (<span class="since">since 1.3.0</span>) 'passthrough'. The tablet provides absolute cursor movement, while the mouse uses relative movement. The optional <code>bus</code> attribute can be used to refine the exact device type. @@ -4824,6 +4828,10 @@ qemu-kvm -net nic,model=? /dev/null sub-element <code><address></code> which can tie the device to a particular PCI slot, <a href="#elementsAddress">documented above</a>. + + For type <code>passthrough</code>, the mandatory sub-element <code>source</code> + must have an <code>evdev</code> attribute containing the absolute path to the + event device passed through to guests. (KVM only) </p> <h4><a name="elementsHub">Hub devices</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index b740db8..2fb4d3f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3578,23 +3578,40 @@ <define name="input"> <element name="input"> - <attribute name="type"> - <choice> - <value>tablet</value> - <value>mouse</value> - <value>keyboard</value> - </choice> - </attribute> - <optional> - <attribute name="bus"> - <choice> - <value>ps2</value> - <value>usb</value> - <value>xen</value> + <choice> + <group> + <attribute name="type"> + <choice> + <value>tablet</value> + <value>mouse</value> + <value>keyboard</value> + </choice> + </attribute> + <optional> + <attribute name="bus"> + <choice> + <value>ps2</value> + <value>usb</value> + <value>xen</value> + <value>virtio</value> + </choice> + </attribute> + </optional> + </group> + <group> + <attribute name="type"> + <value>passthrough</value> + </attribute> + <attribute name="bus"> <value>virtio</value> - </choice> - </attribute> - </optional> + </attribute> + <element name="source"> + <attribute name="evdev"> + <ref name="absFilePath"/> + </attribute> + </element> + </group> + </choice> <optional> <ref name="alias"/> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 419bfb9..d8ac349 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -537,7 +537,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, "mouse", "tablet", - "keyboard") + "keyboard", + "passthrough") VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, "ps2", @@ -1409,6 +1410,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def) return; virDomainDeviceInfoClear(&def->info); + VIR_FREE(def->source.evdev); VIR_FREE(def); } @@ -10215,15 +10217,20 @@ virDomainPanicDefParseXML(xmlNodePtr node) static virDomainInputDefPtr virDomainInputDefParseXML(const virDomainDef *dom, xmlNodePtr node, + xmlXPathContextPtr ctxt, unsigned int flags) { + xmlNodePtr save = ctxt->node; virDomainInputDefPtr def; + char *evdev = NULL; char *type = NULL; char *bus = NULL; if (VIR_ALLOC(def) < 0) return NULL; + ctxt->node = node; + type = virXMLPropString(node, "type"); bus = virXMLPropString(node, "bus"); @@ -10330,10 +10337,20 @@ virDomainInputDefParseXML(const virDomainDef *dom, goto error; } + if ((evdev = virXPathString("string(./source/@evdev)", ctxt))) + def->source.evdev = virFileSanitizePath(evdev); + if (def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH && !def->source.evdev) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing evdev path for input device passthrough")); + goto error; + } + cleanup: + VIR_FREE(evdev); VIR_FREE(type); VIR_FREE(bus); + ctxt->node = save; return def; error: @@ -12684,8 +12701,8 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: - if (!(dev->data.input = virDomainInputDefParseXML(def, - node, flags))) + if (!(dev->data.input = virDomainInputDefParseXML(def, node, + ctxt, flags))) goto error; break; case VIR_DOMAIN_DEVICE_SOUND: @@ -16068,6 +16085,7 @@ virDomainDefParseXML(xmlDocPtr xml, for (i = 0; i < n; i++) { virDomainInputDefPtr input = virDomainInputDefParseXML(def, nodes[i], + ctxt, flags); if (!input) goto error; @@ -20919,9 +20937,11 @@ virDomainInputDefFormat(virBufferPtr buf, virBufferAsprintf(buf, "<input type='%s' bus='%s'", type, bus); - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { + if (virDomainDeviceInfoNeedsFormat(&def->info, flags) || + def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "<source evdev='%s'/>\n", def->source.evdev); if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; virBufferAdjustIndent(buf, -2); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 81c546d..4ad41e6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1288,6 +1288,7 @@ typedef enum { VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_TYPE_TABLET, VIR_DOMAIN_INPUT_TYPE_KBD, + VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH, VIR_DOMAIN_INPUT_TYPE_LAST } virDomainInputType; @@ -1305,6 +1306,9 @@ typedef enum { struct _virDomainInputDef { int type; int bus; + struct { + char *evdev; + } source; virDomainDeviceInfo info; }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 570904a..5815734 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5773,6 +5773,8 @@ qemuBuildVirtioInputDevStr(virDomainDefPtr def, } virBufferAsprintf(&buf, "virtio-keyboard%s,id=%s", suffix, dev->info.alias); break; + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + /* TBD */ case VIR_DOMAIN_INPUT_TYPE_LAST: break; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.xml new file mode 100644 index 0000000..e2bf063 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.xml @@ -0,0 +1,24 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='passthrough' bus='virtio'> + <source evdev='/dev/input/event1234'/> + </input> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 535dfb8..9b47ce0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -627,6 +627,7 @@ mymain(void) DO_TEST("net-udp"); DO_TEST("virtio-input"); + DO_TEST("virtio-input-passthrough"); qemuTestDriverFree(&driver); -- 2.4.6

Add functions for setting and restoring the label of input devices to DAC and SELinux drivers. https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- src/security/security_dac.c | 72 +++++++++++++++++++++++++++++++++++++++++ src/security/security_selinux.c | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index dfdeffd..cdde34e 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1013,6 +1013,66 @@ virSecurityDACRestoreSecurityTPMFileLabel(virSecurityManagerPtr mgr, static int +virSecurityDACSetInputLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virDomainInputDefPtr input) + +{ + virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr); + virSecurityLabelDefPtr seclabel; + int ret = -1; + uid_t user; + gid_t group; + + seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_DAC_NAME); + if (seclabel && !seclabel->relabel) + return 0; + + switch ((virDomainInputType) input->type) { + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + if (virSecurityDACGetIds(seclabel, priv, &user, &group, NULL, NULL) < 0) + return -1; + + ret = virSecurityDACSetOwnership(priv, NULL, input->source.evdev, user, group); + break; + + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + case VIR_DOMAIN_INPUT_TYPE_LAST: + ret = 0; + break; + } + + return ret; +} + +static int +virSecurityDACRestoreInputLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainInputDefPtr input) +{ + virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr); + int ret = -1; + + switch ((virDomainInputType) input->type) { + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + ret = virSecurityDACRestoreSecurityFileLabel(priv, input->source.evdev); + break; + + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + case VIR_DOMAIN_INPUT_TYPE_LAST: + ret = 0; + break; + } + + return ret; +} + + +static int virSecurityDACRestoreSecurityAllLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, bool migrated) @@ -1037,6 +1097,12 @@ virSecurityDACRestoreSecurityAllLabel(virSecurityManagerPtr mgr, NULL) < 0) rc = -1; } + + for (i = 0; i < def->ninputs; i++) { + if (virSecurityDACRestoreInputLabel(mgr, def, def->inputs[i]) < 0) + rc = -1; + } + for (i = 0; i < def->ndisks; i++) { if (virSecurityDACRestoreSecurityImageLabelInt(mgr, def, @@ -1114,6 +1180,12 @@ virSecurityDACSetSecurityAllLabel(virSecurityManagerPtr mgr, def->disks[i]) < 0) return -1; } + + for (i = 0; i < def->ninputs; i++) { + if (virSecurityDACSetInputLabel(mgr, def, def->inputs[i]) < 0) + return -1; + } + for (i = 0; i < def->nhostdevs; i++) { if (virSecurityDACSetSecurityHostdevLabel(mgr, def, diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 80b0886..b8ebdcc 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1056,6 +1056,64 @@ virSecuritySELinuxRestoreSecurityFileLabel(virSecurityManagerPtr mgr, static int +virSecuritySELinuxSetInputLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virDomainInputDefPtr input) +{ + virSecurityLabelDefPtr seclabel; + + seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); + if (seclabel == NULL) + return 0; + + switch ((virDomainInputType) input->type) { + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + if (virSecuritySELinuxSetFilecon(mgr, input->source.evdev, + seclabel->imagelabel) < 0) + return -1; + break; + + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + case VIR_DOMAIN_INPUT_TYPE_LAST: + break; + } + + return 0; +} + + +static int +virSecuritySELinuxRestoreInputLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virDomainInputDefPtr input) +{ + int rc = 0; + virSecurityLabelDefPtr seclabel; + + seclabel = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME); + if (seclabel == NULL) + return 0; + + switch ((virDomainInputType) input->type) { + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + rc = virSecuritySELinuxRestoreSecurityFileLabel(mgr, + input->source.evdev); + break; + + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + case VIR_DOMAIN_INPUT_TYPE_LAST: + break; + } + + return rc; +} + + +static int virSecuritySELinuxSetSecurityTPMFileLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, virDomainTPMDefPtr tpm) @@ -1954,6 +2012,12 @@ virSecuritySELinuxRestoreSecurityAllLabel(virSecurityManagerPtr mgr, NULL) < 0) rc = -1; } + + for (i = 0; i < def->ninputs; i++) { + if (virSecuritySELinuxRestoreInputLabel(mgr, def, def->inputs[i]) < 0) + rc = -1; + } + for (i = 0; i < def->ndisks; i++) { virDomainDiskDefPtr disk = def->disks[i]; @@ -2346,6 +2410,12 @@ virSecuritySELinuxSetSecurityAllLabel(virSecurityManagerPtr mgr, NULL) < 0) return -1; } + + for (i = 0; i < def->ninputs; i++) { + if (virSecuritySELinuxSetInputLabel(mgr, def, def->inputs[i]) < 0) + return -1; + } + if (def->tpm) { if (virSecuritySELinuxSetSecurityTPMFileLabel(mgr, def, def->tpm) < 0) -- 2.4.6

https://bugzilla.redhat.com/show_bug.cgi?id=1231114 --- src/qemu/qemu_cgroup.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index a8e0b8c..3b44b7a 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -200,6 +200,26 @@ qemuSetupTPMCgroup(virDomainDefPtr def, static int +qemuSetupInputCgroup(virDomainObjPtr vm, + virDomainInputDefPtr dev) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + int ret = 0; + + switch (dev->type) { + case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH: + VIR_DEBUG("Process path '%s' for input device", dev->source.evdev); + ret = virCgroupAllowDevicePath(priv->cgroup, dev->source.evdev, + VIR_CGROUP_DEVICE_RW); + virDomainAuditCgroupPath(vm, priv->cgroup, "allow", dev->source.evdev, "rw", ret == 0); + break; + } + + return ret; +} + + +static int qemuSetupHostUSBDeviceCgroup(virUSBDevicePtr dev ATTRIBUTE_UNUSED, const char *path, void *opaque) @@ -596,6 +616,11 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver, goto cleanup; } + for (i = 0; i < vm->def->ninputs; i++) { + if (qemuSetupInputCgroup(vm, vm->def->inputs[i]) < 0) + goto cleanup; + } + for (i = 0; i < vm->def->nrngs; i++) { if (vm->def->rngs[i]->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM) { VIR_DEBUG("Setting Cgroup ACL for RNG device"); -- 2.4.6

<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 | 9 ++++++++- .../qemuxml2argv-virtio-input-passthrough.args | 22 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5815734..02f834e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5774,7 +5774,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 index 0000000..4be1ef5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input-passthrough.args @@ -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 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bad65a6..ac30036 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1750,6 +1750,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); -- 2.4.6

On Fr, 2015-11-20 at 09:59 +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
Looks good to me. One question: Does this work with symlinks? i.e. when using the static names created by udev in /dev/input/by-{id,path} ? cheers, Gerd

On Fri, Nov 20, 2015 at 11:23:01AM +0100, Gerd Hoffmann wrote:
On Fr, 2015-11-20 at 09:59 +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
Looks good to me.
One question: Does this work with symlinks? i.e. when using the static names created by udev in /dev/input/by-{id,path} ?
Yes. The symlink path is passed unchanged to QEMU and on libvirt side, all the operations (adding it to devices.allow cgroup, changing the uid:gid and selinux label) are done on the device the link points to. Jan

On Fri, Nov 20, 2015 at 09:59:35AM +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114
Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device
ACK series. I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one. Pavel

On Fri, Nov 27, 2015 at 02:36:09PM +0100, Pavel Hrdina wrote:
On Fri, Nov 20, 2015 at 09:59:35AM +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114
Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device
ACK series.
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
I don't think it's that easy. We add it to the XML because when we start QEMU with any graphics, it also automatically gains an additional mouse and keyboard. We con't specify it on the command line, so we're merely trying so that the XML matches what the domain looks like.
Pavel
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Mon, Nov 30, 2015 at 09:14:11AM +0100, Martin Kletzander wrote:
On Fri, Nov 27, 2015 at 02:36:09PM +0100, Pavel Hrdina wrote:
On Fri, Nov 20, 2015 at 09:59:35AM +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114
Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device
ACK series.
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
I don't think it's that easy. We add it to the XML because when we start QEMU with any graphics, it also automatically gains an additional mouse and keyboard. We con't specify it on the command line, so we're merely trying so that the XML matches what the domain looks like.
In that case we should put the ps/2 mouse and keyboard always in the domain XML to represent actual state of the domain.

On Mon, Nov 30, 2015 at 01:25:25PM +0100, Pavel Hrdina wrote:
On Mon, Nov 30, 2015 at 09:14:11AM +0100, Martin Kletzander wrote:
On Fri, Nov 27, 2015 at 02:36:09PM +0100, Pavel Hrdina wrote:
On Fri, Nov 20, 2015 at 09:59:35AM +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114
Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device
ACK series.
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
I don't think it's that easy. We add it to the XML because when we start QEMU with any graphics, it also automatically gains an additional mouse and keyboard. We con't specify it on the command line, so we're merely trying so that the XML matches what the domain looks like.
In that case we should put the ps/2 mouse and keyboard always in the domain XML to represent actual state of the domain.
Or find out how to disable those in QEMU so that we don't double them (that apparently causes some issues, too).

On Mon, Nov 30, 2015 at 03:53:56PM +0100, Martin Kletzander wrote:
On Mon, Nov 30, 2015 at 01:25:25PM +0100, Pavel Hrdina wrote:
On Mon, Nov 30, 2015 at 09:14:11AM +0100, Martin Kletzander wrote:
On Fri, Nov 27, 2015 at 02:36:09PM +0100, Pavel Hrdina wrote:
On Fri, Nov 20, 2015 at 09:59:35AM +0100, Ján Tomko wrote:
Support virtio-keyboard, virtio-mouse, virtio-tablet and virtio-input-host.
Requires kernel 4.1+ in the guest.
https://www.kraxel.org/blog/2015/06/new-member-in-the-virtio-family-input-de... https://bugzilla.redhat.com/show_bug.cgi?id=1231114
Ján Tomko (8): qemu: add capabilities for virtio input devices conf: parse and format virtio input bus in domain XML qemu: build command line for virtio input devices qemu: add capability for virtio-input-host-device conf: add XML for input device passthrough security: label the evdev for input device passthrough qemu: add passed-through input devs to cgroup ACL qemu: build command line for virtio-input-host device
ACK series.
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
I don't think it's that easy. We add it to the XML because when we start QEMU with any graphics, it also automatically gains an additional mouse and keyboard. We con't specify it on the command line, so we're merely trying so that the XML matches what the domain looks like.
In that case we should put the ps/2 mouse and keyboard always in the domain XML to represent actual state of the domain.
Or find out how to disable those in QEMU so that we don't double them (that apparently causes some issues, too).
Well, that's the thing, we cannot disable it for QEMU [1]. The best solution is to put those implicit input devices only into live XML. This will result in config XML that contains input devices defined by user, but live XML will add those implicit devices if necessary. [1] https://www.redhat.com/archives/libvir-list/2015-November/msg01253.html

Hi,
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
Adding ps/2 mouse + keyboard unconditionally makes sense (for x86) as any qemu guest will actually have a ps/2 keybaord and ps/2 mouse (even when started without graphics). That is hard-coded in the machine type init and can't be turned off. cheers, Gerd

On Mon, Nov 30, 2015 at 11:25:19AM +0100, Gerd Hoffmann wrote:
Hi,
I have only one thing to mention, but it's not in scope of this series, it's an existing behavior. If you define a new guest with mouse/keyboard input device with bus!=ps2 and graphics is defined, then we always add implicit mouse and keyboard with bus=ps2 which leads to having two different mouses and keyboards defined for the guest. We should probably update the code to not add any implicit mouse or keyboard if there is already one.
Adding ps/2 mouse + keyboard unconditionally makes sense (for x86) as any qemu guest will actually have a ps/2 keybaord and ps/2 mouse (even when started without graphics). That is hard-coded in the machine type init and can't be turned off.
cheers, Gerd
Oh, good to know, thanks.
participants (4)
-
Gerd Hoffmann
-
Ján Tomko
-
Martin Kletzander
-
Pavel Hrdina