Bug 1271519 - Error message "Unable to connect to the graphic server 127.0.0.1:xxxx" pops up
Error message "Unable to connect to the graphic server 127.0.0.1:xxxx" pops up
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: virt-viewer (Show other bugs)
7.2
x86_64 Unspecified
medium Severity medium
: rc
: 7.3
Assigned To: Virt Viewer Maint
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-14 04:17 EDT by xiaodwan
Modified: 2016-11-03 21:11 EDT (History)
11 users (show)

See Also:
Fixed In Version: virt-viewer-2.0-7.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-03 21:11:47 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
error message box (178.11 KB, image/png)
2015-10-14 04:17 EDT, xiaodwan
no flags Details
virt-viewer connect to guest successfully (34.04 KB, text/plain)
2015-10-14 04:18 EDT, xiaodwan
no flags Details
virt-vewer connect to guest failure (12.47 KB, text/plain)
2015-10-14 04:19 EDT, xiaodwan
no flags Details

  None (edit)
Description xiaodwan 2015-10-14 04:17:29 EDT
Created attachment 1082727 [details]
error message box

Description of problem:
Error message "Unable to connect to the graphic server 127.0.0.1:xxxx" pops up.

Version-Release number of selected component (if applicable):
virt-viewer-2.0-6.el7.x86_64
libvirt-1.2.17-13.el7.x86_64

How reproducible:
80%

Steps to Reproduce:
1. Use virt-viewer connect to a shutdown guest.
# G_MESSAGES_DEBUG=all virt-viewer rhel7.2-0924 --wait

2. Stop libvirtd service on host.
# service libvirtd stop

3. Start libvirtd service on host again.
# service libvirtd start
4. Start the guest.

Actual results:
Error message "Unable to connect to the graphic server 127.0.0.1:xxxx" pops up.

Expected results:
virt-viewer should connect to the guest correctly.

Additional info:
I attached the debug logs for both success and failure.
Comment 1 xiaodwan 2015-10-14 04:18 EDT
Created attachment 1082729 [details]
virt-viewer connect to guest successfully
Comment 2 xiaodwan 2015-10-14 04:19 EDT
Created attachment 1082730 [details]
virt-vewer connect to guest failure
Comment 4 Jonathon Jongsma 2015-10-14 12:18:51 EDT
The fact that you have these warnings even on the successful run makes me think that you are using a non-standard configuration of some sort:

** (virt-viewer:4874): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-3yGBLPcl8U: Connection refused

(virt-viewer:5058): virt-viewer-DEBUG: Error: Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory



I have not been able to reproduce the failure here, and I don't see any of those warnings above. Can you give a little more information on your setup?

Is the client running on the same machine as the host? If not, what OS is the host?
Comment 5 xiaodwan 2015-10-14 22:31:36 EDT
Yes, the client is running on the same machine as the host. 
It's easy to meet this problem at the first time. And then you redo the same operation, it's hard to reproduce it. I tried about 8~12 times to reproduce it again. So you can try it many times.
Comment 6 Christophe Fergeau 2015-10-15 04:40:09 EDT
Is this being run as root?
Comment 7 Christophe Fergeau 2015-10-15 05:05:44 EDT
Actually I can reproduce this on a 7.2 system. Building virt-viewer from 7.2 and running it on a fedora box leads to a different kind of failure for what it's worth (repeated "cannot connect to libvirt socket" messages during libvirtd downtime).
Comment 8 xiaodwan 2015-10-15 05:53:04 EDT
(In reply to Christophe Fergeau from comment #6)
> Is this being run as root?

yes
Comment 9 Christophe Fergeau 2015-10-15 09:24:33 EDT
Some experiments I've run


This triggers the bug:
$ virsh destroy $domain_name
$ virt-viewer $domain_name --wait
$ systemctl stop libvirtd.service && systemctl start libvirtd.service
$
$ virsh start $domain_name


This does not trigger the bug:
$ virsh destroy $domain_name
$ virt-viewer $domain_name --wait
$ systemctl stop libvirtd.service && systemctl start libvirtd.service
$
$ virsh start $other_domain && virsh destroy $other_domain && sleep 1 && virsh start $domain_name


This triggers the bug:
$ virsh destroy $domain_name
$ virt-viewer $domain_name --wait
$ systemctl stop libvirtd.service && systemctl start libvirtd.service
$
$ sleep 10 && virsh start $domain_name


Adding a 1 second g_usleep in virt_viewer_session_spice_open_host() right before the spice_session_connect() call also makes the bug go away in all cases.


Another thing to have in mind is that after a libvirt restart, virt-viewer does some polling to detect domain startup and connect to it rather than use libvirt domain events. See virt_viewer_start_reconnect_poll() and virt_viewer_connect_timer() and VirtViewer::domain_event. If I force domain_event to always be -1 in virt_viewer_connect(), I can sometimes reproduce this issue without a libvirtd restart. Why it's more reliably reproducible without a libvirtd restart, I don't know.

My current theory is that by polling libvirt domain, we get connection information before the domain is fully ready (SPICE ports not initialized), and thus the connection fails. Maybe always using libvirt events instead of falling back to polling would fix this bug.
Comment 10 Christophe Fergeau 2015-10-15 11:44:00 EDT
https://www.redhat.com/archives/virt-tools-list/2015-October/msg00043.html avoids this bug: it makes sure we don't keep polling when connecting to a recent (0.8 or newer) libvirtd.
As only connections to VM through the polling code have this bug (I think), this patch will prevent the buggy situation from occurring.
Comment 12 Fabiano Fidêncio 2016-03-15 08:26:45 EDT
Here is the relevant commit for virt-viewer:
c1e72c1be177544e5a718303dcb88412568f46d9
Comment 14 xiaodwan 2016-04-14 05:22:29 EDT
I can reproduce it with versions:
virt-viewer-2.0-6.el7.x86_64
libvirt-1.2.17-13.el7.x86_64

And then only update virt-viewer to virt-viewer-2.0-7.el7.x86_64 and tried it several times again. It doesn't occur.

At last updated libvirt to latest version libvirt-1.3.3-1.el7.x86_64 and tried it several times. I didn't meet this issue.

So move the bug from ON_QA to VERIFIED.
Comment 16 errata-xmlrpc 2016-11-03 21:11:47 EDT
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/RHBA-2016-2229.html

Note You need to log in before you can comment on or make changes to this bug.