Bug 1512934

Summary: Incorrect device used for <serial> with type usb-serial or pci-serial on pSeries
Product: Red Hat Enterprise Linux 7 Reporter: Andrea Bolognani <abologna>
Component: libvirtAssignee: Andrea Bolognani <abologna>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 7.5CC: abologna, dzheng, gsun, haizhao, junli, mtessun, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64le   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.9.0-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 11:00:58 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 Andrea Bolognani 2017-11-14 13:23:14 UTC
If a USB serial console is added to a pSeries guest with

  <serial type='pty'>
    <target type='usb-serial'/>
  </serial>

the missing attributes will be filled in by libvirt, resulting in

  <serial type='pty'>
    <target type='usb-serial' port='0'/>
    <address type='spapr-vio' reg='0x30000000'/>
  </serial>

which, in addition to not making any sense due to the mismatch in
device type and address type, will result in a spapr-vty device
being added to the QEMU command line instead of usb-serial. The
same happens for pci-serial.

libvirt should use the expected device instead, or error out if
the device is not compiled in the QEMU binary.

Comment 2 Andrea Bolognani 2017-11-15 11:54:00 UTC
Patches posted upstream.

  https://www.redhat.com/archives/libvir-list/2017-November/thread.html

Comment 3 Andrea Bolognani 2017-11-15 11:55:03 UTC
Wrong link :/

  https://www.redhat.com/archives/libvir-list/2017-November/msg00545.html

Comment 4 Andrea Bolognani 2017-11-28 15:27:16 UTC
Fixed upstream.

commit b342e94399eee7fd519234a12ca3ea04f6564154
Author: Andrea Bolognani <abologna>
Date:   Fri Nov 10 17:57:53 2017 +0100

    qemu: Support usb-serial and pci-serial on pSeries
    
    The existing implementation set the address type for all serial
    devices to spapr-vio, which made it impossible to use other devices
    such as usb-serial and pci-serial; moreover, some decisions were
    made based on the address type rather than the device type.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1512934
    
    Signed-off-by: Andrea Bolognani <abologna>
    Reviewed-by: Pavel Hrdina <phrdina>

v3.9.0-260-gb342e9439

Comment 7 Junxiang Li 2017-12-05 02:54:51 UTC
Env:
# rpm -q libvirt kernel qemu-kvm-rhev
libvirt-3.9.0-4.virtcov.el7.ppc64le
kernel-3.10.0-799.el7.ppc64le
qemu-kvm-rhev-2.10.0-10.el7.ppc64le

Add the following xml in guest:
<serial type='pty'>
    <target type='usb-serial'/>
</serial>

After define:
<serial type='pty'>
    <target type='usb-serial' port='0'>
        <model name='usb-serial'/>
    </target>
    <address type='usb' bus='0' port='3'/>
</serial>

When start:
error: Failed to start domain vm1
error: unsupported configuration: 'usb-serial' is not supported in this QEMU binary

BTW, the attribute 'model' is not generated before, so it is expected or a mistake?

Comment 8 Andrea Bolognani 2017-12-05 09:24:59 UTC
(In reply to junli from comment #7)
> Env:
> # rpm -q libvirt kernel qemu-kvm-rhev
> libvirt-3.9.0-4.virtcov.el7.ppc64le
> kernel-3.10.0-799.el7.ppc64le
> qemu-kvm-rhev-2.10.0-10.el7.ppc64le
> 
> Add the following xml in guest:
> <serial type='pty'>
>     <target type='usb-serial'/>
> </serial>
> 
> After define:
> <serial type='pty'>
>     <target type='usb-serial' port='0'>
>         <model name='usb-serial'/>
>     </target>
>     <address type='usb' bus='0' port='3'/>
> </serial>
> 
> When start:
> error: Failed to start domain vm1
> error: unsupported configuration: 'usb-serial' is not supported in this QEMU
> binary

Failure to start the guest when using either usb-serial or pci-serial
is expected, as we don't enable either device in RHEL. The bug has
been fixed, though, otherwise QEMU would complain about isa-serial
being unavailable.

> BTW, the attribute 'model' is not generated before, so it is expected or a
> mistake?

It's expected.

Comment 9 Junxiang Li 2017-12-06 08:40:30 UTC
1. prepare a guest vm:

<domain type='kvm' id='4'>
  <name>vm1</name>
  <uuid>3dcc6321-216a-4353-bb9b-75d1317d2bac</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='ppc64le' machine='pseries-rhel7.5.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/avocado/data/avocado-vt/images/jeos-25-64-clone.qcow2'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <interface type='bridge'>
      <mac address='52:54:00:1f:6b:8a'/>
      <source bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </interface>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-4-vm1/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='keyboard' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='usb'>
      <alias name='input1'/>
      <address type='usb' bus='0' port='2'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='vga' vram='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
    <panic model='pseries'/>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c158,c597</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c158,c597</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+107:+107</label>
    <imagelabel>+107:+107</imagelabel>
  </seclabel>
</domain>
2. Add the serial into the guest:

<serial type='pty'>
    <target type='usb-serial'/>
</serial>
***********************************
Reproduced on 
libvirt-3.9.0-3.virtcov.el7.ppc64le
kernel-3.10.0-799.el7.ppc64le
qemu-kvm-rhev-2.10.0-10.el7.ppc64le

3.1 Run "virsh create"
Domain vm1 created from vm1.xml
3.2 Run "virsh dumpxml"
<serial type='pty'>
  <source path='/dev/pts/2'/>
  <target type='usb-serial' port='0'/>
  <alias name='serial0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>

4.1 Run "virsh define"
Domain vm1 defined from vm1.xml
4.2 Run "virsh dumpxml"
<serial type='pty'>
  <target type='usb-serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>
4.3 Run "virsh start"
error: Failed to start domain vm1
error: unsupported configuration: usb-serial requires address of usb type
***********************************

Verified on 
libvirt-3.9.0-4.virtcov.el7.ppc64le
kernel-3.10.0-799.el7.ppc64le
qemu-kvm-rhev-2.10.0-10.el7.ppc64le

3.1 Run "virsh create"
error: Failed to create domain from vm1.xml
error: unsupported configuration: 'usb-serial' is not supported in this QEMU binary

4.1 Define the guest and run "virsh dumpxml"
<serial type='pty'>
    <target type='usb-serial' port='0'>
        <model name='usb-serial'/>
    </target>
    <address type='usb' bus='0' port='3'/>
</serial>
4.2 Run "virsh start"
error: Failed to start domain vm1
error: unsupported configuration: 'usb-serial' is not supported in this QEMU binary

It works as expected.

Comment 13 errata-xmlrpc 2018-04-10 11:00:58 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, 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/RHEA-2018:0704