Hide Forgot
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:
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
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.
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.
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.
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.
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
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