Bug 1511421

Summary: Incorrect <target type='isa-serial'/> for <serial> element of pSeries guests
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: dzheng, gsun, haizhao, junli, mtessun, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64   
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-09 10:18:44 UTC
If a serial console is added to a pSeries guest with

  <console type='pty'>
    <target type='serial'/>
  </console>

the <serial> element auto-generated by libvirt will look like

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

While the serial console will work thanks to workarounds present
in the code, isa-serial is clearly the incorrect type (pSeries
guests don't have an ISA bus) and a more appropriate type should
be used instead.

Comment 2 Andrea Bolognani 2017-11-15 11:53:21 UTC
Patches posted upstream.

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

Comment 3 Andrea Bolognani 2017-11-15 11:54:53 UTC
Wrong link :/

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

Comment 4 Andrea Bolognani 2017-11-28 15:26:25 UTC
Fixed upstream.

commit c498a8921e447715189c8c6d22b7ca24cc810830
Author: Andrea Bolognani <abologna>
Date:   Wed Nov 8 15:31:21 2017 +0100

    conf: Add target type and model for spapr-vty
    
    We can finally introduce a specific target model for the spapr-vty
    device used by pSeries guests, which means isa-serial will no longer
    show up to confuse users.
    
    We make sure migration works in both directions by interpreting the
    isa-serial target type, or the lack of target type, appropriately
    when parsing the guest XML, and skipping the newly-introduced type
    when formatting if for migration. We also verify that spapr-vty is
    not used for non-pSeries guests and add a bunch of test cases.
    
    This commit is best viewed with 'git show -w'.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511421
    
    Signed-off-by: Andrea Bolognani <abologna>
    Reviewed-by: Pavel Hrdina <phrdina>

v3.9.0-259-gc498a8921

Comment 7 Junxiang Li 2017-12-05 03:06:24 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

1. Add the following xml in guest:
  <console type='pty'>
    <target type='serial'/>
  </console>

2. After define:
    <serial type='pty'>
      <target type='spapr-vio-serial' port='0'>
        <model name='spapr-vty'/>
      </target>
      <address type='spapr-vio' reg='0x30000000'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
      <address type='spapr-vio' reg='0x30000000'/>
    </console>

3. Start successfully

Result: The target type change from 'isa-serial' to 'spapr-vio-serial'

Comment 8 Andrea Bolognani 2017-12-05 09:21:53 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
> 
> 1. Add the following xml in guest:
>   <console type='pty'>
>     <target type='serial'/>
>   </console>
> 
> 2. After define:
>     <serial type='pty'>
>       <target type='spapr-vio-serial' port='0'>
>         <model name='spapr-vty'/>
>       </target>
>       <address type='spapr-vio' reg='0x30000000'/>
>     </serial>
>     <console type='pty'>
>       <target type='serial' port='0'/>
>       <address type='spapr-vio' reg='0x30000000'/>
>     </console>
> 
> 3. Start successfully
> 
> Result: The target type change from 'isa-serial' to 'spapr-vio-serial'

You should also check that a guest which got the wrong target
type formatted in the past, eg.

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

gets parsed correctly and results in the same XML as above.

Comment 9 Junxiang Li 2017-12-06 08:58:14 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 console into the guest:

<console type='pty'>
  <target type='serial'/>
</console>
***********************************
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'>
  <target type='isa-serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</console>

4.1 Run "virsh define"
Domain vm1 defined from vm1.xml
4.2 Run "virsh dumpxml"
<serial type='pty'>
  <target type='isa-serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</console>
4.3 Run "virsh start"
Domain vm1 started
***********************************

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"
Domain vm1 created from vm1.xml
3.2 Run "virsh dumpxml"
<serial type='pty'>
  <target type='spapr-vio-serial' port='0'>
    <model name='spapr-vty'/>
  </target>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</console>

4.1 Run "virsh define"
Domain vm1 defined from vm1.xml
4.2 Run "virsh dumpxml"
<serial type='pty'>
  <target type='spapr-vio-serial' port='0'>
    <model name='spapr-vty'/>
  </target>
  <address type='spapr-vio' reg='0x30000000'/>
</serial>
<console type='pty'>
  <target type='serial' port='0'/>
  <address type='spapr-vio' reg='0x30000000'/>
</console>
4.3 Run "virsh start"
Domain vm1 started

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