RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1591240 - coldplug allows source for all input devices
Summary: coldplug allows source for all input devices
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: x86_64
OS: Linux
low
unspecified
Target Milestone: rc
: 8.0
Assignee: Ján Tomko
QA Contact: Lili Zhu
URL:
Whiteboard:
Depends On: 1591151
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-14 11:18 UTC by jiyan
Modified: 2020-11-09 06:26 UTC (History)
6 users (show)

Fixed In Version: libvirt-4.5.0-9.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1591151
Environment:
Last Closed: 2019-06-14 01:24:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description jiyan 2018-06-14 11:18:39 UTC
+++ This bug was initially created as a clone of Bug #1591151 +++

Same issue can be reproduced in RHEL-8
RHEL-8
qemu-kvm-2.12.0-11.el8+619+ba8f0855.1.x86_64
libvirt-3.10.0-2.el8+526+412dc3e0.x86_64
kernel-4.16.0-10.el8+5.x86_64

Description of problem:
coldplug allows source for all input devices

Version-Release number of selected component (if applicable):
RHEL-7.6
libvirt-4.4.0-2.el7.x86_64
kernel-3.10.0-902.el7.x86_64
qemu-kvm-rhev-2.12.0-3.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a shutdown VM with default input device
# virsh domstate test2
shut off

# virsh dumpxml test2 |grep "<input"
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>

2. Prepare a virtio.xml describing related input device
# cat /proc/bus/input/devices |grep  "I: Bus=0003 Vendor=17ef Product=6050 Version=0111" -A11
I: Bus=0003 Vendor=17ef Product=6050 Version=0111
N: Name="Lenovo Precision USB Mouse"
P: Phys=usb-0000:00:1d.0-1.7/input0
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.7/2-1.7:1.0/input/input3
U: Uniq=
H: Handlers=mouse0 event3 
B: PROP=0
B: EV=17
B: KEY=1f0000 0 0 0 0
B: REL=103
B: MSC=10

# cat virtio.xml 
    <input type='mouse' bus='virtio'>
      <source evdev='/dev/input/event3'/>  **illegal**
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </input>

3. Cold-unplug virtio.xml to VM
# virsh attach-device test2 virtio.xml --config
Device attached successfully

# virsh dumpxml test2 |grep "<input" -A3
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <input type='mouse' bus='virtio'>
      <source evdev='/dev/input/event3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </input>

4. Start VM
# virsh start test2
Domain test2 started

# virsh dumpxml test2 |grep "<input" -A4
    <input type='mouse' bus='ps2'>
      <alias name='input0'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='mouse' bus='virtio'>
      <source evdev='/dev/input/event3'/>
      <alias name='input2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </input>

# ps -ef |grep "test2" |sed 's/-device/\n-device/g'
-device virtio-mouse-pci,id=input2,bus=pci.0,addr=0x8 (No 'source' related info)

Actual results:
As Step-3 and Step-4 show

Expected results:
Extra illegal 'source' element should be detected when saving dumpxml file and be deleted.

Additional info:

--- Additional comment from Red Hat Bugzilla Rules Engine on 2018-06-14 03:43:35 EDT ---

Since this bug report was entered in Red Hat Bugzilla, the release flag has been set to ? to ensure that it is properly evaluated for this release.

Comment 1 Ján Tomko 2018-08-21 12:39:11 UTC
Pushed upstream as:
commit deb057fd364cb57614c6dea7b05c247231f9ae4f
Author:     Han Han <hhan>
AuthorDate: 2018-07-26 15:27:33 +0800
Commit:     John Ferlan <jferlan>
CommitDate: 2018-07-26 17:16:01 -0400

    conf: Add validation of input devices
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1591151
    
    Add function virDomainInputDefValidate to validate input devices.
    Make sure evdev attribute of source element is not used by mouse,
    keyboard, and tablet input device.
    
    Signed-off-by: Han Han <hhan>
    Reviewed-by: John Ferlan <jferlan>

git describe: v4.5.0-308-gdeb057fd36 contains: v4.6.0-rc1~49

Comment 4 Lili Zhu 2018-11-26 05:11:23 UTC
Verify this bug with:
libvirt-daemon-4.5.0-12.el8.x86_64
qemu-kvm-2.12.0-41.el8.x86_64

steps:
1) Check the input devices on the server 
# ll /dev/input/by-path/
total 0
lrwxrwxrwx. 1 root root 9 Oct 30 10:55 pci-0000:00:14.0-usb-0:2:1.0-event-kbd -> ../event2
lrwxrwxrwx. 1 root root 9 Nov 26 12:59 pci-0000:00:14.0-usb-0:4:1.0-event-mouse -> ../event3

2) prepare a input xml snippet with type "mouse".
# cat virtio.xml 
    <input type='mouse' bus='virtio'>
      <source evdev='/dev/input/event3'/>  
    </input>

3) coldplug virtio.xml to guest
# virsh attach-device avocado-vt-vm1 virtio.xml --config
error: Failed to attach device from virtio.xml
error: XML error: setting source evdev path only supported for passthrough input device

4)hotplug virtio.xml to guest
# virsh attach-device avocado-vt-vm1 virtio.xml --live
error: Failed to attach device from virtio.xml
error: XML error: setting source evdev path only supported for passthrough input devices

5) prepare a input xml snippet with type "keyboard".
# cat virtio.xml 
    <input type='keyboard' bus='virtio'>
      <source evdev='/dev/input/event2'/>  
    </input>


3) coldplug virtio.xml to guest
# virsh attach-device avocado-vt-vm1 virtio.xml --config
error: Failed to attach device from virtio.xml
error: XML error: setting source evdev path only supported for passthrough input device

4)hotplug virtio.xml to guest
# virsh attach-device avocado-vt-vm1 virtio.xml --live
error: Failed to attach device from virtio.xml
error: XML error: setting source evdev path only supported for passthrough input devices

I also tried other bus type, including "ps2" and "usb", when attach the xml to the guest, will return the same error message. 
As the results match with expected results, mark the bug as verified.


Note You need to log in before you can comment on or make changes to this bug.