Bug 1724928

Summary: Guest with 'passthrough' input device fails to start with '' is not a valid device model name
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Meina Li <meili>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Lili Zhu <lizhu>
Severity: unspecified Docs Contact:
Priority: low    
Version: 8.0CC: chhu, dyuan, fjin, jdenemar, jsuchane, jtomko, lizhu, xuzhang, yalzhang
Target Milestone: rc   
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-6.2.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-17 17:44:46 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:

Description Meina Li 2019-06-28 06:27:47 UTC
Description of problem:
Guest with 'passthrough' input device fails to start with '' is not a valid device model name

Version-Release number of selected component (if applicable):
kernel-4.18.0-80.el8.x86_64
qemu-kvm-3.1.0-27.module+el8.0.1+3253+c5371cb3.x86_64
libvirt-5.0.0-10.module+el8.0.1+3363+49e420ce.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a guest with 'passtthrough' input device.
# virsh edit guest
...
<input type='passthrough'>
    <source evdev='/dev/input/event1/>
</input>
...

2. Start guest and check the dumpxml.
# virsh start guest
error: Failed to start domain guest
error: internal error: qemu unexpectedly closed the monitor: 2019-06-28T06:14:14.894428Z qemu-kvm: -device ,bus=usb.0,port=4: '' is not a valid device model name

# virsh dumpxml lmn | grep input -B5
...
 <input type='passthrough' bus='usb'>
      <source evdev='/dev/input/event1'/>
      <address type='usb' bus='0' port='4'/>
 </input>

Actual results:
As step 2, the input device is automatically used with usb bus but start failed.

Expected results:
The guest start successfully. 
Or if usb bus does not support passthrough input device, it can give an error:usb bus does not support passthrough input device

Additional info:

Comment 1 Ján Tomko 2020-02-25 16:31:37 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2020-February/msg01017.html

Comment 2 Ján Tomko 2020-03-04 11:21:08 UTC
commit 59bc34a1d1dc317d84da81a19f4992856ac0fa8c
Author:     Ján Tomko <jtomko>
CommitDate: 2020-03-04 12:14:39 +0100

    conf: default to virtio bus for input passthrough
    
    Other buses are not supported.
    
    Signed-off-by: Ján Tomko <jtomko>
    Reviewed-by: Daniel Henrique Barboza <danielhb413>

commit 33bc3ffe545cb04b7f48cc3354c37d7ac5cc3ee0
Author:     Ján Tomko <jtomko>
CommitDate: 2020-03-04 12:14:38 +0100

    conf: only allow virtio bus for input passthrough
    
    Other buses are not supported.
    
    Signed-off-by: Ján Tomko <jtomko>
    https://bugzilla.redhat.com/show_bug.cgi?id=1724928
    Reviewed-by: Daniel Henrique Barboza <danielhb413>

git describe: v6.1.0-22-g59bc34a1d1

Comment 5 Lili Zhu 2020-07-20 11:39:49 UTC
Verify this bug with:
libvirt-daemon-6.5.0-1.module+el8.3.0+7323+d54bb644.x86_64

1. prepare a guest and edit the xml
# virsh edit avocado-vt-vm1
....
 <input type='passthrough' bus='ps2' >
      <source evdev='/dev/input/event1'/>
 </input>
....
or 
....
 <input type='passthrough' bus='usb' >
      <source evdev='/dev/input/event1'/>
 </input>
error: XML document failed to validate against schema: Unable to validate doc against /usr/share/libvirt/schemas/domain.rng
Extra element devices in interleave
Element domain failed to validate content

Failed. Try again? [y,n,i,f,?]: 

2. prepare a xml snippet with bus type usb or ps2
# cat pass.xml 
<input type='passthrough' bus='usb'>
      <source evdev='/dev/input/event1'/>
</input>

# virsh attach-device avocado-vt-vm1 pass.xml 
error: Failed to attach device from pass.xml
error: XML error: only bus 'virtio' is supported for 'passthrough' input devices

# cat pass.xml 
<input type='passthrough' bus='ps2'>
      <source evdev='/dev/input/event1'/>
 </input>

# virsh attach-device avocado-vt-vm1 pass.xml 
error: Failed to attach device from pass.xml
error: internal error: ps2 bus does not support passthrough input device

3. edit the xml, and set the bus type as virtio
# virsh edit avocado-vt-vm1
....
 <input type='passthrough' bus='virtio' >
      <source evdev='/dev/input/event1'/>
 </input>
....
Domain avocado-vt-vm1 XML configuration edited.

# virsh dumpxml avocado-vt-vm1 | grep "<input type='passthrough'" -A3
    <input type='passthrough' bus='virtio'>
      <source evdev='/dev/input/event1'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </input>

# virsh start avocado-vt-vm1
Domain avocado-vt-vm1 started

4. prepare a xml snippet with no bus type
]# cat pass.xml 
<input type='passthrough'>
      <source evdev='/dev/input/event1'/>
 </input>

5. attach the input device to guest
# virsh attach-device avocado-vt-vm1 pass.xml 
Device attached successfully

6. check the guest xml
# virsh dumpxml avocado-vt-vm1 |grep "<input type='passthrough'" -A4
    <input type='passthrough' bus='virtio'>
      <source evdev='/dev/input/event1'/>
      <alias name='input3'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </input>

The default bus type for input device is "virtio"

As the testing result matches with the expected ones, mark the bug as verified

Comment 8 errata-xmlrpc 2020-11-17 17:44:46 UTC
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:8.3 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-2020:5137