Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
documentation.suse.com / Documentation de SUSE Linux Enterprise Server / Virtualization Guide / Managing Virtual Machines with LXC / Migration from LXC to libvirt-lxc
Applies to SUSE Linux Enterprise Server 12 SP5

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.

Procedure 32.1: Host Migration
  1. Upgrade the host to SUSE Linux Enterprise Server 12 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:

    # 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:

    # 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.

Procedure 32.2: Container Migration
  1. The baseproduct file is missing (and zypper 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/baseproduct
  2. 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
  3. 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
  4. Upgrade the container:

    # zypper --root $ROOTFS dup
  5. 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