[libvirt] [PATCH 01/16] LXC driver: started implementing connectDomainXMLFromNative

Daniel P. Berrange berrange at redhat.com
Fri Jan 24 13:17:55 UTC 2014


On Tue, Jan 14, 2014 at 02:49:50PM +0100, Cédric Bosdonnat wrote:
> This function aims at converting LXC configuration into a libvirt
> domain XML description to help users migrate from LXC to libvirt.
> 
> Here is an example of how the lxc configuration works:
> virsh -c lxc:/// domxml-from-native lxc /var/lib/lxc/migrate_test/config
> 
> It is possible that some parts couldn't be properly mapped into a
> domain XML fragment, so users should carefully review the result
> before creating the domain.
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> new file mode 100644
> index 0000000..14b2844
> --- /dev/null
> +++ b/src/lxc/lxc_native.c

> diff --git a/tests/lxcconf2xmldata/lxcconf2xml-simple.config b/tests/lxcconf2xmldata/lxcconf2xml-simple.config
> new file mode 100644
> index 0000000..12428bb
> --- /dev/null
> +++ b/tests/lxcconf2xmldata/lxcconf2xml-simple.config
> @@ -0,0 +1,38 @@
> +# Template used to create this container: opensuse
> +# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
> +
> +lxc.network.type = veth
> +lxc.network.flags = up
> +lxc.network.link = virbr0
> +lxc.network.hwaddr = 02:00:15:8f:05:c1
> +lxc.network.name = eth0
> +
> +#remove next line if host DNS configuration should not be available to container
> +lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0
> +lxc.rootfs = /var/lib/lxc/migrate_test/rootfs
> +lxc.utsname = migrate_test
> +lxc.autodev=1
> +lxc.tty = 2
> +lxc.pts = 1024
> +lxc.mount = /var/lib/lxc/migrate_test/fstab
> +lxc.cap.drop = sys_module mac_admin mac_override mknod
> +
> +# When using LXC with apparmor, uncomment the next line to run unconfined:
> +#lxc.aa_profile = unconfined
> +
> +lxc.cgroup.devices.deny = a
> +# /dev/null and zero
> +lxc.cgroup.devices.allow = c 1:3 rwm
> +lxc.cgroup.devices.allow = c 1:5 rwm
> +# consoles
> +lxc.cgroup.devices.allow = c 5:1 rwm
> +lxc.cgroup.devices.allow = c 5:0 rwm
> +lxc.cgroup.devices.allow = c 4:0 rwm
> +lxc.cgroup.devices.allow = c 4:1 rwm
> +# /dev/{,u}random
> +lxc.cgroup.devices.allow = c 1:9 rwm
> +lxc.cgroup.devices.allow = c 1:8 rwm
> +lxc.cgroup.devices.allow = c 136:* rwm
> +lxc.cgroup.devices.allow = c 5:2 rwm
> +# rtc
> +lxc.cgroup.devices.allow = c 254:0 rwm

This data format looks really very close to the .vmx file format.
The main difference I see is that the right hand side of the =
sign does not require quotes.

We already have a src/util/virconf.{c,h} module which was originally
designed to parse Xen's python-like config files. It was then extended
to cope with .vmx files. It seems like it should be easy to extend it
to handle the lxc file format too. 

eg define a new VIR_CONF_FLAG_LXC_FORMAT  flag for it parser to honour

> diff --git a/tests/lxcconf2xmldata/lxcconf2xml.fstab b/tests/lxcconf2xmldata/lxcconf2xml.fstab
> new file mode 100644
> index 0000000..a08b2d6
> --- /dev/null
> +++ b/tests/lxcconf2xmldata/lxcconf2xml.fstab
> @@ -0,0 +1,3 @@
> +proc            proc         proc	nodev,noexec,nosuid 0 0
> +sysfs           sys          sysfs	defaults  0 0
> +tmpfs           run          tmpfs	mode=0755,nodev,nosuid 0 0

Hmm, how are the fstab files handled ? The virConnectDomainNativeToXML
API only allows a single config file to be passed into ?

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list