Start KVM virtual machines from the console with virsh

Here’s what I see when I run virsh and type list:

# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
   'quit' to quit

virsh # list
 Id Name                 State
----------------------------------

I’m in the middle of working from the command line in a remote ssh session on a KVM virtual machine host that runs two virtual machines. For reasons unclear at this time, I can’t list domains, interfaces, volumes, or anything from virsh on the host. However, I can still start and stop virtual machines and flag them for autostart and all I need to do right now is start a vm.
kvm logo with tux juggling
Nothing there. I was expecting to see the same two virtual machines by name that I see from virt-manager. But i’m stuck on a console with no display available right now. virt-manager is not an option. I know there are other vm managers available that may be browser based or whatever, but I don’t have them installed.

Although virsh won’t let me query much information, I do know the names of the machines I wish to start and I have a simple ssh shell on the host machine. So lets give it a shot.

dontpanic@host:~# virsh autostart vm1
Domain vm1 marked as autostarted

dontpanic@host:~# virsh start vm1
Domain vm1 started

Everything went better than expected. So if you’re used to working in a virtual machine manager GUI but for whatever reason you can’t/won’t, give the virtual shell “virsh” a try.

If you’re on a debian based system, virsh is found in the libvirt-bin package. If you’re on an rpm based system, it’s in libvirt-client.

Pygtk: Check to see if a button is sensitive

Setting and unsetting flags is a no-brainer, but how do you just check to see if a flag such as ‘gtk.SENSITIVE’ is set for something like a button? Here’s an example of how easy it is.

Use the bitwise and operator, ‘&’ with the flag you’re interested in.

It’s pretty simple but hard to find this answer when you’re looking for a method to extract a bool value. I wish it was as easy as using ‘is_sensitive()’ that returns true if the widget flag ‘gtk.SENSITIVE’ is set. But use the ampersand with the flags and you’re all set.

two power buttons on silver

This is specifically for pygtk and only applicable to buttons, really you should be moving to QT because everything from documentation to implementation of a button is that just much smoother.

Here’s a short example of checking for a save button’s sensitivity before proceeding to quit the main loop. This is something you may use when a quit button is clicked but changes have been made to a document and you want to give the user one last chance to save before exiting your application.

def quit(self, widget):
  if self.button_save.flags() & gtk.SENSITIVE:
    msg = "Save changes before closing?"
    dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
            gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, msg)
    dialog.set_title("There are unsaved Changes")
    dialog.set_position(gtk.WIN_POS_CENTER)
    dialog.set_keep_above(True)

    response = dialog.run()
    dialog.destroy()
                
    if response != gtk.RESPONSE_YES:
      return False

  gtk.main_quit()

Download and build proxytunnel in Fedora

This program connects stdin and stdout to a server somewhere on the network, through a standard HTTPS proxy. We mostly use it to tunnel SSH sessions through HTTP(S) proxies, allowing us to do many things that wouldn’t be possible without it.

* Create tunnels using HTTP and HTTPS proxies (That understand the HTTP CONNECT command).
* Work as a back-end driver for an OpenSSH client, and create SSH connections through HTTP(S) proxies.
* Work as a stand-alone application, listening on a port for connections, and then tunneling these connections to a specified destination.

This was originally posted on rootninja back in December 2009 and dug up from the Internet graveyard that is the wayback machine. Versions of Fedora and this app have changed significantly. Use this howto as-is at your own risk. As of Fedora 21 (at least), you’re better off using yum to download the prebuilt and configured binary version instead of building it (as far as just getting it to work goes anyway!) But hey, maybe you’re still using Fedora 12 for one reason or another. No judgement.

Get it

$ svn co https://proxytunnel.svn.sourceforge.net/svnroot/proxytunnel/

    A trunk
    A trunk/website
    …
    A tags/v1-6-0-rc1/proxytunnel/Makefile.cygwin
    A tags/v1-6-0-rc1/proxytunnel/Makefile
    Checked out revision 248. 

Build it

Getting it built seems to be pretty straight forward stuff…

$ make

    …
    make -C docs
    make[1]: Entering directory /home/svn/proxytunnel/trunk/proxytunnel/docs'
    asciidoc -b docbook -d manpage proxytunnel.1.txt
    make[1]: asciidoc: Command not found
    make[1]: *** [proxytunnel.1.xml] Error 127
    make[1]: Leaving directory /home/svn/proxytunnel/trunk/proxytunnel/docs’
    make: *** [docs] Error 2 

