Bug 986279

Summary: No /dev/hvc0 device in guest after do hot-unplug and hotplug virtconsole device
Product: Red Hat Enterprise Linux 6 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5CC: acathrow, amit.shah, bsarathy, chayang, flang, juzhang, mdeng, michen, mkenneth, qzhang, sluo, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-07-22 06:27:32 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 Sibiao Luo 2013-07-19 10:27:11 UTC
Description of problem:
boot guest with a virtconsole device via TCP or Unix socket, do hot-unplug virtconsole device and then hotplug it, but guest can not find /dev/hvc0 device, it reboot guest that this issue will gone. This issue maybe the kernel component issue.
BTW, do the same testing with virtservice that have no such issue, it can work well with /dev/vport*.

Version-Release number of selected component (if applicable):
host info:
kernel-2.6.32-398.el6.x86_64
qemu-kvm-0.12.1.2-2.378.el6.x86_64
guest info:
kernel-2.6.32-398.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot guest with a virtconsole device via TCP or Unix socket.
e.g:...-device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev socket,id=foo,path=/tmp/foo,server,nowait -device virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
2.guest]# cat /dev/hvc0
3.do hot-unplug virtconsole device and then hotplug it.
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
4.guest]# cat /dev/hvc0

Actual results:
after step 4, it will prompt that no /dev/hvc0 device.
# cat /dev/hvc0
cat: /dev/hvc0: No such device

Expected results:
it can work well in guest again without any error.

Additional info:
# /usr/libexec/qemu-kvm -S -M rhel6.5.0 -cpu SandyBridge -enable-kvm -m 4096 -smp 4,sockets=2,cores=2,threads=1 -no-kvm-pit-reinjection -name sluo -uuid 43425b70-86e5-4664-bf2c-3b76699b8bec -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x3 -chardev socket,id=foo,path=/tmp/foo,server,nowait -device virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1 -drive file=/home/RHEL6.5-20130712.n.0-6.5-Server-x64.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial="QEMU-DISK1" -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-system-disk,id=system-disk,bootindex=1 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x5 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=2C:41:38:B6:40:21,bus=pci.0,addr=0x6,bootindex=2 -drive file=/home/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial="QEMU-DISK2" -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-data-disk,id=data-disk,bootindex=3 -k en-us -boot menu=on -qmp tcp:0:4444,server,nowait -vnc :1 -spice port=5931,disable-ticketing -monitor stdio

Comment 1 Amit Shah 2013-07-19 10:51:05 UTC
It should appear as /dev/hvc1.

Comment 2 Sibiao Luo 2013-07-22 02:25:54 UTC
(In reply to Amit Shah from comment #1)
> It should appear as /dev/hvc1.
yes, after first hotunplug and hotplug again, it appear as /dev/hvc1, not /dev/hvc0. I also tried second hotunplug and hotplug, it appear as /dev/hvc2.

Amit, should it return back to the origin port ? You can close it if not.

Best Regards,
sluo

Comment 3 Amit Shah 2013-07-22 06:27:32 UTC
Yes, that is the intended behaviour.

Comment 4 Sibiao Luo 2013-07-22 06:47:48 UTC
(In reply to Amit Shah from comment #3)
> Yes, that is the intended behaviour.

Amit, but i still curious about it, iirc, the virtio-blk device after hotunplug and hotplug which can return back to the same device id /dev/vd*. And if that is the intended behaviour, how about i do hotunplug and hotplug repeatly(more than 7 times), it should return back to /dev/hvc0 or just the max number is 7 for hotunplug and hotplug ? It can't work well after i do 8 times hotunplug and hotplug any more according my testing.

(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) device_del port1
(qemu) device_add virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,id=port1,nr=1
(qemu) 

guest ]# cat /dev/hvc0
^C
guest ]# cat /dev/hvc1
^C
guest ]# 
guest ]# cat /dev/hvc2
^C
guest ]# cat /dev/hvc3
^C
guest ]# cat /dev/hvc4
^C
guest ]# cat /dev/hvc5
^C
guest ]# cat /dev/hvc6
^C
guest ]# cat /dev/hvc7
^C
guest ]# cat /dev/hvc0
cat: /dev/hvc0: No such device
guest ]# cat /dev/hvc8
cat: /dev/hvc8: No such file or directory
guest ]# ls -lh /dev/hvc*
crw-rw----. 1 root dialout 229, 0 Jul 22 22:36 /dev/hvc0
crw-rw----. 1 root dialout 229, 1 Jul 22 22:36 /dev/hvc1
crw-rw----. 1 root dialout 229, 2 Jul 22 22:36 /dev/hvc2
crw-rw----. 1 root dialout 229, 3 Jul 22 22:36 /dev/hvc3
crw-rw----. 1 root dialout 229, 4 Jul 22 22:36 /dev/hvc4
crw-rw----. 1 root dialout 229, 5 Jul 22 22:36 /dev/hvc5
crw-rw----. 1 root dialout 229, 6 Jul 22 22:36 /dev/hvc6
crw-rw----. 1 root dialout 229, 7 Jul 22 22:36 /dev/hvc7

