Thursday, July 22, 2010

How to get Virtual Manager to work for a Xen host

So, continuing with the theme of Xen, Virtual Machine Manager or virt-manager for short, is a piece of software that I decided to check out because I wanted graphical access to my virtual machines. A more formal description as given on their website is:
"Virt-manager is a desktop user interface for managing virtual machines. It presents a summary view of running domains, their live performance & resource utilization statistics. The detailed view graphs performance & utilization over time. Wizards enable the creation of new domains, and configuration & adjustment of a domain's resource allocation & virtual hardware. An embedded VNC client viewer presents a full graphical console to the guest domain"
You need to download virt-manager on the machine from which you wish to access your virtual machines. I am using a machine running Ubuntu 10.04 which I will call the client machine in the description below.

My Virtual Machines (VMs) were created on top of Xen 3.2 hypervisor, Earlier I had some issues getting the network up and running on my VMs, the resolution of which I have described in an earlier post. My hypervisor machine which I will call my host machine is running kernel 2.6.24-24-xen.

So here is the procedure that I followed to get virt-manager to work:
  1. I used the Synaptic Package Manager (System->Administration->Synaptic Package Manager to download virt-manager and all the dependencies on my client machine. Alternatively, one could also do sudo apt-get install virt-manager

  2. On my host machine, I downloaded and installed libvirt-bin and ssh-askpass
    sudo apt-get install libvirt-bin
    sudo apt-get install ssh-askpass

  3. Now to access the virt-manager console from my client machine I used Application->System Tools->Virtual Machine Manager

  4. On my host machine, I started the libvirtd daemon:
    sudo libvirtd start

  5. At this point I tried to connect to my host machine using File->Add Connection...; I chose my specific hypervisor (Xen) and Connection as Remote Tunnel over SSH (I am not sure that this is the one that I was supposed to use, but it did work, eventually!)
    At this point, I got the following error on a pop-up on my client machine and on the console of my host machine:
    libvir: Xen Daemon error :internal error failed to connect to xend
    After some effort, the following fix worked:

    1. Open the xend configuration file
      sudo vim /etc/xen/xend-config.sxp

    2. In my previous post I had talked about adding a temporary bridge between physical network device and the virtual TAP device. I had to let the xend daemon become aware of this. So under the line:
      (network-script network-bridge)
      I added:
      (network-script 'network-bridge netdev=tmpbridge')
      (To recall what my network device is called, I did a ifconfig. It was the one whose description contains the domain-0's IP.

    3. I was not done with this file yet. I needed to add the following line somewhere in the file:
      (xend-unix-server yes)

    4. I saved and closed the file. Restarted the host machine's network (sudo /etc/init.d/networking restart), restarted the xend daemon (sudo xend restart), and finally restarted the libvirtd daemon( sudo libvirtd start)

    Now when I tried to add the connection using the setting mentioned above, it went through, asked me for a password and I would see a table giving the details of the CPU utilization and some other statistics of my VMs. Following is a screen shot of what I can see so far: