virt-manager ERROR:root:Unable to initialize GTK: could not open display

I recently installed Kvm on my Debian server to have a play with Qemu Virtual Machines. We have this set up at work so i’m pretty familiar with the system.

However, after installing kvm, qemu, vnc4server and vnc4viewer to access my server, when I tried to run virt-manager one of two things happened.

1. As a normal user I had no privileges to create or manage VM’s
2. As root or sudo user virt-manager wouldn’t even launch from the terminal, just gave me a whole string of Gtk error messages.

virt-manager ERROR:root:Unable to initialize GTK: could not open display

So, methinks, A: I need root/sudo privileges, BUT! you NEVER, EVER run graphical apps as root, it’s a no-no.

That’s where I found the solution. To run graphical apps as root/sudo you use GKSU not SU

Solution:

sudo apt-get install gksu

sudo vim /usr/bin/virt-manager

Then in between exec and python, just add a gksudo like this:

#!/bin/sh

exec gksudo python “/usr/share/virt-manager/virt-manager.py” “$@”

Now when I run virt-manager as a normal user, everything is fine.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s