libvirtlibvirt-lxc #Edit source
Since openSUSE
Leap, 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.
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 openSUSE Leap 15 using the official DVD media.
After the upgrade, install the
libvirt-daemon-lxc and
libvirt-daemon-config-network packages.
Create a libvirt XML configuration
lxc_container.xml from the existing container
lxc_container:
tux >sudovirt-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.xml file for any weird or
missing configuration. Note that some LXC configuration options
cannot be mapped to libvirt configuration. Although the conversion
should usually be fine, check Section 32.4, “Differences between the libvirt LXC Driver and LXC” for more
details.
Define the container in libvirt based on the created XML
definition:
tux >sudovirsh -c lxc:/// define lxc_container.xml
After the host is migrated, the LXC container in libvirt will not
boot. It needs to be migrated to
openSUSE Leap 15
as well to get everything working.
The baseproduct file is missing (and
zypper keeps complaining about it). Create the
relevant symbolic link:
root #ROOTFS=/var/lib/lxc/lxc_container/rootfsroot #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:
Disable or remove previous repositories:
root #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 | Noroot #zypper --root $ROOTFS rr 2
root # zypper --root $ROOTFS ar \
cd:///?devices=/dev/dvd "openSUSE 15"Disable or remove previous repositories:
root #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 | Noroot #zypper --root $ROOTFS rr 2
Upgrade the container:
root # zypper --root $ROOTFS dupInstall the Minimal pattern to make sure everything required is installed:
root # zypper --root $ROOTFS in -t pattern MinimalAfter the host and container migration is complete, the container can be started:
root # virsh -c lxc:/// start lxc_containerIf you need to get a console to view the logging messages produced by the container, run:
root # virsh -c lxc:/// console lxc_container