This commit includes new test cases to cover LXC version 3.0 and higher.
This LXC version rebased some settings entries and deprecated other ones.
As we support both, we should include tests to minimize problems with
integration between them.
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.blkio.weight = 500
+lxc.cgroup.blkio.device_weight = 8:16 1000
+lxc.cgroup.blkio.device_weight = 8:0 300
+lxc.cgroup.blkio.throttle.read_bps_device = 8:16 1234
+lxc.cgroup.blkio.throttle.write_bps_device = 8:16 5678
+lxc.cgroup.blkio.throttle.read_iops_device = 8:16 4321
+lxc.cgroup.blkio.throttle.write_iops_device = 8:16 8765
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.cpuset.cpus = 1,2,5-7
+lxc.cgroup.cpuset.mems = 1-4
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+lxc.cgroup.cpu.shares = 1024
+lxc.cgroup.cpu.cfs_quota_us = -1
+lxc.cgroup.cpu.cfs_period_us = 500000
--- /dev/null
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = veth
+lxc.network.flags = up
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.name = eth0
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+#remove next line if host DNS configuration should not be available to container
+lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
+lxc.mount.entry = sysfs sys sysfs defaults 0 0
+lxc.mount.entry = tmpfs run tmpfs size=8m,mode=0755,nodev,nosuid 0 0
+lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.arch = x86
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+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
--- /dev/null
+# 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.fstab = /var/lib/lxc/migrate_test/fstab
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+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
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+
+lxc.idmap = u 10000 0 2000
+lxc.idmap = g 10000 0 1000
--- /dev/null
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = macvlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.macvlan.mode = vepa
+
+#remove next line if host DNS configuration should not be available to container
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+
+# 1GiB
+lxc.cgroup.memory.limit_in_bytes = 1073741824
+# 128MiB
+lxc.cgroup.memory.soft_limit_in_bytes = 134217728
+# 2GiB
+lxc.cgroup.memory.memsw.limit_in_bytes = 2147483648
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
+lxc.network.type = none
--- /dev/null
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
--- /dev/null
+lxc.network.type = phys
+lxc.network.link = eth0
+lxc.network.name = eth1
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
--- /dev/null
+# 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
+lxc.network.ipv4 = 192.168.122.2/24
+lxc.network.ipv4.gateway = 192.168.122.1
+lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596/64
+lxc.network.ipv6.gateway = 2003:db8:1:0:214:1234:fe0b:3595
+
+#remove next line if host DNS configuration should not be available to container
+lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
+lxc.mount.entry = sysfs sys sysfs defaults 0 0
+lxc.mount.entry = tmpfs run tmpfs size=8m,mode=0755,nodev,nosuid 0 0
+lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,ro 0 0
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.arch = x86
+lxc.autodev=1
+lxc.tty.max = 2
+lxc.pts = 1024
+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
--- /dev/null
+# Template used to create this container: opensuse
+# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
+
+lxc.network.type = vlan
+lxc.network.flags = up
+lxc.network.link = eth0
+lxc.network.hwaddr = 02:00:15:8f:05:c1
+lxc.network.vlan.id = 2
+
+lxc.rootfs.path = /var/lib/lxc/migrate_test/rootfs
+lxc.uts.name = migrate_test
+lxc.autodev=1
};
static int
-testCompareXMLToConfigHelper(const void *data)
+testCompareXMLToConfigHelperLegacy(const void *data)
{
int result = -1;
const struct testInfo *info = data;
return result;
}
+static int
+testCompareXMLToConfigHelperV3(const void *data)
+{
+ int result = -1;
+ const struct testInfo *info = data;
+ char *xml = NULL;
+ char *config = NULL;
+
+ if (virAsprintf(&xml, "%s/lxcconf2xmldata/lxcconf2xml-%s.xml",
+ abs_srcdir, info->name) < 0 ||
+ virAsprintf(&config, "%s/lxcconf2xmldata/lxcconf2xml-%s-v3.config",
+ abs_srcdir, info->name) < 0)
+ goto cleanup;
+
+ result = testCompareXMLToConfigFiles(xml, config, info->expectError);
+
+ cleanup:
+ VIR_FREE(xml);
+ VIR_FREE(config);
+ return result;
+}
+
+
static int
mymain(void)
{
do { \
const struct testInfo info = { name, expectError }; \
if (virTestRun("LXC Native-2-XML " name, \
- testCompareXMLToConfigHelper, \
+ testCompareXMLToConfigHelperLegacy, \
&info) < 0) \
ret = EXIT_FAILURE; \
} while (0)
DO_TEST("blkiotune", false);
DO_TEST("ethernet", false);
+ /* Tests for LXC 3.0 and higher */
+# define DO_TEST3(name, expectError) \
+ do { \
+ const struct testInfo info = { name, expectError }; \
+ if (virTestRun("LXC Native-3-XML " name, \
+ testCompareXMLToConfigHelperV3, \
+ &info) < 0) \
+ ret = EXIT_FAILURE; \
+ } while (0)
+
+ DO_TEST3("simple", false);
+ DO_TEST3("fstab", true);
+ DO_TEST3("nonetwork", false);
+ DO_TEST3("nonenetwork", false);
+ DO_TEST3("physnetwork", false);
+ DO_TEST3("macvlannetwork", false);
+ DO_TEST3("vlannetwork", false);
+ DO_TEST3("idmap", false);
+ DO_TEST3("memtune", false);
+ DO_TEST3("cputune", false);
+ DO_TEST3("cpusettune", false);
+ DO_TEST3("blkiotune", false);
+ DO_TEST3("ethernet", false);
+
virObjectUnref(xmlopt);
virObjectUnref(caps);