Xen Hypervisor through Yocto Flow

Table of Contents

Building the Xen Image

Running Xen built from Yocto on QEMU or hardware is similar to running any other Yocto images.  First you need to build the Xen image. To do this you will need to have the meta-xilinx layer and the meta-petalinux layer cloned. Then bulid the xen-image-minimal image. Note that only ZynqMP supports Xen.

Booting Xen

Once that has built you can boot it on either QEMU or hardware. See Booting Yocto Images on QEMU and Meta-Xilinx Booting README for detailed steps on how to do this.
As mentioned in thoses links sometimes the u-boot TFTP images are named differently in the Yocto output compared to what u-boot expects. I generally run these two commands before booting Xen on QEMU to solve the problem.
Once you get to the u-boot prompt use the built in xen or xen_qemu command to TFTP boot Xen. You will probably need to run dhcp first.
The u-boot shipped with the 2016.3 release doesn't work with Ethernet on all boards, if you see this problem you will need to use an older version of u-boot, use u-boot from PetaLinux or try SDBoot instead.
You have now booted Xen and Dom0 ontop of Xen. You can login to Dom0 using the username 'root'.

Xilinx has included some example Xen configurations to help users get started with running DomUs ontop of Xen. These are avaliable in /etc/xen/
You can then use xl to create a DomU based on a configuration file. For more options and information about xl run:
Once you have started a DomU the console input/output will transfer to that guest. You can get control back to Dom0 by typing the following
You can also transfer the input/output back to Xen by pressing:

Simple Example

This is the simplist example and can be started with:

Para-Virtulised Network Example

This is a slightly more complex example and requires some steps before starting DomU. Once you have logeed into Domo run the following commands:
You should now see the DHCP server start up. It will look something like this:
Now create the DomU guest to make use of the para-virtualised network.

Passthrough Network Example

This is the most complex example and requires work before booting Xen. If booting on hardware you need to set the GEM to issue NS DMA transactions. This can be done after running FSBL:
This step is not required if running on QEMU, but all other steps below apply to both hardware and QEMU.

When booting from u-boot use the following command instead of the run commands mentioned above.
These commands are similar to the xen_qemu and xen commands mentioned before, but they have these two extra commands in the middle:
This is required to ensure that Dom0 doesn't use the GEM device so that we can pass it to DomU.

This will start Domo similar to before. Now start Dom1 using the xl command.

Where is the RootFS?

All of the steps above will result in an error when booting DomU as there is no rootFS included in Dom0's RootFS. The Dom0 kernel image is included in the Dom0 rootFS which is why the kernel boots but then panics when no rootFS can be found.

The config files can be edited to point to a specific kernel image and rootFS to use when booting DomU. This image and configuration is up to the user to determine and select. The kernel used in the examples above is just the Dom0 kernel. If you would like a specific DomU kernel you will need to build and boot that yourselvf.

One option is to load the images on an SD card, see here for details on how to do that: Starting Linux guests with Pass-through networking

Another option is to get the rootFS into the Dom0 kernel image is to add a diff similar to this to the meta-petalinux layer. This diff has been applied onto the 2017.1 (morty) release of meta-petalinux