Best Regards,
sluo

Comment 5 Min Deng 2013-07-22 06:53:02 UTC
Hi Amit.
   (In reply to Sibiao Luo from comment #4)
> (In reply to Amit Shah from comment #3)
> > Yes, that is the intended behaviour.
> 
> Amit, but i still curious about it, iirc, the virtio-blk device after
> hotunplug and hotplug which can return back to the same device id /dev/vd*.
> And if that is the intended behaviour, how about i do hotunplug and hotplug
> repeatly(more than 7 times), it should return back to /dev/hvc0 or just the
> max number is 7 for hotunplug and hotplug ? It can't work well after i do 8
> times hotunplug and hotplug any more according my testing.
> 
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) 
> 
> guest ]# cat /dev/hvc0
> ^C
> guest ]# cat /dev/hvc1
> ^C
> guest ]# 
> guest ]# cat /dev/hvc2
> ^C
> guest ]# cat /dev/hvc3
> ^C
> guest ]# cat /dev/hvc4
> ^C
> guest ]# cat /dev/hvc5
> ^C
> guest ]# cat /dev/hvc6
> ^C
> guest ]# cat /dev/hvc7
> ^C
> guest ]# cat /dev/hvc0
> cat: /dev/hvc0: No such device
> guest ]# cat /dev/hvc8
> cat: /dev/hvc8: No such file or directory
> guest ]# ls -lh /dev/hvc*
> crw-rw----. 1 root dialout 229, 0 Jul 22 22:36 /dev/hvc0
> crw-rw----. 1 root dialout 229, 1 Jul 22 22:36 /dev/hvc1
> crw-rw----. 1 root dialout 229, 2 Jul 22 22:36 /dev/hvc2
> crw-rw----. 1 root dialout 229, 3 Jul 22 22:36 /dev/hvc3
> crw-rw----. 1 root dialout 229, 4 Jul 22 22:36 /dev/hvc4
> crw-rw----. 1 root dialout 229, 5 Jul 22 22:36 /dev/hvc5
> crw-rw----. 1 root dialout 229, 6 Jul 22 22:36 /dev/hvc6
> crw-rw----. 1 root dialout 229, 7 Jul 22 22:36 /dev/hvc7
> 
> Best Regards,
> sluo

Hi Amit,
   Thanks for you time,could you have a look on the above comments,it seems that there isn't enough device in guest to support multiple hotplug&hotunplug (max number is 7),Could you double check it ? Thanks in advance.Any issues please let me know.
Best Regards,
Min

Comment 6 Sibiao Luo 2013-07-22 06:55:14 UTC
(In reply to Sibiao Luo from comment #4)
> (In reply to Amit Shah from comment #3)
> > Yes, that is the intended behaviour.
> 
> Amit, but i still curious about it, iirc, the virtio-blk device after
> hotunplug and hotplug which can return back to the same device id /dev/vd*.
> And if that is the intended behaviour, how about i do hotunplug and hotplug
> repeatly(more than 7 times), it should return back to /dev/hvc0 or just the
> max number is 7 for hotunplug and hotplug ? It can't work well after i do 8
> times hotunplug and hotplug any more according my testing.
> 
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) device_del port1
> (qemu) device_add
> virtconsole,chardev=foo,name=com.redhat.rhevm.vdsm.1,bus=virtio-serial0.0,
> id=port1,nr=1
> (qemu) 
> 
> guest ]# cat /dev/hvc0
> ^C
> guest ]# cat /dev/hvc1
> ^C
> guest ]# 
> guest ]# cat /dev/hvc2
> ^C
> guest ]# cat /dev/hvc3
> ^C
> guest ]# cat /dev/hvc4
> ^C
> guest ]# cat /dev/hvc5
> ^C
> guest ]# cat /dev/hvc6
> ^C
> guest ]# cat /dev/hvc7
> ^C
> guest ]# cat /dev/hvc0
> cat: /dev/hvc0: No such device
> guest ]# cat /dev/hvc8
> cat: /dev/hvc8: No such file or directory
guest ]# cat /dev/hvc0
cat: /dev/hvc0: No such device
guest ]# cat /dev/hvc1
cat: /dev/hvc1: No such device
guest ]# cat /dev/hvc2
cat: /dev/hvc2: No such device
guest ]# cat /dev/hvc3
cat: /dev/hvc3: No such device
guest ]# cat /dev/hvc4
cat: /dev/hvc4: No such device
guest ]# cat /dev/hvc5
cat: /dev/hvc5: No such device
guest ]# cat /dev/hvc6
cat: /dev/hvc6: No such device
guest ]# cat /dev/hvc7
cat: /dev/hvc7: No such device
guest ]# cat /dev/hvc8
cat: /dev/hvc8: No such file or directory
> guest ]# ls -lh /dev/hvc*
> crw-rw----. 1 root dialout 229, 0 Jul 22 22:36 /dev/hvc0
> crw-rw----. 1 root dialout 229, 1 Jul 22 22:36 /dev/hvc1
> crw-rw----. 1 root dialout 229, 2 Jul 22 22:36 /dev/hvc2
> crw-rw----. 1 root dialout 229, 3 Jul 22 22:36 /dev/hvc3
> crw-rw----. 1 root dialout 229, 4 Jul 22 22:36 /dev/hvc4
> crw-rw----. 1 root dialout 229, 5 Jul 22 22:36 /dev/hvc5
> crw-rw----. 1 root dialout 229, 6 Jul 22 22:36 /dev/hvc6
> crw-rw----. 1 root dialout 229, 7 Jul 22 22:36 /dev/hvc7
> 
> Best Regards,
> sluo

