Virtualization with Ubuntu 10.04 – Lucid Lynx

Posted on Posted in Custom Programming

With the growing projects, we’ve decided to upgrade our test servers to a production grade server and setup virtual machines within the server. This move really makes sense because instead of allocating a workstation for each project as test machine, we are cutting it down into one server with multiple test VMs.

At the time of this writing, there are no official documentation on Lucid Lynx yet. There are a couple of variations on the configuration as compared to Ubuntu 9.10. This setup guide is to configure a KVM on Ubuntu Server and management of the VMs is done remotely from another machine running Ubuntu Desktop.

So, here is the step-by-step guide:

STEP #1: Install lib-virt package.

sudo apt-get install kvm libvirt-bin

STEP #2: Create user to manage lib-virt.

sudo adduser $USER libvirtd

where $USER is the username who will perform VM management.

STEP #3: Install bridge utilities.

sudo apt-get install bridge-utils

STEP #4: Configure network to bridge setup.

Edit /etc/network/interfaces and add the following (assumes dhcp bridge):

auto virbr1
iface virbr1 inet dhcp
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

STEP #5: Restart networking service.

sudo /etc/init.d/networking restart

If bridge is properly configured you should still be able to connect to any external network. (e.g. ping www.google.com). Once this work, proceed to Ubuntu Desktop to create the VM guests.

STEP #6: Install Virtual Machine Manager (on Ubuntu Desktop machine).

sudo apt-get install virt-manager

STEP #7: Invoke virt-manager and connect to Ubuntu Server.

virt-manager -c qemu+ssh:///system

where is hostname or IP address of the server.

STEP #8: Create the Guest VM image. Virtual Machine Manager provides a GUI to easily create an image. Just right-click on the server and select “New”. You will then be prompted step-by-step on the variables (e.g. # of processors, memory, etc.) needed to be configured for your VM.

STEP #9: Install the Guest VM OS. Use your regular CD/DVD installer or iso image to install the operating system on the VM. In my case, we use Ubuntu Server and Ubuntu Desktop on the guest VMs.

STEP #10: Change guest network connection to use pre-configured bridge. VMM does not have the option to configure bridge network. To setup the bridge, manually change the configuration file (xml) from libvirt. On Ubuntu Server, edit the xml configuration file under /etc/libvirt/qemu by changing the network portion to:



STEP #11: Restart VM. Upon restart, you should be able to access external network and VM is accessible from external network. On Ubuntu guests, the network device is found as eth3 and you may need to enable eth3 on /etc/network/interfaces.

