Build Xen 4.1.1(2-rc1,2-rc2,2-rc3) on Ubuntu 11.10 and set up HVM via virt-manager

*****************************************************************************************
UPDATE on 10/25/11 Xen 4.1.2 with pygrub gpt support for Ubuntu 11.10 (virt-install fedora 16(TC1) works for me).
View PPA Xen 4.1.2 with pygrub gpt support for Ubuntu 11.10.
Attention, vif entry for HVM domains should look like :-

vif = [ 'type=ioemu, bridge=br0, model='e1000']

Then absence of Ubuntu’s patch xen-pirq-resubmit-irq.patch from official package is not important. Same entry for PV-on-HVM domains should look like :-

vif = [ 'bridge=br0, model='e1000']

Details may be viewed PV-on-HVM domains at Xen 4.1.2 Ubuntu Oneiric Dom0
I’ve also tested this hypervisor with 3.1.0-030100-generic. The last kernel has PCI_BACKEND implemented.
UPDATE on 10/21/11 Xen 4.1.2 for Ubuntu 11.10.
View PPA Xen 4.1.2 for Ubuntu 11.10.
UPDATE on 09/15/11 Xen 4.1.2-rc2 for Ubuntu 11.10.
View PPA Xen 4.1.2-rc2 for Ubuntu 11.10.
UPDATE on 08/26/11 Build Xen 4.1.2-rc1 for Ubuntu 11.10.
View PPA Build Xen 4.1.2-rc1 for Ubuntu 11.10
How to build Xen 4.1.2 on Launchpad on your own
******************************************************************************************
Patch changeset-23104 from xen-4.1-testing.hg (changeset 23104:1976adbf2b80) has been applied to fix build “hvmloader” by GCC 4.6. View thread @xen-devel (Posts #11,14,15,18) ([1]). Packages, ready to go, uploaded to PPA Xen 4.1.1 on Ubuntu 11.10. Workaround connected with ERROR: Domain not found: xenUnifiedDomainLookupByName when attempt to set up HVM DomU via virt-manager is also described in details. Build is based on https://launchpad.net/ubuntu/+source/xen/4.1.1-1ubuntu1
Now run :-
# apt-add-repository ppa:bderzhavets/xen-hg
# apt-get update
# apt-get install synaptic
Install Xen 4.1.1 Hypervisor (4.1.1-1ubuntu3) and tools via Synaptic Manager.



Add to /etc/modules :-

xen-gntdev
xen-blkback
xen-netback

Reboot into Xen environment

root@boris-System-P5Q3:~# xl info
host : boris-System-P5Q3
release : 3.0.0-6-generic
version : #7-Ubuntu SMP Wed Jul 20 13:53:04 UTC 2011
machine : x86_64
nr_cpus : 4
nr_nodes : 1
cores_per_socket : 4
threads_per_core : 1
cpu_mhz : 2833
hw_caps : bfebfbff:20100800:00000000:00000940:0008e3fd:00000000:00000001:00000000
virt_caps : hvm
total_memory : 8190
free_memory : 2052
free_cpus : 0
xen_major : 4
xen_minor : 1
xen_extra : .1
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler : credit
xen_pagesize : 4096
platform_params : virt_start=0xffff800000000000
xen_changeset : unavailable
xen_commandline : placeholder
cc_compiler : gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-5ubuntu1)
cc_compile_by : bderzhavets
cc_compile_domain : yahoo.com
cc_compile_date : Sun Jul 24 12:24:37 UTC 2011
xend_config_format : 4

Also make sure :-

root@boris-System-P5Q3:~# ls -l /dev/xen
total 0
crw------- 1 root root 10, 55 2011-07-25 10:31 evtchn
crw------- 1 root root 10, 56 2011-07-25 10:31 gntdev
root@boris-System-P5Q3:~# lsmod | grep xen
xen_evtchn 13172 1
xenfs 18311 1
xen_blkback 23177 0 [permanent]
xen_netback 27854 0 [permanent]
xen_gntdev 17676 0

If you are missing at least one device under /dev/xen or lsmod doesn’t show all mentioned drivers, yours system won’t be functional.
Create HVM DomU via standard python profile. You should be able complete the task with no problem. Next step would be fixing bug with virtinst tools and install HVM Ubuntu 10.04.3 via virt-manager or virt-install. Installation via virt-manager is much easier and allows create Ubuntu 10.04.3 PV DomU via XML profiling and command “virsh define” in several minutes.




Next to activate Libvirt 0.9.2 and virtinst tools :-

# apt-get install virtinst virt-viewer virt-manager

Comment out (xend-unix-server yes) in /etc/xen/xend-config.sxp and export variable

export VIRSH_DEFAULT_CONNECT_URI="xen:///"

in root’s .bashrc. Then restart xend service
Attempt to run :-

# virt-install --connect xen:/// --debug -n LynxHVM --hvm -r 1024 --vcpus=1 \
-f /dev/sda7 --vnc \
-c /root/Downloads/ubuntu-10.04.3-desktop-amd64.iso


Generates an error

Mon, 25 Jul 2011 10:58:45 ERROR Domain not found: xenUnifiedDomainLookupByName
Mon, 25 Jul 2011 10:58:45 DEBUG Traceback (most recent call last):
File “/usr/bin/virt-install”, line 1079, in start_install
dom = guest.start_install(conscb, meter, wait=wait_on_console)
File “/usr/lib/pymodules/python2.7/virtinst/Guest.py”, line 1187, in start_install
start_xml, final_xml, is_initial)
File “/usr/lib/pymodules/python2.7/virtinst/Guest.py”, line 1246, in _create_guest
dom = self.conn.createLinux(start_xml or final_xml, 0)
File “/usr/lib/python2.7/dist-packages/libvirt.py”, line 1686, in createLinux
if ret is None:raise libvirtError(‘virDomainCreateLinux() failed’, conn=self)
libvirtError: Domain not found: xenUnifiedDomainLookupByName

/var/log/xen/qemu-dm-LNX.log reports

/usr/lib64/xen/bin/qemu-dm: error while loading shared libraries: libxenctrl.so: cannot open shared object file: No such file or directory

To fix this failure :

root@boris-System-P5Q3:/usr/lib64/xen-4.1# cp -R lib /usr/lib64/xen
root@boris-System-P5Q3:/usr/lib64/xen-4.1# cp -R boot /usr/lib64/xen
root@boris-System-P5Q3:/usr/lib64/xen-4.1# cp -R bin /usr/lib64/xen







Normal virt-install :
root@boris-System-P5Q3:~# virt-install –connect xen:/// –debug -n LynxHVM –hvm -r 1024 –vcpus=1 -f /dev/sda7 –vnc -c /root/Downloads/ubuntu-10.04.3-desktop-amd64.iso
Mon, 25 Jul 2011 11:07:40 DEBUG Launched with command line:
/usr/bin/virt-install –connect xen:/// –debug -n LynxHVM –hvm -r 1024 –vcpus=1 -f /dev/sda7 –vnc -c /root/Downloads/ubuntu-10.04.3-desktop-amd64.iso
Mon, 25 Jul 2011 11:07:40 DEBUG Requesting libvirt URI xen:///
Mon, 25 Jul 2011 11:07:40 DEBUG Received libvirt URI xen:///
Mon, 25 Jul 2011 11:07:40 DEBUG Requesting virt method ‘hvm’, hv type ‘default’.
Mon, 25 Jul 2011 11:07:40 DEBUG Received virt method ‘hvm’
Mon, 25 Jul 2011 11:07:40 DEBUG Hypervisor name is ‘xen’
Mon, 25 Jul 2011 11:07:40 DEBUG DistroInstaller location is a local file/path: /root/Downloads/ubuntu-10.04.3-desktop-amd64.iso
Mon, 25 Jul 2011 11:07:40 DEBUG Guest.has_install_phase: True

Starting install…
Mon, 25 Jul 2011 11:07:40 DEBUG Could not open “/etc/sysconfig/keyboard” [Errno 2] No such file or directory: ‘/etc/sysconfig/keyboard’
Mon, 25 Jul 2011 11:07:40 DEBUG Could not open “/etc/X11/xorg.conf”: [Errno 2] No such file or directory: ‘/etc/X11/xorg.conf’
Mon, 25 Jul 2011 11:07:40 DEBUG Could not open “/etc/sysconfig/keyboard” [Errno 2] No such file or directory: ‘/etc/sysconfig/keyboard’
Mon, 25 Jul 2011 11:07:40 DEBUG Could not open “/etc/X11/xorg.conf”: [Errno 2] No such file or directory: ‘/etc/X11/xorg.conf’
Mon, 25 Jul 2011 11:07:40 DEBUG Generated install XML:
<domain type=’xen’>
<name>LynxHVM</name>
<currentMemory>1048576</currentMemory>
<memory>1048576</memory>
<uuid>c4e2746f-bc7c-17ef-84e4-e37defc696d3</uuid>
<os>
<type arch=’x86_64′>hvm</type>
<loader>/usr/lib/xen-default/boot/hvmloader</loader>
<boot dev=’cdrom’/>
<boot dev=’hd’/>
</os>
<features>
<acpi/><apic/><pae/>
</features>
<clock offset=”utc”/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<vcpu>1</vcpu>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type=’block’ device=’disk’>
<source dev=’/dev/sda7’/>
<target dev=’hda’ bus=’ide’/>
</disk>
<disk type=’file’ device=’cdrom’>
<source file=’/root/Downloads/ubuntu-10.04.3-desktop-amd64.iso’/>
<target dev=’hdc’ bus=’ide’/>
<readonly/>
</disk>
<interface type=’bridge’>
<source bridge=’br0’/>
<mac address=’00:16:3e:6d:9c:aa’/>
</interface>
<input type=’mouse’ bus=’ps2’/>
<graphics type=’vnc’ port=’-1′ keymap=’en-us’/>
<console type=’pty’/>
<video>
<model type=’cirrus’/>
</video>
</devices>
</domain>

Mon, 25 Jul 2011 11:07:40 DEBUG Generated boot XML:
<domain type=’xen’>
<name>LynxHVM</name>
<currentMemory>1048576</currentMemory>
<memory>1048576</memory>
<uuid>c4e2746f-bc7c-17ef-84e4-e37defc696d3</uuid>
<os>
<type arch=’x86_64′>hvm</type>
<loader>/usr/lib/xen-default/boot/hvmloader</loader>
<boot dev=’hd’/>
</os>
<features>
<acpi/><apic/><pae/>
</features>
<clock offset=”utc”/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<vcpu>1</vcpu>
<devices>
<emulator>/usr/lib64/xen/bin/qemu-dm</emulator>
<disk type=’block’ device=’disk’>
<source dev=’/dev/sda7’/>
<target dev=’hda’ bus=’ide’/>
</disk>
<disk type=’block’ device=’cdrom’>
<target dev=’hdc’ bus=’ide’/>
<readonly/>
</disk>
<interface type=’bridge’>
<source bridge=’br0’/>
<mac address=’00:16:3e:6d:9c:aa’/>
</interface>
<input type=’mouse’ bus=’ps2’/>
<graphics type=’vnc’ port=’-1′ keymap=’en-us’/>
<console type=’pty’/>
<video>
<model type=’cirrus’/>
</video>
</devices>
</domain>

Creating domain… | 0 B 00:00
Mon, 25 Jul 2011 11:07:40 DEBUG Started guest, connecting to console if requested
Mon, 25 Jul 2011 11:07:40 DEBUG Launching console callback

** (virt-viewer:5321): CRITICAL **: viewer_activate: assertion `viewer->display == NULL’ failed
Guest installation complete… restarting guest.
Mon, 25 Jul 2011 11:22:14 DEBUG Launching console callback

(virt-viewer:5844): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width 400 and height -2147483648

(virt-viewer:5844): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width 400 and height -2147483648

********************************************************************************
Define following XML profile LucidPV.xml utilizing same storage device (/dev/sda7) as HVM:
********************************************************************************

<domain type=’xen’>
<name>LucidPV</name>
<description></description>
<memory>2097152</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<bootloader>/usr/lib/xen-4.1/bin/pygrub</bootloader>
<bootloader_args>-q</bootloader_args>
<os>
<type>linux</type>
<kernel></kernel>
</os>
<clock offset=’utc’/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/lib/xen-4.1/bin/qemu-dm</emulator>
<disk type=’block’ device=’disk’>
<driver name=’phy’/>
<source dev=’/dev/sda7’/>
<target dev=’xvda’ bus=’xen’/>
</disk>
<interface type=’bridge’>
<mac address=’00:16:3e:63:3b:51’/>
<source bridge=’br0’/>
<script path=’/etc/xen/scripts/vif-bridge’/>
<target dev=’vif10.0’/>
</interface>
<console type=’pty’ tty=’/dev/pts/3′>
<source path=’/dev/pts/3’/>
<target type=’xen’ port=’0’/>
</console>
<input type=’mouse’ bus=’xen’/>
<graphics type=’vnc’ port=’5900′ autoport=’yes’/>
</devices>
</domain>

Then run
# virsh define LucidPV.xml



References
1.Problem with Xen 4.1 on Ubuntu 11.10 ( Oneiric Ocelot) (HVM DomUs crash)

12 Responses to Build Xen 4.1.1(2-rc1,2-rc2,2-rc3) on Ubuntu 11.10 and set up HVM via virt-manager

  1. wangqi060934 says:

    what do you mean by “Reboot into Xen environment”?
    After I reboot,I find nothing has changed.And I type “xl info”,it promps me “Can’t find hypervisor information in sysfs”.

  2. Aaron says:

    wangqi, on Ubuntu 11.10 the grub2 boot menu is hidden.

    To show the menu, you’ll need to do:
    sudo cp /etc/default/grub /etc/default/grub.bak
    edit /etc/default/grub (with whatever editor you prefer) and change GRUB_HIDDEN_TIMEOUT to something greater than 0 (seconds).

    If you want to change the default kernel to boot:
    You can either count the number of entries (from 0) and update GRUB_DEFAULT to that number or change the order so that xen is the first item:
    sudo mv /etc/grub.d/20_linux_xen /etc/grub.d/08_linux_xen

    When you’re done, you must:
    sudo update-grub2

  3. Aaron says:

    My question is, am I right in assuming that these PPA’s or the default xen hypervisor included in ubuntu cannot have specific options set, such as CONFIG_XEN_PCIDEV_BACKEND? To do those, I assume I would have to compile it myself.

  4. dbaxps says:

    CONFIG_XEN_PCIDEV_BACKEND it’s about 3.1 kernel , but not hypervisor. View :-
    http://kernel.ubuntu.com/%7Ekernel-ppa/mainline/v3.1-oneiric/
    I haven’t found anything in 0003-default-configs.patch .
    I would download 3.1-rc4 kernel from kernel.org and see .config

  5. tigra says:

    Hi. Thanx for your work!
    Also i can’t start HVM domain without doing
    # sudo ln -s /usr/share/qemu-linaro /usr/share/qemu
    There was an error “Could not read keymap file: ‘/usr/share/qemu/keymaps/en-us'” in /var/log/qemu-dm-domU.log

  6. dbaxps says:

    I cannot watch every step of Ubuntu development. I was under impression that if you install stock xen 4.1 ( fixed a while ago) keymaps get installed due to dependencies. If you installed 4.1.2 via my PPA it didn’t happen due to my laziness to update debian/control .
    Sorry.

  7. wangqi060934 says:

    I have installed hypervisor,but there is no boot entry about xen in /boot/grub/grub.cfg. “update-grub2″ doesnot make any sense.

  8. Hi man,

    Great tutorial, really! Very helpful, thank you very much!
    Besides this, I’ve got a question: the DomU you’ve installed here is a 10.04. I tried with 11.10, but it doesn’t work.
    At the time the installation process tries to detect hardware, I’ve got a error prompting it can’t load “modprobe -v xenbus_probe_frontend”. If I continue the install, it just can’t detect any net interface nor hard disk.
    As me using an oneiric DomU rather than a 10.04 is the only difference with your tutorial, I then tried to install a 10.04 and it just worked.

    I guess the modprobe xenbus_probe_frontend error is related to the PVHVM drivers (or at least, drivers). Some web research tell me it should be circumvented using xen_platform_pci=0; BUT:
    – I can’t figure how to pass this parameter to virt-install or virt-manager xml definition file
    – I can’t figure WHY this error doesn’t happen using the LTS DomU (the best explanation I got so far is that Canonical fucked up none-LTS packagings)

  9. helloworld says:

    hi
    how to install and run the stubdom????

Leave a comment