Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
Applies to openSUSE Leap 15.1

32 Migration from LXC to libvirt-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.

32.1 Host Migration Edit source

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.

Procedure 32.1: Host Migration
  1. Upgrade the host to openSUSE Leap 15 using the official DVD media.

  2. After the upgrade, install the libvirt-daemon-lxc and libvirt-daemon-config-network packages.

  3. Create a libvirt XML configuration lxc_container.xml from the existing container lxc_container:

    tux > sudo virt-lxc-convert /etc/lxc/lxc_container/config > lxc_container.xml
  4. Check if the network configuration on the host is the same as in the container configuration file, and fix it if needed.

  5. 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 31.4, “Differences between the libvirt LXC Driver and LXC” for more details.

  6. Define the container in libvirt based on the created XML definition:

    tux > sudo virsh -c lxc:/// define lxc_container.xml

32.2 Container Migration Edit source

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.

Procedure 32.2: Container Migration
  1. The baseproduct file is missing (and zypper keeps complaining about it). Create the relevant symbolic link:

    root # ROOTFS=/var/lib/lxc/lxc_container/rootfs
    root # ln -s $ROOTFS/etc/products.d/SUSE_SLES.prod $ROOTFS/etc/products.d/baseproduct
  2. Add the DVD repository. Note that you need to replace the DVD device with the one attached to your container:

  3. 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     | No
    root # zypper --root $ROOTFS rr 2
    root # zypper --root $ROOTFS ar \
    cd:///?devices=/dev/dvd "openSUSE 15"
  4. 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     | No
    root # zypper --root $ROOTFS rr 2
  5. Upgrade the container:

    root # zypper --root $ROOTFS dup
  6. Install the Minimal pattern to make sure everything required is installed:

    root # zypper --root $ROOTFS in -t pattern Minimal

32.3 Starting the Container Edit source

After the host and container migration is complete, the container can be started:

root # virsh -c lxc:/// start lxc_container

If you need to get a console to view the logging messages produced by the container, run:

root # virsh -c lxc:/// console lxc_container
Print this page