32 Migration from LXC to libvirt-lxc #
Since SUSE Linux Enterprise Server 12, LXC is integrated into libvirt library. This decision has
several advantages over using LXC as a separate solution—such as a
unified approach with other virtualization solutions or independence on the
kernel used. This chapter describes steps needed to migrate an existing LXC
environment for use with the libvirt library.
32.1 Host Migration #
The migration itself has two phases. You first need to migrate the host,
then the LXC containers. After that, you can run the original containers
as VM Guests in the libvirt environment.
Upgrade the host to SUSE Linux Enterprise Server 12 using the official DVD media.
After the upgrade, install the
libvirt-daemon-lxcandlibvirt-daemon-config-networkpackages.Create a
libvirtXML configurationlxc_container.xmlfrom the existing containerlxc_container:# virt-lxc-convert /etc/lxc/lxc_container/config > lxc_container.xml
Check if the network configuration on the host is the same as in the container configuration file, and fix it if needed.
Check the
lxc_container.xmlfile for any weird or missing configuration. Note that some LXC configuration options cannot be mapped tolibvirtconfiguration. Although the conversion should usually be fine, check Section 31.4, “Differences Between the libvirt LXC Driver and LXC” for more details.Define the container in
libvirtbased on the created XML definition:# virsh -c lxc:/// define lxc_container.xml
32.2 Container Migration #
After the host is migrated, the LXC container in libvirt will not
boot. It needs to be migrated to SUSE Linux Enterprise Server
12 as well to get
everything working.
The
baseproductfile is missing (andzypperkeeps complaining about it). Create the relevant symbolic link:# ROOTFS=/var/lib/lxc/lxc_container/rootfs # ln -s $ROOTFS/etc/products.d/SUSE_SLES.prod $ROOTFS/etc/products.d/baseproduct
Add the DVD repository. Note that you need to replace the DVD device with the one attached to your container:
# zypper --root $ROOTFS ar \ cd:///?devices=/dev/dvd SLES12-12
Disable or remove previous repositories:
# zypper --root $ROOTFS lr | Alias | Name | Enabled | Refresh --+-----------------------------+------------------------------+---------+-------- 1 | SLES12-12 | SLES12-12 | Yes | No 2 | SUSE-[...]-Server-11-SP3 38 | SUSE-[...]-Server-11-SP3 138 | Yes | No # zypper --root $ROOTFS rr 2
Upgrade the container:
# zypper --root $ROOTFS dup
Install the Minimal pattern to make sure everything required is installed:
# zypper --root $ROOTFS in -t pattern Minimal
32.3 Starting the Container #
After the host and container migration is complete, the container can be started:
# virsh -c lxc:/// start lxc_container
If you need to get a console to view the logging messages produced by the container, run:
# virsh -c lxc:/// console lxc_container