Bug 1759849

Summary: virsh domcapabilities incorrectly includes usb on s390x
Product: Red Hat Enterprise Linux 8 Reporter: smitterl
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: virt-qe-z
Severity: low Docs Contact:
Priority: low    
Version: 8.1CC: cohuck, dzheng, jdenemar, mprivozn, qzhang, rbalakri, smitterl, thuth, virt-maint, yalzhang
Target Milestone: rcKeywords: Upstream
Target Release: 8.3   
Hardware: s390x   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-6.0.0-17.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:53:03 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 smitterl 2019-10-09 09:19:44 UTC
Description of problem:
usb is not supported on platform but virsh domcapabilities lists it.

Version-Release number of selected component (if applicable):
libvirt-4.5.0-35.module+el8.1.0+4227+b2722cb3
qemu-kvm-2.12.0-88.module+el8.1.0+4233+bc44be3f


How reproducible:
Always


Steps to Reproduce:
1. 'virsh domcapabilities --virttype kvm --machine s390-ccw-virtio --arch s390x --emulatorbin /usr/libexec/qemu-kvm'

Actual results:
/domainCapabilities/devices/hostdev:
<hostdev supported='yes'>
...
      <enum name='subsysType'>
        <value>usb</value>
        <value>pci</value>
        <value>scsi</value>
      </enum>


Expected results:
/domainCapabilities/devices/hostdev:
<hostdev supported='yes'>
...
      <enum name='subsysType'>
        <value>pci</value>
        <value>scsi</value>
      </enum>

Comment 1 Cornelia Huck 2019-10-09 09:25:39 UTC
The base problem probably is that the machine accepts 'usb=on', even though usb is not supported on s390.

We may want to make it possible for the machine to disable usb support (it is already possible for things like parallel.)

Comment 2 smitterl 2019-10-15 07:46:57 UTC
domaincapabilities also returns
...
<graphics supported='yes'>
      <enum name='type'>
        <value>sdl</value>
        <value>vnc</value>
      </enum>
</graphics>
...

but defining machine fails starting with 'qemu-kvm: -sdl: SDL support is disabled'

Comment 3 Luiz Capitulino 2019-10-15 17:38:01 UTC
Talked to Cornelia about this BZ and, while it's nice to get this fixed,
our conclusion is that this is low-priority because there's nothing
impacted by the fact usb support shows up in virsh domcapabilities
(this is informational only).

Comment 4 Thomas Huth 2019-10-17 09:19:47 UTC
(In reply to Cornelia Huck from comment #1)
> The base problem probably is that the machine accepts 'usb=on', even though
> usb is not supported on s390.

Looking at src/qemu/qemu_capabilities.c in the libvirt sources, it rather seems like this is hard-coded in libvirt:

static int
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
                                       virDomainCapsDeviceHostdevPtr hostdev)
{
    [...]
    VIR_DOMAIN_CAPS_ENUM_SET(hostdev->subsysType,
                             VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
                             VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
                             VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI);
    [...]
}

I think libvirt should rather check for the availability of a USB host controller before setting the domain capability here, i.e. check for one of these QEMU capabilities:

    QEMU_CAPS_PIIX3_USB_UHCI, /* -device piix3-usb-uhci */
    QEMU_CAPS_PIIX4_USB_UHCI, /* -device piix4-usb-uhci */
    QEMU_CAPS_USB_EHCI, /* -device usb-ehci */
    QEMU_CAPS_ICH9_USB_EHCI1, /* -device ich9-usb-ehci1 and friends */
    QEMU_CAPS_VT82C686B_USB_UHCI, /* -device vt82c686b-usb-uhci */
    QEMU_CAPS_PCI_OHCI, /* -device pci-ohci */
    QEMU_CAPS_NEC_USB_XHCI, /* -device nec-usb-xhci */
    QEMU_CAPS_DEVICE_QEMU_XHCI, /* -device qemu-xhci */

Comment 5 Thomas Huth 2019-10-23 09:26:03 UTC
(In reply to smitterl from comment #2)
> domaincapabilities also returns
> ...
> <graphics supported='yes'>
>       <enum name='type'>
>         <value>sdl</value>
>         <value>vnc</value>
>       </enum>
> </graphics>
> ...
> 
> but defining machine fails starting with 'qemu-kvm: -sdl: SDL support is
> disabled'

Concerning the <graphics>, I think libvirt should use the "query-display-options" QMP command of QEMU to find out what graphic backends are available in QEMU (SDL currently seems to be hardcoded there, too)

Comment 6 Thomas Huth 2019-10-23 13:13:12 UTC
(In reply to Thomas Huth from comment #5)
> (In reply to smitterl from comment #2)
> > domaincapabilities also returns
> > ...
> > <graphics supported='yes'>
> >       <enum name='type'>
> >         <value>sdl</value>
> >         <value>vnc</value>
> >       </enum>
> > </graphics>
> > ...
> > 
> > but defining machine fails starting with 'qemu-kvm: -sdl: SDL support is
> > disabled'
> 
> Concerning the <graphics>, I think libvirt should use the
> "query-display-options" QMP command of QEMU to find out what graphic
> backends are available in QEMU

Ah, scratch that, this QMP command only provides information about the current display option, but does not list the available ones.

Not sure whether there is a way to query this information in a proper way at all. Maybe this needs a new QMP command to be defined?

Comment 7 Michal Privoznik 2020-01-13 12:56:22 UTC
Patch proposed here:

https://www.redhat.com/archives/libvir-list/2020-January/msg00579.html

and pushed upstream as:

bfd5f69d60 qemu_capabilities: Do not report USB as subsystem type if it is not available

v6.0.0-rc1-16-gbfd5f69d60

Comment 8 Michal Privoznik 2020-01-13 13:42:49 UTC
Moving to POST per comment 7.

Comment 9 smitterl 2020-01-14 14:01:22 UTC
(In reply to smitterl from comment #2)
> domaincapabilities also returns
> ...
> <graphics supported='yes'>
>       <enum name='type'>
>         <value>sdl</value>
>         <value>vnc</value>
>       </enum>
> </graphics>
> ...
> 
> but defining machine fails starting with 'qemu-kvm: -sdl: SDL support is
> disabled'

Moved to separate bz https://bugzilla.redhat.com/show_bug.cgi?id=1790902

Comment 13 smitterl 2020-06-08 12:05:43 UTC
Verified with version:
libvirt-daemon-6.0.0-17.module+el8.3.0+6423+e4cb6418.s390x


# virsh domcapabilities --virttype kvm --machine s390-ccw-virtio --arch s390x --emulatorbin /usr/libexec/qemu-kvm && rpm -q libvirt-daemon
<domainCapabilities>
...
  <machine>s390-ccw-virtio-rhel8.2.0</machine>
  <arch>s390x</arch>
...
  <devices>
...
    <hostdev supported='yes'>
...
      <enum name='subsysType'>
        <value>pci</value>
        <value>scsi</value>
      </enum>
...
  </devices>
...
</domainCapabilities>

Comment 16 errata-xmlrpc 2020-11-04 02:53:03 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 (Moderate: virt:rhel and virt-devel:rhel security, 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/RHSA-2020:4676