35 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.
35.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 15 using the official DVD media.
After the upgrade, install the
libvirt-daemon-lxc
andlibvirt-daemon-config-network
packages.Create a
libvirt
XML configurationlxc_container.xml
from the existing containerlxc_container
:>
sudo
virt-lxc-convert /etc/lxc/lxc_container/config > lxc_container.xmlCheck 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.xml
file for any weird or missing configuration. Note that some LXC configuration options cannot be mapped tolibvirt
configuration. Although the conversion should usually be fine, check Section 34.4, “Differences between the libvirt LXC Driver and LXC” for more details.Define the container in
libvirt
based on the created XML definition:>
sudo
virsh -c lxc:/// define lxc_container.xml
35.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 15
as well to get everything working.
The
baseproduct
file is missing (andzypper
keeps 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/baseproductAdd 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 SLES15-0Disable or remove previous repositories:
#
zypper --root $ROOTFS lr | Alias | Name | Enabled | Refresh --+-----------------------------+------------------------------+---------+-------- 1 | SLES12 | SLES12 | Yes | No 2 | SUSE-[...]-Server-12-SP3 38 | SUSE-[...]-Server-12-SP3 138 | Yes | No#
zypper --root $ROOTFS rr 2Disable or remove previous repositories:
#
zypper --root $ROOTFS lr | Alias | Name | Enabled | Refresh --+-----------------------------+------------------------------+---------+-------- 1 | openSUSE 42.3 Main | openSUSE 42.3 Main | Yes | No 2 | openSUSE 42.3 Update | openSUSE 42.3 Update | Yes | No#
zypper --root $ROOTFS rr 2Upgrade the container:
#
zypper --root $ROOTFS dupInstall the Minimal pattern to make sure everything required is installed:
#
zypper --root $ROOTFS in -t pattern Minimal
35.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