i'm currently investigating a Scenario, where a LXC Container, which was created on Ubuntu, is supposed to be migrated to a Container on SLES.
Is there a way to do that? Are there any Tools one could recommend?
i'm currently investigating a Scenario, where a LXC Container, which was created on Ubuntu, is supposed to be migrated to a Container on SLES.
Is there a way to do that? Are there any Tools one could recommend?
There is nothing completely automated end-to-end, but 'virsh' provides a 'domxml-from-native' command that gives you a helping hand in building an XML configuration doc
$ cat container.cfg
lxc.utsname = complex
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.hwaddr = 4a:49:43:49:79:bf
lxc.network.ipv4 = 10.2.3.5/24
lxc.network.type = macvlan
lxc.network.flags = up
lxc.network.link = eth0
lxc.network.hwaddr = 4a:49:43:49:79:bd
lxc.network.ipv4 = 10.2.3.4/24
lxc.network.ipv4 = 192.168.10.125/24
lxc.network.type = phys
lxc.network.flags = up
lxc.network.link = dummy0
lxc.network.hwaddr = 4a:49:43:49:79:ff
lxc.network.ipv4 = 10.2.3.6/24
lxc.cgroup.cpuset.cpus = 0,1
lxc.cgroup.cpu.shares = 1234
lxc.cgroup.devices.deny = a
lxc.cgroup.devices.allow = c 1:3 rw
lxc.cgroup.devices.allow = b 8:0 rw
lxc.rootfs = /mnt/rootfs.complex
lxc.cap.drop = sys_module mknod setuid net_raw
lxc.cap.drop = mac_override
$ virsh -c lxc:/// domxml-from-native lxc-tools container.cfg
<domain type='lxc'>
<name>complex</name>
<uuid>1e600565-6421-4826-a511-20fdd4a5236c</uuid>
<memory unit='KiB'>65536</memory>
<currentMemory unit='KiB'>65536</currentMemory>
<vcpu placement='static' cpuset='0-1'>1</vcpu>
<cputune>
<shares>1234</shares>
</cputune>
<os>
<type>exe</type>
<init>/sbin/init</init>
</os>
<features>
<capabilities policy='allow'>
<mknod state='off'/>
<net_raw state='off'/>
<setuid state='off'/>
<sys_module state='off'/>
</capabilities>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/mnt/rootfs.complex'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='4a:49:43:49:79:bf'/>
<source bridge='br0'/>
<ip address='10.2.3.5' family='ipv4' prefix='24'/>
<link state='up'/>
</interface>
<interface type='direct'>
<mac address='4a:49:43:49:79:bd'/>
<source dev='eth0' mode='private'/>
<ip address='10.2.3.4' family='ipv4' prefix='24'/>
<ip address='192.168.10.125' family='ipv4' prefix='24'/>
<link state='up'/>
</interface>
<hostdev mode='capabilities' type='net'>
<source>
<interface>dummy0</interface>
</source>
<ip address='10.2.3.6' family='ipv4' prefix='24'/>
</hostdev>
</devices>
</domain>
This conversion isn't foolproof and can't handle every possible configuration option, but it should get you going in the write direction. Once you have a suitable XML config, then use virsh -c lxc:/// define
to save it in libvirt