Description of problem: passthrough input device disappeared in the namespace when trying to attach the device to the guest twice Version-Release number of selected component (if applicable): libvirt-5.10.0-1.el8.x86_64 How reproducible: 100% Steps to Reproduce: 1.Prepare the passthrough input device xml: #cat input.xml <input type='passthrough' bus='virtio'> <source evdev='/dev/input/event1'/> </input> 2.Attach the input device to a guest: # virsh attach-device vm2 input.xml Device attached successfully 3.Check the input device in the qemu namespace: # nsenter -t `pidof qemu-kvm` -m ls -l /dev/input total 0 crw-rw----. 1 qemu qemu 13, 65 Dec 6 03:20 event1 4.Attach the input device to the same guest again: #virsh attach-device vm2 input.xml error: Failed to attach device from dev.xml error: internal error: unable to execute QEMU command 'device_add': /dev/input/event1: failed to get exclusive access: Device or resource bus 5.Check the input device in the qemu namespace: # nsenter -t `pidof qemu-kvm` -m ls -l /dev/input total 0 Actual results: passthrough input device disappeared in the namespace when trying to attach the device to the guest twice Expected results: passthrough input device should not disappeare in the namespace when trying to attach the device to the guest twice Additional info:
Patches proposed on the list: https://listman.redhat.com/archives/libvir-list/2021-July/msg00129.html
Merged upstream as: b0ef407c65 qemu: Check for existing file in namespace cbcde4df3b virprocess: Return retval of the child on success, not 0 c39757f700 qemu: Do not erase duplicate devices from namespace if error occurs v7.5.0-92-gc39757f700
Pre-verified on libvirt v7.6.0-rc1-8-gf5c022a389 according to Comment 0
Verify this bug with: libvirt-daemon-7.6.0-1.module+el8.5.0+12097+2c77910b.x86_64 Testing result matches with expected result, mark the bug as 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 (virt:av bug fix and enhancement update), 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/RHBA-2021:4684