Bug 1220195

Summary: Assign virtio-serial addresses after coldplugging a device
Product: Red Hat Enterprise Linux 7 Reporter: Hu Jianwei <jiahu>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.1CC: dyuan, honzhang, jtomko, mzhan, rbalakri, shyu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.16-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:30:24 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 Hu Jianwei 2015-05-11 01:33:01 UTC
Description of problem:
Assign virtio-serial addresses after coldplugging a device

Version-Release number of selected component (if applicable):
libvirt-1.2.15-1.el7.x86_64
qemu-kvm-rhev-2.3.0-1.el7.x86_64

How reproducible:
always

Steps to Reproduce:
[root@localhost ~]# cat channel.xml 
<channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.3'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
</channel>

[root@localhost ~]# virsh attach-device r71 channel.xml --config
Device attached successfully
[root@localhost ~]# vim channel.xml 
[root@localhost ~]# 
[root@localhost ~]# cat channel.xml 
<channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.4'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
</channel>

[root@localhost ~]# virsh attach-device r71 channel.xml --config
Device attached successfully

[root@localhost ~]# virsh dumpxml r71 | grep "</channel>" -B5
      <target type='serial' port='0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='2'/>
    </channel>
    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.1'/>
      <address type='virtio-serial' controller='0' bus='0' port='8'/>
    </channel>
    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.3'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
    </channel>
    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.4'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
    </channel>
[root@localhost ~]# virsh start r71
error: Failed to start domain r71
error: XML error: virtio serial port 4 on controller 0 is already occupied

Actual results:
I found a small issue, with "--config" option libvirt still can accept duplicated port for virtio channel devcies, but based on your patches in bug 1076708, the domain can not boot up normally, libvirt need a small patch to fix it.

Expected results:
Fix it

Additional info:

Comment 1 Hu Jianwei 2015-05-11 01:35:52 UTC
jtomko have sent a patch for the --config issue.
https://www.redhat.com/archives/libvir-list/2015-May/msg00184.html

Thanks for your patch.

Comment 4 Ján Tomko 2015-05-13 11:04:59 UTC
commit 083c33b3243da8ab266c0ff75b6abb217bcbf440
Author:     Ján Tomko <jtomko>
CommitDate: 2015-05-13 12:20:31 +0200

    Assign virtio-serial addresses after coldplugging a device
    
    Otherwise we might allow coldplugging a device
    that uses an address that is already occupied, creating
    an unstartable domain.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1220195

git describe: v1.2.15-72-g083c33b

Comment 7 Shanzhi Yu 2015-07-21 10:15:55 UTC
Verify this bug with libvirt-1.2.17-2.el7.x86_64

1. Prepare a shut off domain, with below in xml config

# virsh dumpxml r7|grep pty -A 4 
    <channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.3'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
    </channel>

2. Prepare below xml file

# cat ch.xml 
<channel type='pty'>
      <target type='virtio' name='org.linux-kvm.port.4'/>
      <address type='virtio-serial' controller='0' bus='0' port='4'/>
</channel>

3. Do cold-plug

# virsh attach-device r7 ch.xml --config
error: Failed to attach device from ch.xml
error: XML error: virtio serial port 4 on controller 0 is already occupied

Comment 9 errata-xmlrpc 2015-11-19 06:30:24 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://rhn.redhat.com/errata/RHBA-2015-2202.html