====== Virtualization using Xen on ODROID-XU3/4 ====== This page contains the **step-by-step guide for virtualization** using Xen on ODROID-XU3/4. **//HOST-PC Environments://** * Ubuntu 14.04 LTS Desktop * Toochain: [[https://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.9-2014.09_linux.tar.xz|arm-none-eabi-, Linaro 4.9-2014.09]] * SD card device name assumption: /dev/sdc * SD card mount point assumption: /media/boot, /media/rootfs ===== Basic preparation ===== SD card or eMMC basic platform preparation: $ wget http://odroid.in/ubuntu_14.04lts/ubuntu-14.04lts-server-odroid-xu3-20150725.img.xz $ unxz ubuntu-14.04lts-server-odroid-xu3-20150725.img.xz $ sudo dd if=ubuntu-14.04lts-server-odroid-xu3-20150725.img of=/dev/sdc bs=1M conv=fsync $ sync ===== Bootloader ===== Bootloader must enable HYP mode to support virtualization before jump to kernel. So, it is needed to reinstall bootloader. Install Bootloader to support HYP mode: $ git clone https://github.com/hardkernel/u-boot.git -b odroidxu3-v2012.07 $ cd u-boot $ make odroid_config $ make ARCH=arm CROSS_COMPILE=arm-none-eabi- -j8 $ cd sd_fuse/hardkernel $ sudo ./sd_fusing.sh /dev/sdc $ sync Changing [[http://git.io/vCu3c|boot.ini]] file for virtualization: $ wget http://git.io/vCu3c -O boot.ini $ sudo cp -f boot.ini /media/boot/ $ sync Note: Please follow [[http://odroid.com/dokuwiki/doku.php?id=en:emmc_recovery_xu3|XU3/XU4 eMMC Bootloader Recovery wiki page]] to burn the bootloader to eMMC. ===== Xen Hypervisor ===== Getting the xen soruce code: $ git clone https://github.com/bkrepo/xen.git -b odroid-xu4 $ cd xen Build & Installation: $ make dist-xen CROSS_COMPILE=arm-none-eabi- XEN_TARGET_ARCH=arm32 debug=y CONFIG_EARLY_PRINTK=exynos5250 -j8 $ sudo cp xen/xen /media/boot/ $ sync ===== Domain 0 Linux kernel ===== Build & Installation: $ git clone https://github.com/bkrepo/linux-dom0.git $ cd linux-dom0 $ make odroidxu3_xen_defconfig ARCH=arm $ make ARCH=arm CROSS_COMPILE=arm-none-eabi- -j8 $ sudo make modules_install ARCH=arm INSTALL_MOD_PATH=/media/rootfs/ $ cp -f arch/arm/boot/zImage arch/arm/boot/dts/exynos5422-odroidxu3.dtb /media/boot/ $ sync ===== Domain 0 Settings ===== **Note** * This step must be done on **ODROID-XU3/4** (id: //root//, password: //odroid//) ==== Xen tools installation==== Getting the xen source code: $ git clone https://github.com/bkrepo/xen.git -b odroid-xu4 $ cd xen Installation packages for xen tools build: $ apt-get update $ apt-get build-dep xen $ apt-get install libpixman-1-dev Building xen tools: $ ./configure --disable-xen --disable-docs $ make dist-tools -j4 $ make install-tools $ update-rc.d xencommons defaults 19 18 $ update-rc.d xendomains defaults 21 20 $ update-rc.d xen-watchdog defaults 22 23 $ ldconfig ==== Network configuration ==== DHCP bridge network configuration: $ apt-get install bridge-utils $ vim /etc/network/interfaces.d/xenbr0 auto xenbr0 inet iface xenbr0 inet dhcp bridge_ports eth0 * //If you want more information about Xen networking, then refer to [[http://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)|this link. ]]// ===== Domain U Settings && Running ===== **(On HOST-PC)** Domain U kernel build preparation: $ wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.2.tar.xz $ tar Jxvf linux-4.2.tar.xz $ cd linux $ make exynos_defconfig ARCH=arm $ make menuconfig ARCH=arm - Kernel Features -> Xen guest support on ARM - Device Drivers -> Block devices -> Xen virtual block device support. - Device Drivers -> Network device support -> Xen network device frontend - Device Drivers -> Xen driver support -> Select all. - System Type -> ARM system type -> Allow multiple platforms to be selected. - System Type -> Multiple platform selection -> ARMv7 based platforms - System Type -> Dummy Virtual Machine. - Device Drivers -> Input Device support -> Miscellaneous devices -> Xen virtual keyboard and mouse support. Patching Domain U kernel source code: $ wget http://git.io/vCV9E -O xen_blkif.patch $ patch -p1 < xen_blkif.patch Build & Installation: $ make ARCH=arm CROSS_COMPILE=arm-none-eabi- zImage -j8 $ sudo cp arch/arm/boot/zImage /media/rootfs/root/ $ sync Creating the [[http://odroid.in/ubuntu_14.04lts/ubuntu-14.04lts-server-odroid-xu3-20150725.img.xz|domain U image(Ubuntu 14.04 server)]]: $ sudo kpartx -v -a ubuntu-14.04lts-server-odroid-xu3-20150725.img $ sudo dd if=/dev/mapper/loop0p2 of=domU.img Modifiying domain U root file system $ mkdir domU-root $ sudo mount domU.img domU-root $ cd domU-root $ vi ./etc/fstab /dev/xvda / ext4 errors=remount-ro 0 1 $ vi ./etc/init/console.conf start on stopped rc RUNLEVEL=[2345] stop on runlevel [!2345] respawn exec /sbin/getty -8 38400 hvc0 $ cd .. $ sudo umount domU-root $ sudo cp domU.img /media/rootfs/root/ $ sync Create the xen configuration file: $ vi domU.cfg kernel = "/root/zImage" memory = 256 maxmem = 256 name = "Domain U" vcpus = 1 cpus = ['1'] serial="pty" disk = [ 'phy:/root/domU.img,xvda,w' ] vif = ['bridge=xenbr0'] extra = 'console=hvc0 xencons=tty root=/dev/xvda rw' $ sudo cp domU.cfg /media/rootfs/root/ $ sync Running virtual machine(**On ODROID-XU3/4**, id: 'root', passwd: 'odroid'): # xl create -c domU.cfg Checking the domain list. (Type the 'CTRL + x + ]' key -> Escaping Domain U, Moving to Domain 0 console.) root@odroid-server:~# xl list Name ID Mem VCPUs State Time(s) Domain-0 0 800 4 r----- 534.3 Domain U 1 256 1 -b---- 49.9 root@odroid-server:~# ===== References ===== * [[http://forum.odroid.com/viewtopic.php?f=98&t=6643|Related Topic in ODROID Forum]] * [[http://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions/OdroidXU|Xen ARM with Virtualization Extensions/OdroidXU]] * [[https://github.com/cypresskr/xen|cypresskr's xen repository]] * [[https://github.com/suriyanr/linux-xen/tree/odroidxu3-3.10.y|suriyanr's domain 0 linux kernel repository]]