Bug 1066239

Summary: Hotplug second virtioserialport failed after attached and detached virtconsole port
Product: Red Hat Enterprise Linux 7 Reporter: Min Deng <mdeng>
Component: qemu-kvm-rhevAssignee: Amit Shah <amit.shah>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: flang, hhuang, juzhang, knoel, mdeng, rbalakri, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu 2.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 09:44:18 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 Min Deng 2014-02-18 05:33:43 UTC
Description of problem:
Hotplug second virtioserialport failed after attached and detached virtconsole port

Version-Release number of selected component (if applicable):
kernel-3.10.0-88.el7.x86_64
qemu-kvm-rhev-1.5.3-47.el7.x86_64

How reproducible:
5 times


Steps to Reproduce:
1.boot up guest with the following CLI
  ...-machine pc-i440fx-rhel7.0.0,accel=kvm,usb=off -m 1024 -realtime mlock=off -smp 1,sockets=1,cores=1,threads=1 -uuid fbd227fb-06f6-42d8-aac4-b21232e05326 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=testabs,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/home/r7.img,if=none,id=drive-ide0-0-0,format=raw,cache=none -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -vga qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=67108864 -qmp tcp:0:4444,server,nowait -monitor stdio 
2.
2.1 Hot-plug 1st chardev 
2.2 Hot-plug virtconsole port
2.3 Hot-unplug virtconsole port
2.4 hot-unplug 1st chardev
2.5 Hot-plug 2nd chardev
2.6 Hot-plug virtserialport 
Actual results:
There's error message 
{"execute":"device_add","arguments":{"driver":"virtserialport","bus":"virtio-serial0.0","chardev":"chardev-two","name":"org.linux-kvm.port.1","id":"port1"}}
{"error": {"class": "GenericError", "desc": "Device initialization failed."}}

Expected results:
The port should be added to guest successfully.And it influenced other team so please go through it carefully,any issue please let me know.Thanks in advance.

Additional info:
Information from QMP
   telnet 10.66.10.127 4444
Trying 10.66.10.127...
Connected to 10.66.10.127.
Escape character is '^]'.
{"QMP": {"version": {"qemu": {"micro": 3, "minor": 5, "major": 1}, "package": " (qemu-kvm-1.5.3-30.el7)"}, "capabilities": []}}
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute": "chardev-add", "arguments": {"id": "chardev-pty", "backend": {"data": {}, "type": "pty"}}}   --*Add 1st chardev
{"return": {"pty": "/dev/pts/14"}}
{"execute":"device_add","arguments":{"driver":"virtconsole","bus":"virtio-serial0.0","chardev":"chardev-pty","name":"org.linux-kvm.port.0","id":"port0"}}
{"return": {}}  --*Add virtconsole port0
{"execute": "device_del", "arguments": {"id": "port0"}}  -- remove port0
{"timestamp": {"seconds": 1392692854, "microseconds": 644051}, "event": "DEVICE_DELETED", "data": {"device": "port0", "path": "/machine/peripheral/port0"}}
{"return": {}}
{"execute": "chardev-remove", "arguments": {"id": "chardev-pty"}} --*Remove chardev chardev-pty
{"return": {}}
{"execute": "chardev-add", "arguments": {"id": "chardev-two", "backend": {"data": {}, "type": "pty"}}}  --*Add new chardev named chardev-two
{"return": {"pty": "/dev/pts/14"}}
{"execute":"device_add","arguments":{"driver":"virtserialport","bus":"virtio-serial0.0","chardev":"chardev-two","name":"org.linux-kvm.port.1","id":"port1"}}
{"error": {"class": "GenericError", "desc": "Device initialization failed."}}
--*Add new virtserialport port1

Comment 1 Amit Shah 2014-02-20 10:18:47 UTC
Device init is failing, and there's not enough info why.  I can't see how this is related to virtio-serial; looks like the failure is happening in the qdev layer itself.  I suspect it could be due to some typo somewhere but it's not really easy to follow.

Can you try a few things:

1. How easily is this reproducible?  You've mentioned 5 times, but does it happen each time you try, or does it happen 5 out of 100 times?
2. Can you try via the hmp?

