Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 689865

Summary: [RHEL 6.1] "virt-manager -h" command from ssh session gives error
Product: Red Hat Enterprise Linux 6 Reporter: asilva <asilva>
Component: virt-managerAssignee: Cole Robinson <crobinso>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: dyuan, hjiang, jmunilla, jwilleford, mliu, mzhan, rdassen
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
No description necessary
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 16:07:30 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:
Bug Depends On:    
Bug Blocks: 688244    

Description asilva 2011-03-22 17:07:29 UTC
> Description of problem:
If I do "virt-manager --h" command from ssh shell, I see the following error on the screen. If I do this command from console,
it prints the correct print output

[root@blade7-rhel6 ~]# virt-manager --h
Traceback (most recent call last):
File "/usr/share/virt-manager/virt-manager.py", line 455, in <module>
main()
File "/usr/share/virt-manager/virt-manager.py", line 341, in main
import gtk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display 

> Version-Release number of selected component (if applicable):
- Red Hat Enterprise Linux 6.1

> Steps to Reproduce:
- Using RHEL 6.1 and ssh with "-X":
[wr41th@arkham ~]$ ssh root.1.101 -X
root.1.101's password: 

[root@host01 ~]# virt-manager -h
Usage: virt-manager.py [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  --profile=FILE        Generate runtime performance profile stats
  -c URI, --connect=URI
                        Connect to hypervisor at URI
  --debug               Print debug output to stdout (implies --no-fork)
  --no-dbus             Disable DBus service for controlling UI
  --no-fork             Don't fork into background on startup
  --no-conn-autostart   Do not autostart connections
  --show-domain-creator
                        Create a new virtual machine
  --show-domain-editor=UUID
                        Edit a domain configuration
  --show-domain-performance=UUID
                        Show a domain performance
  --show-domain-console=UUID
                        Show a domain console
  --show-host-summary   Show a host summary

- Using RHEL 6.1 and ssh without "-X":
[root@host01 ~]# virt-manager -h
ERROR:root:could not open display
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-manager.py", line 413, in <module>
    main()
  File "/usr/share/virt-manager/virt-manager.py", line 285, in main
    import gtk
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
    _gtk.init_check()
RuntimeError: could not open display
Traceback (most recent call last):
  File "/usr/share/virt-manager/virt-manager.py", line 420, in <module>
    _show_startup_error(str(run_e), "".join(traceback.format_exc()))
  File "/usr/share/virt-manager/virt-manager.py", line 61, in _show_startup_error
    import gtk
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
    _gtk.init_check()
RuntimeError: could not open display

- Using RHEL 5.5 and ssh without "-X":
[root@host02 ~]# virt-manager -h
usage: virt-manager.py [options]

options:
  -h, --help            show this help message and exit
  --profile=FILE        Generate runtime performance profile stats
  -c URI, --connect=URI
                        Connect to hypervisor at URI
  --debug               Print debug output to stdout (requires --no-fork)
  --no-dbus             Disable DBus service for controlling UI
  --no-fork             Don't fork into background on startup
  --no-conn-autostart   Do not autostart connections
  --show-domain-creator
                        Create a new virtual machine
  --show-domain-editor=UUID
                        Edit a domain configuration
  --show-domain-performance=UUID
                        Show a domain performance
  --show-domain-console=UUID
                        Show a domain console
  --show-host-summary   Show a host summary
  
> Additional info:

The error happens because the command line arguments are being parsed after the main () tries to run the GTK.

There is a difference in main() statement.

- RHEL5 in /usr/share/virt-manager/virt-manager.py
--snip--
# Run me!
def main():
    setup_i18n()
    setup_pypath()

    (options, ignore) = parse_commandline()
    setup_logging(options.debug)

    # Urgh, pygtk merely logs a warning when failing to open
    # the X11 display connection, and lets everything carry
    # on as if all were fine. Ultimately bad stuff happens,
    # so lets catch it here & get the hell out...
    import warnings
    warnings.filterwarnings('error', module='gtk')
    try:
--/snip--


- RHEL6 in /usr/share/virt-manager/virt-manager.py
--snip--
# Run me!
def main():
    setup_i18n()
    setup_pypath()

    # Urgh, pygtk merely logs a warning when failing to open
    # the X11 display connection, and lets everything carry
    # on as if all were fine. Ultimately bad stuff happens,
    # so lets catch it here & get the hell out...
    import warnings
    warnings.filterwarnings('error', module='gtk')
    try:
        import gobject

        # Set program name for gnome shell (before importing gtk, which
--/snip--


We can see in RHEL5 virt-manager.py there is the following line getting the command line arguments before to start the GTk. 

    (options, ignore) = parse_commandline()


In RHEL6 this line is after: 

        import gtk
    except Warning, e:
        # ...the risk is we catch too much though
        # Damned if we do, damned if we dont :-)(
        raise RuntimeError(_("Unable to initialize GTK: %s") % str(e))
    warnings.resetwarnings()

    (options, ignore) = parse_commandline()
    setup_logging(options.debug)

Comment 2 Cole Robinson 2011-04-07 16:37:05 UTC
Tagging as a regression. Fix is simple and low risk.

Comment 6 Cole Robinson 2011-07-28 15:30:33 UTC
Fixed in virt-manager-0.9.0-2.el6

Comment 8 Huming Jiang 2011-08-04 03:15:03 UTC
verified with the following components:
virt-manager-0.9.0-5.el6.x86_64
libvirt-0.9.4-0rc1.2.el6.x86_64

Steps:
1. # ssh 10.66.3.130
root.3.130's password: 
Last login: Wed Aug  3 21:14:29 2011 from 10.66.15.50
2. # virt-manager -h
Usage: virt-manager [options]
...

3. # ssh 10.66.3.130 -X
root.3.130's password: 
Last login: Wed Aug  3 23:08:54 2011 from 10.66.3.131
4. # virt-manager -h
Usage: virt-manager [options]
...

Comment 9 Cole Robinson 2011-11-07 16:37:36 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:
No description necessary

Comment 10 errata-xmlrpc 2011-12-06 16:07:30 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-2011-1642.html