Bug 1509866
Summary: | Couldn't open event file when execute device_add for virtio-input-host-pci | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Han Han <hhan> |
Component: | libvirt | Assignee: | Ján Tomko <jtomko> |
Status: | CLOSED ERRATA | QA Contact: | jiyan <jiyan> |
Severity: | high | Docs Contact: | |
Priority: | medium | ||
Version: | 7.5 | CC: | dyuan, fjin, hhan, jiyan, jtomko, juzhang, knoel, kraxel, mtessun, rbalakri, virt-maint, xuzhang, zpeng |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-3.9.0-4.el7 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-04-10 10:59:09 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: | |||
Bug Blocks: | 1379603 |
Description
Han Han
2017-11-06 09:06:39 UTC
Block the test scenario of hotplug/hotunplug on virtio input passthrough devices in BZ1379603 > 3. Try to use device_add to attach the input device to VM: > # virsh qemu-monitor-command V-raw > '{"execute":"device_add","arguments":{"driver":"virtio-input-host-pci","id": > "input5","evdev":"/dev/input/event2","bus":"pci.0","addr":"0xe"}}' > {"id":"libvirt-28","error":{"class":"GenericError","desc":"Could not open > '/dev/input/event2': No such file or directory"}} This is not going to work without proper libvirt support. Libvirt must add /dev/input/event2 to the devices cgroup and adjust the svirt labels, simliar to how it is done for usb-host device files. Otherwise qemu-kvm will not be allowed to access it. So, in theory, when you use a libvirt build which has bug 1379603 fixed and you are using "virsh attach-device ..." instead of "virsh qemu-monitor-command" everything should work just fine. Please retest. If this is just about the libvirt use case, I forgot to add labelling and cgroup device whitelisting to the hotplug code path. Unless this is reproducible with the same label as libvirt applies to the device on domain startup and with the evdev device listed in devices.allow (cgroup_device_acl in qemu.conf), I'd happily take the bug and move it to libvirt. (In reply to Ján Tomko from comment #4) > If this is just about the libvirt use case, I forgot to add labelling and > cgroup device whitelisting to the hotplug code path. Well, at least report is about libvirt, and without labeling and cgroup whitelisting it has no chance to work. > Unless this is reproducible with the same label as libvirt applies to the > device on domain startup and with the evdev device listed in devices.allow > (cgroup_device_acl in qemu.conf), I'd happily take the bug and move it to > libvirt. Done. (In reply to Gerd Hoffmann from comment #3) > > 3. Try to use device_add to attach the input device to VM: > > # virsh qemu-monitor-command V-raw > > '{"execute":"device_add","arguments":{"driver":"virtio-input-host-pci","id": > > "input5","evdev":"/dev/input/event2","bus":"pci.0","addr":"0xe"}}' > > {"id":"libvirt-28","error":{"class":"GenericError","desc":"Could not open > > '/dev/input/event2': No such file or directory"}} > > This is not going to work without proper libvirt support. Libvirt must add > /dev/input/event2 to the devices cgroup and adjust the svirt labels, simliar > to how it is done for usb-host device files. Otherwise qemu-kvm will not be > allowed to access it. > > So, in theory, when you use a libvirt build which has bug 1379603 fixed and > you are using "virsh attach-device ..." instead of "virsh > qemu-monitor-command" everything should work just fine. Please retest. This bug also reproduced on libvirt-3.9.0-1.el7.x86_64 qemu-kvm-rhev-2.10.0-4.el7.x86_64 # cat /tmp/virtio-passthrough.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> </input> # virsh list Id Name State ---------------------------------------------------- 4 V running # virsh attach-device V /tmp/virtio-passthrough.xml error: Failed to attach device from /tmp/virtio-passthrough.xml error: internal error: unable to execute QEMU command 'device_add': Could not open '/dev/input/event2': No such file or directory > > So, in theory, when you use a libvirt build which has bug 1379603 fixed and > > you are using "virsh attach-device ..." instead of "virsh > > qemu-monitor-command" everything should work just fine. Please retest. > > This bug also reproduced on libvirt-3.9.0-1.el7.x86_64 > qemu-kvm-rhev-2.10.0-4.el7.x86_64 Yes, as Jan wrote in comment 4 the libvirt patch is incomplete. Upstream patches: https://www.redhat.com/archives/libvir-list/2017-November/msg00821.html Hi, Ján. When verifying this bug, it is found that attaching virtio input device will fail at the second time after restarting libvirtd service. Could you please check whether it is normal? thanks in advance. The following are the detailed steps: Test Components' Version qemu-kvm-rhev-2.10.0-9.el7.x86_64 libvirt-3.9.0-4.el7.x86_64 kernel-3.10.0-799.el7.x86_64 Test Scenarios: Step1. Prepare a VM running in the physical host with mouse input device plugged in, check the state of VM and info of input device # virsh domstate pc running # virsh dumpxml pc |grep "<input type='passthrough' bus='virtio'>" -A4 No output # cat /proc/bus/input/devices |grep "I: Bus=0003 Vendor=03f0 Product=094a Version=0111" -A11 I: Bus=0003 Vendor=03f0 Product=094a Version=0111 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/input16 U: Uniq= H: Handlers=mouse0 event9 B: PROP=0 B: EV=17 B: KEY=ff0000 0 0 0 0 B: REL=103 B: MSC=10 # ll /dev/input/event9 crw-rw----. 1 root input 13, 73 Dec 4 17:18 /dev/input/event9 Step2. Prepare the following XML file used to hot-plug virtio input device to VM, then hot-plug and hot-unplug input device, during the process, check the VM dumpxml file # cat virtiomouse.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event9'/> </input> # virsh attach-device pc virtiomouse.xml Device attached successfully # virsh dumpxml pc |grep "<input type='passthrough' bus='virtio'>" -A4 <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event9'/> <alias name='input2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </input> # virsh detach-device pc virtiomouse.xml Device detached successfully # virsh dumpxml pc |grep "<input type='passthrough' bus='virtio'>" -A4 No output Step3. Check the mouse input device again and restart libvirtd service # cat /proc/bus/input/devices |grep "I: Bus=0003 Vendor=03f0 Product=094a Version=0111" -A11 I: Bus=0003 Vendor=03f0 Product=094a Version=0111 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/input20 U: Uniq= H: Handlers=mouse0 event9 B: PROP=0 B: EV=17 B: KEY=ff0000 0 0 0 0 B: REL=103 B: MSC=10 # ll /dev/input/event9 crw-rw----. 1 root input 13, 73 Dec 4 17:18 /dev/input/event9 # systemctl restart libvirtd # systemctl status libvirtd ● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2017-12-04 17:20:52 CST; 5s ago Step4. Hot-plug mouse input device again # virsh attach-device pc virtiomouse.xml error: Failed to attach device from virtiomouse.xml error: internal error: unable to execute QEMU command 'device_add': Bus 'pci' not found Hi jiyan Please see this bug for the "Bus 'pci' not found" issue: Bug 1518148 - Fail to attach interface after libvirtd restart 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 scenarios Preparation: Physical host with USB keyboard and mouse plugged in, and check 'event' info of them and prepare xml file according to the 'event' info # 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 # cat virtiokbd.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> </input> # cat virtiomouse.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> </input> Scenario1. Hot-plug/unplug virtio input device without restarting libvirtd service Step1. Prepare a running VM # virsh domstate pc running Step2. Hot-plug operation # virsh attach-device pc virtiokbd.xml Device attached successfully # virsh attach-device pc virtiomouse.xml Device attached successfully # virsh dumpxml pc |grep passthrough -A4 <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <alias name='input2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <alias name='input3'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </input> Step3. Hot-unplug operation # virsh detach-device pc virtiokbd.xml Device detached successfully # virsh detach-device pc virtiomouse.xml Device detached successfully # virsh dumpxml pc |grep passthrough -A3 No output Scenario2. Hot-plug/unplug virtio input device with restarting libvirtd service during the process Step1. Prepare a running VM # virsh domstate pc running Step2. Hot-plug operation # virsh attach-device pc virtiokbd.xml Device attached successfully # virsh attach-device pc virtiomouse.xml Device attached successfully # virsh dumpxml pc |grep passthrough -A4 <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <alias name='input2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <alias name='input3'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </input> Step3. Restart libvirtd and check the status of libvirtd # systemctl restart libvirtd # systemctl status libvirtd ● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2017-12-06 15:38:57 CST; 6s ago Step4. Hot-unplug operation # virsh detach-device pc virtiokbd.xml Device detached successfully # virsh detach-device pc virtiomouse.xml Device detached successfully # virsh dumpxml pc |grep passthrough -A4 No output Scenario3. Cold-plug/hot-unplug operation Step1. Prepare a shutdown VM # virsh domstate pc shut off Step2. Cold-plug operation # virsh attach-device pc virtiokbd.xml --config Device attached successfully # virsh attach-device pc virtiomouse.xml --config Device attached successfully # virsh dumpxml pc --inactive |grep passthrough -A4 <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </input> Step3. Start VM then check dumpxml file and qemu cmd line # virsh start pc Domain pc started # virsh dumpxml pc |grep passthrough -A4 <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event2'/> <alias name='input2'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </input> <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event3'/> <alias name='input3'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </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 Step4. Hot-unplug operation # virsh detach-device pc virtiokbd.xml Device detached successfully # virsh detach-device pc virtiomouse.xml Device detached successfully # virsh dumpxml pc |grep passthrough -A4 No output All the 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 |