That’s it. You can repeat steps (#8-#11) to setup additional guest VMs.

19 thoughts on “Virtualization with Ubuntu 10.04 – Lucid Lynx

  1. Following your instructions on a fresh ubuntu server install, there is a problem. Trying to invoke virt-manager from the client OS, I get this error:

    “Unable to open a connection to the libvirt management daemon.

    Libvirt URI is: qemu+ssh://192.168.1.23/system

    Verify that:
    – The ‘libvirt-bin’ package is installed
    – The ‘libvirtd’ daemon has been started
    – That you have access to ‘/var/run/libvirt/libvirt-sock’

    And the details:
    Unable to open connection to hypervisor URI ‘qemu+ssh://192.168.1.23/system’:
    cannot recv data: Connection reset by peer
    Traceback (most recent call last):
    File “/usr/share/virt-manager/virtManager/connection.py”, line 896, in _try_open
    None], flags)
    File “/usr/lib/python2.6/dist-packages/libvirt.py”, line 111, in openAuth
    if ret is None:raise libvirtError(‘virConnectOpenAuth() failed’)
    libvirtError: cannot recv data: Connection reset by peer

    Maybe you need to install ssh-askpass in order to authenticate.”

    libvirt-bin is installed on the server
    libvirtd has been started on the server
    ‘/var/run/libvirt/libvirt-sock’ is accessible to all users on the server
    ssh-askpass is installed on the server

    Would appreciate any help.
    Thanks!

  2. Hi,

    Remember that when you installed libvirt, it has automatically added your user to the libvirtd group.

    Hence, you have to logoff and logon again to obtain the needed credentials and get it to work.

    ++

  3. Notice: Ubuntu-server 10.04 doesn’t have ACPI daemon (package: acpid) installed as default. This needs to be installed on the Guest before it will react to the Shutdown and the Reboot commands. Without it, “virsh shutdown myGuestMachine” will not work. The Destroy command will of course always work.

  4. On a fresh install of 10.04 and following your instructions I can not setup the bridge. Every attempt to do so kills my network connectivity. Both eth0 and virbr1 have the same mac addy when looked up in ifconfig.

    I also don’t understand why you reference both virbr0 and virbr1 in your instructions.

  5. Hello Zer0-9, I prefer to setup the VM directly on the machine than over the network to avoid disconnection issues. It took me a while playing around to get the network connection stable. Sometimes rebooting the machine solves the IP issues… for reasons I don’t understand.

    Thanks for pointing out virbr0 and virbr1… my bad, they should refer to same name.

  6. Another neat feature is that you’ll be able to setup VNC on the VMs so you can directly connect to the machines without going through Virtual Machine Machine.

    VNC can be enabled on the VM by going to System > Preferences > Remote Desktop, then enable it. You may then use any VNC client to connect to the VM.

    For Mac Snow Leopard, VNC client is available in Finder > Go > Connect to Server.

  7. Hi,
    I installed 8.10 on 10.04 as a guest vm but its not booting.Error is………..

    Grub loading stage 1.5

    Grub loading ,please wait……

    Thanks
    Avinash

  8. I get an error that the user are not permitted to add the interface. Ubuntu 10.04.

    Traceback (most recent call last):
    File “/usr/share/virt-manager/virtManager/engine.py”, line 588, in run_domain
    vm.startup()
    File “/usr/share/virt-manager/virtManager/domain.py”, line 150, in startup
    self._backend.create()
    File “/usr/lib/python2.6/dist-packages/libvirt.py”, line 300, in create
    if ret == -1: raise libvirtError (‘virDomainCreate() failed’, dom=self)
    libvirtError: Failed to add tap interface to bridge ‘virbr0’: Operation not permitted

  9. When I try to connect to my server I get the following error:

    Unable to open a connection to the libvirt management daemon.

    Libvirt URI is: qemu+ssh://192.168.198.1/system

    Verify that:
    – The ‘libvirt-bin’ package is installed
    – The ‘libvirtd’ daemon has been started
    – That you have access to ‘/var/run/libvirt/libvirt-sock’

    Unable to open connection to hypervisor URI ‘qemu+ssh://192.168.198.1/system’:
    cannot recv data: Connection reset by peer
    Traceback (most recent call last):
    File “/usr/share/virt-manager/virtManager/connection.py”, line 896, in _try_open
    None], flags)
    File “/usr/lib/python2.6/dist-packages/libvirt.py”, line 111, in openAuth
    if ret is None:raise libvirtError(‘virConnectOpenAuth() failed’)
    libvirtError: cannot recv data: Connection reset by peer

    Maybe you need to install ssh-askpass in order to authenticate.

    Any help would be great, thanks.

    Richard

  10. Problem resolved, This error can also be caused by outdated CA certificates on the client machine. You can test this by trying to connect to the ssh port manually and seeing if your certificate is outdated on the client machine.

    Regards,

    Richard

  11. I solved this by going to a terminal and logging in once to the remote server via ssh so that I could accept the certificate or whatever. The next time I tried with virt-manager, it skipped that step and asked me for the root password which I was finally able to enter and then connect to the vm.

  12. Just delete the connection.
    go to file->add new connection-> Hypervisior QEMU+KVM->connection -> Remote tunnel over ssh
    give the rsa key to add the connection by typing yes
    and you are done.

    This works for me..

  13. hi- i follow your guide, step by step.

    Before I go further on problem – I would like to clarify on statements :
    “This setup guide is to configure a KVM on Ubuntu Server and management of the VMs is done remotely from another machine running Ubuntu Desktop.”

    My question – step1 to step11 is setup on Ubuntu Server, say the IP address is 192.128.1.50?

    after that, I have to have one client, say IP 192.128.1.55 to invoke Ubuntu server, am I correct?

    Second question-

    I have problem with following errors message when i try to add connection in Virtual Machine Manager at IP- 10.1.9.125)(Applications—>System Tools —>Virtual Machine Manager).

    My machine produces problem with message:

    Unable to open a connection to the libvirt management daemon.

    Libvirt URI is: qemu+ssh://root@10.1.9.125/system

    Verify that:
    – The ‘libvirt-bin’ package is installed
    – The ‘libvirtd’ daemon has been started
    – That you have access to ‘/var/run/libvirt/libvirt-sock’

    Unable to open connection to hypervisor URI ‘qemu+ssh://root@10.1.9.105/system’:
    cannot recv data: Connection reset by peer
    None

    Maybe you need to install ssh-askpass in order to authenticate.

  14. Sir, i do not have ubuntu server rather i hv ubuntu 10.04 , and cpu configuration is

    4GB Ram
    500 GB HDD
    intel core i5 processor xi386, 32-bit

    please tell me , what should i do to make my private cloud. i also tried to install ubuntu server 11.04, but it didn’t worked (installation problem).

  15. Dear Allan,
    thx for ur support, but i m facing lots of problem while installing ubuntu enterprise cloud 11.04. sir, plzz tell me, where to start from, is there any sites which provide all the required information regarding. i have only little bit knowledge of ubuntu. now what should i do to make my private cloud.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.