Install xen on Fedora20
Installing the Packages
To install the Xen Project software, just run:
1 | # yum install xen |
as root. yum will, as usual, take care of downloading and installing anything that is needed. As a part of that, it also create a new GRUB2 boot menu entry. Once the installation is complete, just reboot and select “Xen 4.x.x” from the GRUB2 menu.
If on Fedora 18 and 19, you will likely see something like “Xen 4.2.x”. If on Fedora 16 or 17, it will have “Xen 4.1.x” in it. It is also possible that you only see something like “Fedora, with Xen hypervisor”, and that is also ok.
Networking deserves some special attention. In fact, it is something that gave a lot of trouble in the past (Xen 3/4.0). That is why, from Xen Project 4.1 on, the default behavior is to let the dom0’s network scripts (i.e., the ones that came with the distribution, not the ones that come with Xen Project) handle setting up a network bridge, and let the toolstack just attach the domU’s network interface to the it. More on this matter down in the page.
Booting the Xen Project hypervisor by Default
Although a Xen Project GRUB2 menu entry will be automatically created, it will likely not be the default one. To make it so, ensure to you have a line like this in /etc/default/grub:
1 | GRUB_DEFAULT=saved |
and then do
1 | # grub2-mkconfig -o /boot/grub2/grub.cfg |
Typically, it would be something like this:
1 | # grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 |
Disabling Network Manager
In case of any networking issues, or if you want to manually manage the network configuration, disabling NetworkManager is necessary (e.g., because NetworkManager does not support bridges), and that requires manually editing a couple of config files. This is particularly true if you do not plan to install and use the typical Fedora virtualization tools, like libvirt, etc. In fact, libvirt automatically creates a bridge and sets up the VMs created via its interface(s) to use it by default. On the other hand, if not using libvirt, the bridge has to be created by hand.
For Red Hat-based distros, the networking configuration is stored in /etc/sysconfig/network-scripts/.
Also, make sure that the network service is kicked off automatically on subsequent restarts by running:
1 | # chkconfig network on |
Next, create the configuration file for the bridge. The most common bridge name is br0, so let’s stick to that (although other Xen Project documentation suggests using xenbr0 to make it obvious that the bridge is for the hypervisor):
1 | # touch /etc/sysconfig/network-scripts/ifcfg-xenbr0 |
open the file in a text editor and put the following lines in it:
1 | DEVICE=xenbr0 |
Next, you need to find the configuration file for your existing network adaptor. It’s most likely named ifcfg-eth0 or ifcfg-em0 (the part after the dash can and does change depending on the actual hardware). Once you know what config file you’re using, open it, find the line
1 | NM_CONTROLLED=yes |
and change it to
1 | NM_CONTROLLED=no |
Also, do not forget to add the line
1 | BRIDGE=xenbr0 |
(or whatever you named your bridge) to that file.
Finally, run this:
1 | # systemctl restart network.service |
and the bridge should look like this:
1 | # ifconfig xenbr0 |
Note that in earlier versions of Fedora (prior to 21), libvirt with xen would always assume that the default bridge was ‘xenbr0’. And even if you did change the option (using the libvirt overrides) it would ignore it. Fedora 21 libvirt has that fixed.
Rebooting and “Running” the Xen Project hypervisor
Now that the software is installed, (re)boot in the proper option, as explained above, and check it’s working, e.g., by running xl info from the command line, which should then tell something like this:
1 | # xl info |
If the hypervisor is not working, you’ll get something like:
1 | libxl: error: libxl.c:56:libxl_ctx_init Is xenstore daemon running? |
If you get something like the error message above, double check that all the needed servic are up and running and, if not, make sure they start automatically at boot. That is the case of xenconsoled.service and xenstored.service are enabled and running. You can check their status with #systemctl status xenstored. If it says something like “inactive (dead)”, do the following:
1 | # systemctl enable xenstored |
(and the same for xenconsoled)