Bug 769142

Summary: Qemu-kvm core dumped when connecting to listening vnc with "reverse"
Product: Red Hat Enterprise Linux 6 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Gerd Hoffmann <kraxel>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, bcao, bsarathy, juzhang, kraxel, michen, minovotn, mkenneth, qzhang, rhod, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.237.el6 Doc Type: Bug Fix
Doc Text:
Cause: When using vnc reverse mode (qemu connects to vnc viewer instead of the other way around) the vnc server tried to access the display before initialization. Consequence: Guest core dumped Fix: Initialize display before using it. Result: Doesn't core dump
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 11:37:52 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:

Description Sibiao Luo 2011-12-20 02:56:30 UTC
Description of problem:
The command line parameter value of "reverse" should make qemu try to connect instead of waiting for incoming connections. But Qemu-kvm core dumped when connecting to the listening vnc.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm
2.6.32-220.el6.x86_64
qemu-kvm-0.12.1.2-2.210.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. launch a listening vnc on host A by:
$ vncviewer -listen 7000
2. launch qemu-kvm process and try to connect to the listening vnc on host B by:
... -vnc ${ip_of_host_A's}:7000,"reverse"
  
Actual results:
The Qemu-kvm core dumped when connecting to the listening vnc.
(gdb) bt
#0  vnc_refresh_server_surface (vd=0x2511010) at vnc.c:2321
#1  0x00000000004de22c in vnc_refresh (opaque=0x2511010) at vnc.c:2361
#2  0x00000000004de527 in vnc_init_timer (vd=0x2511010, csock=<value optimized out>) at vnc.c:2392
#3  vnc_connect (vd=0x2511010, csock=<value optimized out>) at vnc.c:2443
#4  0x00000000004de88b in vnc_display_open (ds=<value optimized out>, display=<value optimized out>) at vnc.c:2744
#5  0x000000000040d649 in main (argc=<value optimized out>, argv=<value optimized out>, envp=<value optimized out>) at /usr/src/debug/qemu-kvm-0.12.1.2/vl.c:6332
(gdb) q

Expected results:
The qemu connect instead of waiting for the listening vnc successfully.

Additional info:
processor	: 3
vendor_id	: GenuineIntel
cpu family	: 6
model		: 42
model name	: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
stepping	: 7
cpu MHz		: 1600.000
cache size	: 6144 KB
physical id	: 0
siblings	: 4
core id		: 3
cpu cores	: 4
apicid		: 6
initial apicid	: 6
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 x2apic popcnt aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid
bogomips	: 6185.15
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

Comment 2 juzhang 2011-12-20 03:18:19 UTC
Mark qa ack+,however,still have a question?what's the parameter "reverse" for?do
we must identify the client ip? for example -vnc $client ip:7000,"reverse",if
yes,in practice,it's a little difficult to know which client will be
connected.so,anybody can enlight me?

Comment 3 Gerd Hoffmann 2012-01-03 12:05:12 UTC
upstream 5db8378a7710df7899544004967597eb395418c2

Comment 5 Gerd Hoffmann 2012-02-17 10:11:41 UTC
patch posted.

Comment 9 Sibiao Luo 2012-03-08 03:05:56 UTC
I have reproduced this issue on qemu-kvm-0.12.1.2-2.236.el6.x86_64 and verified
this issue on qemu-kvm-0.12.1.2-2.237.el6.x86_64 with the same steps.

The result of reproduce is that the QEMU-kvm get Segmentation fault, and the details as following:
Program received signal SIGSEGV, Segmentation fault.
(gdb) bt
#0  vnc_refresh_server_surface (vd=0x7ffff92da010) at vnc.c:2321
#1  0x00007ffff7e9177c in vnc_refresh (opaque=0x7ffff92da010) at vnc.c:2361
#2  0x00007ffff7e91a8c in vnc_init_timer (vd=0x7ffff92da010, csock=<value optimized out>) at vnc.c:2392
#3  vnc_connect (vd=0x7ffff92da010, csock=<value optimized out>) at vnc.c:2443
#4  0x00007ffff7e91e0f in vnc_display_open (ds=<value optimized out>, display=<value optimized out>) at vnc.c:2744
#5  0x00007ffff7dfacd3 in main (argc=20, argv=<value optimized out>, envp=<value optimized out>) at /usr/src/debug/qemu-kvm-0.12.1.2/vl.c:6357
(gdb) q

The result of verify is that do not get any segmentation fault, and the guest boot up with QEMU connecting to the listening vnc successfully.

Above all, this issue has been fixed.

Comment 12 Michal Novotny 2012-05-04 09:31:43 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:
Cause:
[NEEDINFO: Gerd, could you please add this info?]

Consequence:
Guest core dumped

Fix:
[NEEDINFO: Gerd, could you please add this info?]

Result:
Doesn't core dump

Comment 13 Gerd Hoffmann 2012-05-04 09:57:37 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1,11 @@
 Cause:
-[NEEDINFO: Gerd, could you please add this info?]
+When using vnc reverse mode (qemu connects to vnc viewer instead of the other way around) the vnc server tried to access the display before initialization.
 
 Consequence:
 Guest core dumped
 
 Fix:
-[NEEDINFO: Gerd, could you please add this info?]
+Initialize display before using it.
 
 Result:
 Doesn't core dump

Comment 14 errata-xmlrpc 2012-06-20 11:37:52 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