Comment 7 Amit Shah 2013-07-22 07:50:38 UTC
(In reply to Sibiao Luo from comment #4)
> (In reply to Amit Shah from comment #3)
> > Yes, that is the intended behaviour.
> 
> Amit, but i still curious about it, iirc, the virtio-blk device after
> hotunplug and hotplug which can return back to the same device id /dev/vd*.

Yes, even virtio-serial will work that way.  However, console is different.

It's unfortunate that the same virtio_console.o module handles two completely different types of devices and functionality: console is handled via hvc, and serial (which is not really a serial port) is handled via virtio_console itself.  hvc is the module which allocates tty ports for virtio_console types of devices.

> And if that is the intended behaviour, how about i do hotunplug and hotplug
> repeatly(more than 7 times), it should return back to /dev/hvc0 or just the
> max number is 7 for hotunplug and hotplug ? It can't work well after i do 8
> times hotunplug and hotplug any more according my testing.

The limit is hard-coded in the kernel, and it is only 8.  Apparently, no one needs more serial consoles.  Also, no one does so many hot-plug/unplugs on them as well.  This is just a theoretical test that you're doing; thankfully, no one is going to do this in production :)

> guest ]# cat /dev/hvc0
> cat: /dev/hvc0: No such device
> guest ]# cat /dev/hvc8

Yes, once 8 ports have been used, it is supposed to re-use older ones, but there might be some bug.  However, this is unlikely to be fixed as (1) this is not something people will hit in regular use, and (2) console use-case is not the primary usage of the virtio_console module.

Comment 8 Sibiao Luo 2013-07-22 08:55:24 UTC
(In reply to Amit Shah from comment #7)
> (In reply to Sibiao Luo from comment #4)
> > (In reply to Amit Shah from comment #3)
> > > Yes, that is the intended behaviour.
> > 
> > Amit, but i still curious about it, iirc, the virtio-blk device after
> > hotunplug and hotplug which can return back to the same device id /dev/vd*.
> 
> Yes, even virtio-serial will work that way.  However, console is different.
> 
> It's unfortunate that the same virtio_console.o module handles two
> completely different types of devices and functionality: console is handled
> via hvc, and serial (which is not really a serial port) is handled via
> virtio_console itself.  hvc is the module which allocates tty ports for
> virtio_console types of devices.
> 
> > And if that is the intended behaviour, how about i do hotunplug and hotplug
> > repeatly(more than 7 times), it should return back to /dev/hvc0 or just the
> > max number is 7 for hotunplug and hotplug ? It can't work well after i do 8
> > times hotunplug and hotplug any more according my testing.
> 
> The limit is hard-coded in the kernel, and it is only 8.  Apparently, no one
> needs more serial consoles.  Also, no one does so many hot-plug/unplugs on
> them as well.  This is just a theoretical test that you're doing;
> thankfully, no one is going to do this in production :)
> 
> > guest ]# cat /dev/hvc0
> > cat: /dev/hvc0: No such device
> > guest ]# cat /dev/hvc8
> 
> Yes, once 8 ports have been used, it is supposed to re-use older ones, but
> there might be some bug.  However, this is unlikely to be fixed as (1) this
> is not something people will hit in regular use, and (2) console use-case is
> not the primary usage of the virtio_console module.

ok, thanks for your detail explains. This is buggy in theory due to the limitation, but as you said in the bug, few people will do such operation and virtconsole is in low priority. So, I suggest to close it as a wontfix bug, and I'd better make a notice into our TCMS or wiki page. 

Thanks & Best Regards,
sluo

Comment 9 Amit Shah 2013-07-22 09:07:52 UTC
(In reply to Sibiao Luo from comment #8)
> ok, thanks for your detail explains. This is buggy in theory due to the
> limitation, but as you said in the bug, few people will do such operation
> and virtconsole is in low priority. So, I suggest to close it as a wontfix
> bug, and I'd better make a notice into our TCMS or wiki page. 

At least the bug summary mentions the bug was due to /dev/hvc0 not found -- and that is not a bug, since it goes on to be active on /dev/hvc1.