Bug 1379603
Summary: | RFE: support hotplugging virtio input devices | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Fangge Jin <fjin> |
Component: | libvirt | Assignee: | Ján Tomko <jtomko> |
Status: | CLOSED ERRATA | QA Contact: | jiyan <jiyan> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.3 | CC: | dyuan, hhan, jtomko, mtessun, mzhan, rbalakri, xuzhang, yafu, zpeng |
Target Milestone: | rc | Keywords: | FutureFeature |
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | libvirt-3.9.0-1.el7 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-04-10 10:39:40 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1509866 | ||
Bug Blocks: | 1473046 |
Description
Fangge Jin
2016-09-27 08:22:10 UTC
Hotplug/hotunplug virtio input devices by qemu monitor command: 1) add/delete a virtio mouse # virsh qemu-monitor-command rhel7 '{"execute":"device_add","arguments":{"driver":"virtio-mouse-pci","id":"input1","bus":"pci.0","addr":"0xa"}}' {"return":{},"id":"libvirt-19"} check the current mouse # virsh qemu-monitor-command rhel7 --hmp info mice Mouse #2: QEMU PS/2 Mouse * Mouse #3: QEMU Virtio Mouse delete the virtio mouse # virsh qemu-monitor-command rhel7 '{"execute":"device_del","arguments":{"id":"input1"}}'{"return":{},"id":"libvirt-22"} check the current mouse again # virsh qemu-monitor-command rhel7 --hmp info mice * Mouse #2: QEMU PS/2 Mouse 2) add/delete a virtio keyboard # virsh qemu-monitor-command rhel7 '{"execute":"device_add","arguments":{"driver":"virtio-keyboard-pci","id":"input1","bus":"pci.0","addr":"0xa"}}' {"return":{},"id":"libvirt-25"} # virsh qemu-monitor-command rhel7 '{"execute":"device_del","arguments":{"id":"input1"}}' {"return":{},"id":"libvirt-26"} 3) add/delete a virtio tablet # virsh qemu-monitor-command rhel7 '{"execute":"device_add","arguments":{"driver":"virtio-tablet-pci","id":"input1","bus":"pci.0","addr":"0xa"}}' {"return":{},"id":"libvirt-27"} # virsh qemu-monitor-command rhel7 '{"execute":"device_del","arguments":{"id":"input1"}}'{"return":{},"id":"libvirt-28"} 4) add/delete a host input device to/from guest(but I run into permission issue) # chown qemu:qemu /dev/input/event3 # chcon system_u:object_r:svirt_image_t:s0 /dev/input/event3 # virsh qemu-monitor-command rhel7 '{"execute":"device_add","arguments":{"driver":"virtio-input-host-pci","id":"input2","evdev":"/dev/input/event3","bus":"pci.0","addr":"0xb"}}' {"id":"libvirt-23","error":{"class":"GenericError","desc":"Could not open '/dev/input/event3': Operation not permitted"}} Upstream patches: https://www.redhat.com/archives/libvir-list/2017-October/msg00684.html Pushed upstream as: commit bc9ffafcc776fd84bb0bdaa7e621572e48e81841 Author: Ján Tomko <jtomko> CommitDate: 2017-10-19 14:43:22 +0200 qemu: implement input device hotplug For both virtio input devices and USB input devices. https://bugzilla.redhat.com/show_bug.cgi?id=1379603 commit 67486bb2957ff3ac266df6844a9b3d960f410555 Author: Ján Tomko <jtomko> CommitDate: 2017-10-19 14:43:22 +0200 qemu: implement input device hotunplug Allow unplugging USB and virtio USB devices. https://bugzilla.redhat.com/show_bug.cgi?id=1379603 git describe: v3.8.0-185-g67486bb29 Test hot-plug/hot-unplug on input devices on libvirt-3.9.0-1.el7.x86_64 qemu-kvm-rhev-2.10.0-4.el7.x86_64 Since virtio-input-passthrough device is not supported now. Test keyboard/mouse/tablet device on usb or virtio bus. 1. Prepare devices xml: /tmp/usb-keyboard.xml: <input type='keyboard' bus='usb'/> /tmp/usb-mouse.xml: <input type='mouse' bus='usb'/> /tmp/usb-tablet.xml: <input type='tablet' bus='usb'/> /tmp/virtio-keyboard.xml: <input type='keyboard' bus='virtio'/> /tmp/virtio-mouse.xml: <input type='mouse' bus='virtio'/> /tmp/virtio-tablet.xml: <input type='tablet' bus='virtio'/> 2. hot-plug/hot-unplug on input devices # virsh list Id Name State ---------------------------------------------------- 4 V running ``` #!/bin/bash for i in /tmp/virtio-*.xml;do virsh attach-device V $i done for i in /tmp/usb-*.xml;do virsh attach-device V $i done for i in /tmp/virtio-*.xml;do virsh detach-device V $i done for i in /tmp/usb-*.xml;do virsh detach-device V $i done ``` Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully hot-plug/hot-unplug works well. Test components' version qemu-kvm-rhev-2.10.0-11.el7.x86_64 kernel-3.10.0-799.el7.x86_64 libvirt-3.9.0-5.el7.x86_64 Test env Physical host with USB keyboard and mouse plugged in and the event info is as following: # cat /proc/bus/input/devices N: Name="Dell Dell USB Entry Keyboard" P: Phys=usb-0000:00:1d.0-1.8/input0 S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.8/2-1.8:1.0/input/input2 H: Handlers=sysrq kbd leds event2 # cat /proc/bus/input/devices N: Name="PixArt HP USB Optical Mouse" P: Phys=usb-0000:00:1a.0-1.4/input0 S: Sysfs=/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input14 H: Handlers=mouse0 event3 # ll /dev/input/event2 crw-rw----. 1 root input 13, 66 Dec 6 14:48 /dev/input/event2 # ll /dev/input/event3 crw-rw----. 1 root input 13, 67 Dec 6 14:53 /dev/input/event3 Preparation: Prepare the following device xml files # cat usbkbd.xml <input type='keyboard' bus='usb'/> # cat usbmouse.xml <input type='mouse' bus='usb'/> # cat usbtablet.xml <input type='tablet' bus='usb'/> # cat virtiokbd.xml <input type='keyboard' bus='virtio'/> # cat virtiomouse.xml <input type='mouse' bus='virtio'/> # cat virtiotablet.xml <input type='tablet' bus='virtio'/> # cat passthroughkbd.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> </input> # cat passthroughmouse.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> </input> Test scenarios Scenario-1: Hot-plug/unplug operation Step1. Prepare a running VM # virsh domstate pc running Step2. Hot-plug operation # for i in *; do virsh attach-device pc $i; done Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully # virsh dumpxml pc |grep input <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <alias name='input2'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <alias name='input3'/> </input> <input type='keyboard' bus='usb'> <alias name='input4'/> </input> <input type='mouse' bus='usb'> <alias name='input5'/> </input> <input type='tablet' bus='usb'> <alias name='input6'/> </input> <input type='keyboard' bus='virtio'> <alias name='input7'/> </input> <input type='mouse' bus='virtio'> <alias name='input8'/> </input> <input type='tablet' bus='virtio'> <alias name='input9'/> </input> Step3. Hot-unplug operation # for i in *; do virsh detach-device pc $i; done Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully # virsh dumpxml pc |grep input No output Scenario-2: Cold-plug/Hot-unplug operation Step1. Prepare a shutdown VM # virsh domstate pc shut off Step2. Cold-plug operation # for i in *; do virsh attach-device pc $i --config; done Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully Device attached successfully # virsh dumpxml pc --inactive|grep input <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> </input> <input type='keyboard' bus='usb'> </input> <input type='mouse' bus='usb'> </input> <input type='tablet' bus='usb'> </input> <input type='keyboard' bus='virtio'> </input> <input type='mouse' bus='virtio'> </input> <input type='tablet' bus='virtio'> </input> Step3. Start VM # virsh start pc Domain pc started # virsh domstate pc running # virsh dumpxml pc |grep input <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <alias name='input2'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <alias name='input3'/> </input> <input type='keyboard' bus='usb'> <alias name='input4'/> </input> <input type='mouse' bus='usb'> <alias name='input5'/> </input> <input type='tablet' bus='usb'> <alias name='input6'/> </input> <input type='keyboard' bus='virtio'> <alias name='input7'/> </input> <input type='mouse' bus='virtio'> <alias name='input8'/> </input> <input type='tablet' bus='virtio'> <alias name='input9'/> </input> # ps -ef |grep pc |sed 's/-device/\n-device/g' -device virtio-input-host-pci,id=input2,evdev=/dev/input/event2,bus=pci.0,addr=0xa -device virtio-input-host-pci,id=input3,evdev=/dev/input/event3,bus=pci.0,addr=0xb -device usb-kbd,id=input4,bus=ua-usb.0,port=3 -device usb-mouse,id=input5,bus=ua-usb.0,port=4 -device usb-tablet,id=input6,bus=ua-usb.0,port=5 -device virtio-keyboard-pci,id=input7,bus=pci.0,addr=0xc -device virtio-mouse-pci,id=input8,bus=pci.0,addr=0xd -device virtio-tablet-pci,id=input9,bus=pci.0,addr=0xe Step4. Hot-unplug operation # for i in *; do virsh detach-device pc $i ; done Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully Device detached successfully # virsh dumpxml pc |grep input No output All results are as expected, move this bug to be verified. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHEA-2018:0704 |