Comment 3 Min Deng 2014-02-24 05:48:10 UTC
(In reply to Amit Shah from comment #1)
> Device init is failing, and there's not enough info why.  I can't see how
> this is related to virtio-serial; looks like the failure is happening in the
> qdev layer itself.  I suspect it could be due to some typo somewhere but
> it's not really easy to follow.
> 
> Can you try a few things:
> 
> 1. How easily is this reproducible?  You've mentioned 5 times, but does it
> happen each time you try, or does it happen 5 out of 100 times?
> 2. Can you try via the hmp?

Hi Amit,

   Could you please go through my testing results,thank you very much.

For 1,100% reproducible if use my steps
For 2,QE got the following error message from HMP

1.#chardev-add backend=pty,id=chardev-pty

2.#device_add  virtconsole,bus=virtio-serial0.0,chardev=chardev-pty,name=org.linux-kvm.port.0,id=port0

3.#device_del  port0

4.#chardev-remove  chardev-pty

5.#chardev-add backend=pty,id=chardev-two

6.#device_add virtserialport,bus=virtio-serial0.0,chardev=chardev-two,name=org.linux-kvm.port.1,id=port1 
(This was original issue in the bug)

7.#device_add virtserialport,bus=virtio-serial0.0,chardev=chardev-two,name=org.linux-kvm.port.1,id=port1,nr=0 (Step 7's results was expected as it was reserved for virtconsole)

For do step6 without "nr" or step7 with "nr=0" get the following info from qemu
Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.
Device initialization failed.
Device 'virtserialport' could not be initialized

8.Change "nr=1" QE still failed to add port.I think it should be successfully here but it didn't.
#device_add virtserialport,bus=virtio-serial0.0,chardev=chardev-two,name=org.linux-kvm.port.1,id=port1,nr=1
The message was following as below and still failed to add port
virtio-serial-bus: A port already exists at id 1
Device initialization failed.
Device 'virtserialport' could not be initialized

9.After changing "nr=2" successfully added port1 from HMP.
#device_add virtserialport,bus=virtio-serial0.0,chardev=chardev-two,name=org.linux-kvm.port.1,id=port1,nr=2

Amit,any issues please let me know,thanks.

Best regards
Min Deng

Comment 6 Amit Shah 2014-07-14 11:29:17 UTC
Reduced testcase:

$ ./x86_64-softmmu/qemu-system-x86_64 -m 512 -cpu host -enable-kvm -device virtio-serial-pci -monitor stdio  -vnc :1
QEMU 2.0.91 monitor - type 'help' for more information
(qemu) device_add virtconsole,id=p1
(qemu) device_del p1
(qemu) device_add virtserialport,id=p1
Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.
Device 'virtserialport' could not be initialized
(qemu) quit

What's happening is hot-unplug of virtconsole removes the 'reserved' tag for port 0.

Comment 10 langfang 2014-09-01 04:49:29 UTC
Reproduce this bug as follow version:
Host:
# uname -r
3.10.0-144.el7.x86_64
# rpm -q qemu-kvm-rhev
qemu-kvm-rhev-1.5.3-30.el7.x86_64

Guest :rhel7

Steps:
1.Boot guest 
...-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5...

2.Hotadd chardev and virtio console
...
{"execute": "chardev-add", "arguments": {"id": "chardev-pty", "backend": {"data": {}, "type": "pty"}}}
{"return": {"pty": "/dev/pts/1"}}

{"execute":"device_add","arguments":{"driver":"virtconsole","bus":"virtio-serial0.0","chardev":"chardev-pty","name":"org.linux-kvm.port.0","id":"port0"}}
{"return": {}}
...

3.Hotunplug  virtio console and chardev
...
{"execute": "device_del", "arguments": {"id": "port0"}} 
{"timestamp": {"seconds": 1409538647, "microseconds": 669236}, "event": "DEVICE_DELETED", "data": {"device": "port0", "path": "/machine/peripheral/port0"}}
{"return": {}}

{"execute": "chardev-remove", "arguments": {"id": "chardev-pty"}}
{"return": {}}

4.Hotadd chardev and virtio console

After step 4
..
{"execute": "chardev-add", "arguments": {"id": "chardev-two", "backend": {"data": {}, "type": "pty"}}}
{"return": {"pty": "/dev/pts/1"}}

{"execute":"device_add","arguments":{"driver":"virtserialport","bus":"virtio-serial0.0","chardev":"chardev-two","name":"org.linux-kvm.port.1","id":"port1"}}
{"error": {"class": "GenericError", "desc": "Device initialization failed."}}


Verify this bug as follow version:
# uname -r
3.10.0-144.el7.x86_64
# rpm -q qemu-kvm-rhev
qemu-kvm-rhev-2.1.0-3.el7.x86_64

Guest :rhel7

Steps as same as reproduce

Resutls:

After step 4
...
{"execute": "chardev-add", "arguments": {"id": "chardev-two", "backend": {"data": {}, "type": "pty"}}}
{"return": {"pty": "/dev/pts/3"}}
{"execute":"device_add","arguments":{"driver":"virtserialport","bus":"virtio-serial0.0","chardev":"chardev-two","name":"org.linux-kvm.port.1","id":"port1"}}
{"return": {}}


According to above test ,this bug fixed.

Comment 13 errata-xmlrpc 2015-03-05 09:44:18 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/RHSA-2015-0624.html