Bug 1531470

Summary: virtio char devices should select an available virtio-serial address while hotplug and skip unavailable ones
Product: Red Hat Enterprise Linux 7 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED DUPLICATE QA Contact: Jing Qi <jinqi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: jinqi, jtomko, lmen, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-08 09:03: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 yalzhang@redhat.com 2018-01-05 08:48:33 UTC
Description of problem:
virtio char devices should select an available virtio-serial address while hotplug and skip unavailable ones

Version-Release number of selected component (if applicable):
libvirt-3.9.0-7.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare the xml for virtio channel and virtio console
# cat channel.xml 
<channel type='pty'> 
<target type='virtio'/>
</channel>

# cat console.xml
<console type='pty'>
      <target type='virtio'/>
    </console>

2. start a guest with below char devices:
# virsh start pc
# virsh dumpxml pc
...
<controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
...
<serial type='pty'>
      <source path='/dev/pts/1'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-78-pc/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
      <alias name='channel1'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
...

3. do hotplug for virtio console for 2 times
# virsh attach-device pc console.xml
Device attached successfully

# virsh attach-device pc console.xml
Device attached successfully

# virsh dumpxml pc
...
 <console type='pty'>
      <source path='/dev/pts/3'/>
      <target type='virtio' port='1'/>
      <alias name='console1'/>
    </console>
    <console type='pty'>
      <source path='/dev/pts/4'/>
      <target type='virtio' port='2'/>
      <alias name='console2'/>
    </console>
...

4. then do hotplug for the virtio channel
# virsh attach-device pc channel.xml 
error: Failed to attach device from channel.xml
error: internal error: unable to execute QEMU command 'device_add': virtio-serial-bus: A port already exists at id 3

Actual results:
In step 4, the hotplug failed as auto generated virtio-serial address is unavailable. It seems that in step 3, the 2nd virtio console will occupied the virtio-serial address(only attach one virtio console will not trigger this issue). Same issue in https://bugzilla.redhat.com/show_bug.cgi?id=1531466#c2

Expected results:
hotplug virtio channel should skip the unavailable virtio-serial address

Additional info:
current virtio console do not generate the virtio-console address, refer to "Bug 1447505 - Support virtio console devices generating virtio-serial address"

Comment 2 Ján Tomko 2018-06-08 09:03:03 UTC

*** This bug has been marked as a duplicate of bug 1447505 ***