Bug 1591151

Summary: coldplug allows source for all input devices
Product: Red Hat Enterprise Linux 7 Reporter: jiyan <jiyan>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED WONTFIX QA Contact: Lili Zhu <lizhu>
Severity: unspecified Docs Contact:
Priority: low    
Version: 7.6CC: dyuan, fjin, hhan, jdenemar, jiyan, jtomko, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1591240 (view as bug list) Environment:
Last Closed: 2019-04-03 11:34:10 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: 1591240    

Description jiyan 2018-06-14 07:43:23 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


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:

Comment 2 jiyan 2018-06-14 11:20:04 UTC
Sry for the loss of following info:
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%

Comment 3 Han Han 2018-07-11 06:00:42 UTC
Send a patch to upstream: https://www.redhat.com/archives/libvir-list/2018-July/msg00658.html

Comment 4 Ján Tomko 2018-08-21 12:34:12 UTC
v2: https://www.redhat.com/archives/libvir-list/2018-July/msg01753.html
Pushed 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 5 RHEL Program Management 2019-04-03 11:34:10 UTC
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.