Bug 770512

Summary: Virtio serial chardev will be still in use even failed to hot plug a serial port on it
Product: Red Hat Enterprise Linux 6 Reporter: Qunfang Zhang <qzhang>
Component: qemu-kvmAssignee: Amit Shah <amit.shah>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, amit.shah, bsarathy, juzhang, michen, mkenneth, tburke, virt-maint, wdai
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.226.el6 Doc Type: Bug Fix
Doc Text:
No documentation necessary
Story Points: ---
Clone Of:
: 923599 (view as bug list) Environment:
Last Closed: 2012-06-20 11:38:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 676568, 923599, 969799, 973038    

Description Qunfang Zhang 2011-12-27 07:31:30 UTC
Description of problem:
Hot plug a virtio serial port to a chardev but let it failed. For example, giving it a wrong "nr" value. But, the chardev will be still in use though no serial port is plugged on it. So the chardev can not be used.

Version-Release number of selected component (if applicable):
kernel-2.6.32-220.el6.x86_64
qemu-kvm-0.12.1.2-2.213.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Boot a guest with virtio serial bus and chardev but no serial port, for example:
/usr/libexec/qemu-kvm ....... -device virtio-serial-pci,id=virtio-serial0,max_ports=3,vectors=4,bus=pci.0,addr=0x5 -chardev socket,id=channel0,path=/var/lib/libvirt/qemu/rhel58.channel0,server,nowait -chardev socket,id=channel1,path=/var/lib/libvirt/qemu/rhel58.channel1,server,nowait

2. Hot plug a virtio serial port on the first chardev "channel0".
(qemu) device_add virtserialport,bus=virtio-serial0.0,nr=1,chardev=channel0,name=org.linux-kvm.port.0,id=port0

3. Hot plug another serial port on the second chardev "channel1" but with a wrong "nr" value to let it failed to plug.

(qemu) device_add virtserialport,bus=virtio-serial0.0,nr=1,chardev=channel1,name=org.linux-kvm.port.1,id=port1
virtio-serial-bus: A port already exists at id 1
Device 'virtserialport' could not be initialized

4. Hot plug the serial port again with correct "nr" value.
(qemu)  device_add virtserialport,bus=virtio-serial0.0,nr=2,chardev=channel1,name=org.linux-kvm.port.1,id=port1

  
Actual results:
After step4, can not hot plug the second serial port to the chardev. and (qemu)info qtree shows there's only 1 virtio serial port "port0" and chardev "channel0"

Expected results:
The second chardev "channel1" should NOT be used if actually failed to plug a serial port on it.

Additional info:

Comment 2 Qunfang Zhang 2011-12-27 07:34:55 UTC
After step 4 in the bug description, qemu monitor shows:

(qemu)  device_add virtserialport,bus=virtio-serial0.0,nr=2,chardev=channel1,name=org.linux-kvm.port.1,id=port1

Property 'virtserialport.chardev' can't take value 'channel1', it's in use

Comment 3 Amit Shah 2011-12-27 08:37:05 UTC
This is going to need the chardev hot-plug/unplug patches (Bug 676568).

Instead of closing as a dup, I'll let this bug remain open so that we test this scenario when that bug is closed.

Comment 4 Markus Armbruster 2012-01-13 07:54:48 UTC
This is a bug in the chardev - qdev connection code.

A typical use case for dynamic chardev - qdev connection is full hot plug/unplug of chardevs (bug 676568).

But other use cases exist.  For instance, you can unplug the qdev and reuse the same chardev for another qdev.

But currently a qdev initialization can fail in a way that leaves the chardev unusable for another qdev.  That's this bug.  It needs fixing regardless of chardev hot plug/unplug.

Thus, I'm reverting the dependency between this one and bug 676568: this one blocks bug 676568.

Comment 5 Amit Shah 2012-01-13 10:05:14 UTC
While testing, please also test the case in Bug 700512.  It should continue to remain fixed.  The fix in bug 700512 will be reverted for a generic fix, which will fix both these bugs.

Comment 11 daiwei 2012-02-14 06:52:15 UTC
Reproduced this issue with steps and environment as follows: 

# uname -r ;rpm -q qemu-kvm

2.6.32-220.el6.x86_64
qemu-kvm-0.12.1.2-2.209.el6_2.1.x86_64

1. Boot a guest with virtio serial bus and chardev but no serial port

2. Hot plug a virtio serial port on the first chardev "channel0"

3. Hot plug another serial port on the second chardev "channel1" but with a
wrong "nr" value to let it failed to plug.

(qemu) device_add
virtserialport,bus=virtio-serial0.0,nr=1,chardev=channel1,name=org.linux-kvm.port.1,id=port1
virtio-serial-bus: A port already exists at id 1
Device 'virtserialport' could not be initialized

4. Hot plug the serial port again with correct "nr" value.

after step 4,qemu monitor shows:
(qemu)  device_add
virtserialport,bus=virtio-serial0.0,nr=2,chardev=channel1,name=org.linux-kvm.port.1,id=port1

Property 'virtserialport.chardev' can't take value 'channel1', it's in use

(qemu)info qtree 
 shows there's only 1 virtio serial port "port0" and chardev
"channel0"


Verified this issue with steps and environment as follows:

# uname -r ;rpm -q qemu-kvm

2.6.32-220.el6.x86_64
qemu-kvm-0.12.1.2-2.226.el6.x86_64

redo above step1 ~ step4.
after step4, qemu monitor does not report an error.

(qemu) info qtree
.... 
bus: virtio-serial0.0
          type virtio-serial-bus
          dev: virtserialport, id "port1"
            dev-prop: chardev = channel1
            bus-prop: nr = 2
 bus-prop: name = "org.linux-kvm.port.1"
             dev-prop-int: id: 2
             dev-prop-int: guest_connected: 0
             dev-prop-int: host_connected: 0
             dev-prop-int: throttled: 0
          dev: virtserialport, id "port0"
            dev-prop: chardev = channel0
            bus-prop: nr = 1
            bus-prop: name = "org.linux-kvm.port.0"
             dev-prop-int: id: 1
             dev-prop-int: guest_connected: 0
             dev-prop-int: host_connected: 0
             dev-prop-int: throttled: 0
....

(qemu) info tree shows both <port0,channel0> and <port1,channel1>.

So,this bug had been fixed.

Comment 14 Amit Shah 2012-04-24 13:04:51 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No documentation necessary

Comment 15 errata-xmlrpc 2012-06-20 11:38:17 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.

http://rhn.redhat.com/errata/RHBA-2012-0746.html