$ yum install asciidoc

    Running Transaction
    Installing : asciidoc-8.4.5-4.fc12.noarch 1/1
    Installed:
    asciidoc.noarch 0:8.4.5-4.fc12
    Complete!

$ make

    make -C docs
    make[1]: Entering directory /home/svn/proxytunnel/trunk/proxytunnel/docs'
    asciidoc -b docbook -d manpage proxytunnel.1.txt
    xmlto man proxytunnel.1.xml
    make[1]: xmlto: Command not found
    make[1]: *** [proxytunnel.1] Error 127
    rm proxytunnel.1.xml
    make[1]: Leaving directory /home/svn/proxytunnel/trunk/proxytunnel/docs’
    make: *** [docs] Error 2

$ yum install xmlto

    Running Transaction
    Installing : xmlto-0.0.23-2.fc12.x86_64 1/1
    Installed:
    xmlto.x86_64 0:0.0.23-2.fc12
    Complete!

$ make

    Note: Writing proxytunnel.1
    asciidoc -d manpage proxytunnel.1.txt
    asciidoc proxytunnel-paper.txt
    rm proxytunnel.1.xml
    make[1]: Leaving directory `/home/svn/proxytunnel/trunk/proxytunnel/docs’

$ ./proxytunnel –help

    proxytunnel 1.9.0 (rev 248) Copyright 2001-2008 Proxytunnel Project
    Usage: proxytunnel [OPTIONS]…
    Build generic tunnels trough HTTPS proxies using HTTP authentication

    Standard options:
    -i, –inetd Run from inetd (default: off)
    -a, –standalone=INT Run as standalone daemon on specified port
    -p, –proxy=STRING Local proxy host:port combination
    -r, –remproxy=STRING Remote proxy host:port combination (using 2 proxies)
    -d, –dest=STRING Destination host:port combination
    -e, –encrypt SSL encrypt data between local proxy and destination
    -E, –encrypt-proxy SSL encrypt data between client and local proxy
    -X, –encrypt-remproxy SSL encrypt data between local and remote proxy

    Additional options for specific features:
    -F, –passfile=STRING File with credentials for proxy authentication
    -P, –proxyauth=STRING Proxy auth credentials user:pass combination
    -R, –remproxyauth=STRING Remote proxy auth credentials user:pass combination
    -N, –ntlm Use NTLM based authentication
    -t, –domain=STRING NTLM domain (default: autodetect)
    -H, –header=STRING Add additional HTTP headers to send to proxy
    -x, –proctitle=STRING Use a different process title

    Miscellaneous options:
    -v, –verbose Turn on verbosity
    -q, –quiet Suppress messages
    -h, –help Print help and exit
    -V, –version Print version and exit

And there you have it, enjoy.

Linux Mint is the best Operating System available today

This distribution of Linux is the best setup available today for the desktop.

Since Mint is based on Ubuntu or Debian depending on your choice, the installation and setup is simple and easy. You can even install it while running in live mode or from inside Windows using Ubuntu’s wubi installer.

Where Ubuntu and Fedora have recently shunned almost everyone with their new half-developed unity desktop, this distro shines through. I really enjoy the LXDE environment over Gnome, but the choice is yours to pick and choose what you like to use.

Choice is one of many reasons why I really like this distribution over the other popular flavours right now.

I share the same dissatisfaction for Unity and Gnome 3 with most of the community. While this is the main reason for jumping ship and crashing the party, there are some really simple things I like, like Dropbox.

You dont have to go and download it to start using it, its right there in the start menu. But not installed yet so its not taking up space. This is one of the many reasons why maintaining compatibility with Ubuntu is a good thing. Click on it to start it, and tells you it needs to download. One more click and you’re off.

Once its done, just log in with your account or make a new one, and thats it. I wish all services worked that well.

I think Microsoft is heading in the right direction with swipe gestures for unlocking the desktop, but I hope they take a hint from the recent Gnome debacle and make it configurable. I want the option to jump right into desktop mode without having to bother with metro at all if that’s what I like. For desktop users, forcing you to use metro will be a deal breaker. Remember how bad ME and Vista were?

The sad part is Microsoft doesn’t have a history of giving you much choice in anything and their track record for anything mobile is horrible.

But enough about Windows, especially since is not even available yet. Mint is the choice for desktops today. From the simple, straightforward installer to the fact that everything just works the way it should, it picks up where Ubuntu fails.