]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/parse_config_file.c
3 * Copyright © 2017 Christian Brauner <christian.brauner@ubuntu.com>.
4 * Copyright © 2017 Canonical Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <lxc/lxccontainer.h>
26 #include <sys/types.h>
32 #include "confile_utils.h"
33 #include "lxc/state.h"
37 static int set_get_compare_clear_save_load(struct lxc_container
*c
,
38 const char *key
, const char *value
,
39 const char *config_file
,
42 char retval
[4096] = {0};
45 if (!c
->set_config_item(c
, key
, value
)) {
46 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
51 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
53 lxc_error("failed to get config item \"%s\"\n", key
);
58 ret
= strcmp(retval
, value
);
61 "expected value \"%s\" and retrieved value \"%s\" "
62 "for config key \"%s\" do not match\n",
69 if (!c
->save_config(c
, config_file
)) {
70 lxc_error("%s\n", "failed to save config file");
77 if (!c
->load_config(c
, config_file
)) {
78 lxc_error("%s\n", "failed to load config file");
83 if (!c
->clear_config_item(c
, key
)) {
84 lxc_error("failed to clear config item \"%s\"\n", key
);
94 static int set_and_clear_complete_netdev(struct lxc_container
*c
)
96 if (!c
->set_config_item(c
, "lxc.net.1.type", "veth")) {
97 lxc_error("%s\n", "lxc.net.1.type");
101 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.address", "10.0.2.3/24")) {
102 lxc_error("%s\n", "lxc.net.1.ipv4.address");
106 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "10.0.2.2")) {
107 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
111 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "auto")) {
112 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
116 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "dev")) {
117 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
121 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.address",
122 "2003:db8:1:0:214:1234:fe0b:3596/64")) {
123 lxc_error("%s\n", "lxc.net.1.ipv6.address");
127 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway",
128 "2003:db8:1:0::1")) {
129 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
133 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway", "auto")) {
134 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
138 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway", "dev")) {
139 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
143 if (!c
->set_config_item(c
, "lxc.net.1.flags", "up")) {
144 lxc_error("%s\n", "lxc.net.1.flags");
148 if (!c
->set_config_item(c
, "lxc.net.1.link", "br0")) {
149 lxc_error("%s\n", "lxc.net.1.link");
153 if (!c
->set_config_item(c
, "lxc.net.1.veth.pair", "bla")) {
154 lxc_error("%s\n", "lxc.net.1.veth.pair");
158 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv4.route", "192.0.2.1/32")) {
159 lxc_error("%s\n", "lxc.net.1.veth.ipv4.route");
163 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv6.route", "2001:db8::1/128")) {
164 lxc_error("%s\n", "lxc.net.1.veth.ipv6.route");
168 if (!c
->set_config_item(c
, "lxc.net.1.hwaddr",
169 "52:54:00:80:7a:5d")) {
170 lxc_error("%s\n", "lxc.net.1.hwaddr");
174 if (!c
->set_config_item(c
, "lxc.net.1.mtu", "2000")) {
175 lxc_error("%s\n", "lxc.net.1.mtu");
179 if (!c
->clear_config_item(c
, "lxc.net.1")) {
180 lxc_error("%s", "failed to clear \"lxc.net.1\"\n");
190 static int set_invalid_netdev(struct lxc_container
*c
) {
191 if (c
->set_config_item(c
, "lxc.net.0.asdf", "veth")) {
192 lxc_error("%s\n", "lxc.net.0.asdf should be invalid");
196 if (c
->set_config_item(c
, "lxc.net.2147483647.type", "veth")) {
197 lxc_error("%s\n", "lxc.net.2147483647.type should be invalid");
201 if (c
->set_config_item(c
, "lxc.net.0.", "veth")) {
202 lxc_error("%s\n", "lxc.net.0. should be invalid");
212 int test_idmap_parser(void)
219 static struct idmap_check idmaps
[] = {
223 { true, "u 1 100001 999999999" },
224 { true, "g 1 100001 999999999" },
227 { true, "u 1000 165536 65536" },
228 { true, "g 999 999 1" },
229 { true, "u 0 5000 100000" },
230 { true, "g 577 789 5" },
231 { true, "u 65536 65536 1 " },
233 { false, "1u 0 0 0" },
234 { false, "1g 0 0 0a" },
235 { false, "1 u 0 0 0" },
236 { false, "1g 0 0 0 1" },
237 { false, "1u a0 b0 c0 d1" },
238 { false, "1g 0 b0 0 d1" },
239 { false, "1u a0 0 c0 1" },
240 { false, "g -1 0 -10" },
241 { false, "a 1 0 10" },
242 { false, "u 1 1 0 10" },
243 { false, "g 1 0 10 z " },
246 for (i
= 0; i
< sizeof(idmaps
) / sizeof(struct idmap_check
); i
++) {
247 unsigned long hostid
, nsid
, range
;
250 ret
= parse_idmaps(idmaps
[i
].idmap
, &type
, &nsid
, &hostid
,
252 if ((ret
< 0 && idmaps
[i
].is_valid
) ||
253 (ret
== 0 && !idmaps
[i
].is_valid
)) {
254 lxc_error("failed to parse idmap \"%s\"\n",
263 static int set_get_compare_clear_save_load_network(
264 struct lxc_container
*c
, const char *key
, const char *value
,
265 const char *config_file
, bool compare
, const char *network_type
)
267 char retval
[4096] = {0};
270 if (!c
->set_config_item(c
, "lxc.net.0.type", network_type
)) {
271 lxc_error("%s\n", "lxc.net.0.type");
275 if (!c
->set_config_item(c
, key
, value
)) {
276 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
281 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
283 lxc_error("failed to get config item \"%s\"\n", key
);
288 ret
= strcmp(retval
, value
);
291 "expected value \"%s\" and retrieved value \"%s\" "
292 "for config key \"%s\" do not match\n",
299 if (!c
->save_config(c
, config_file
)) {
300 lxc_error("%s\n", "failed to save config file");
307 if (!c
->load_config(c
, config_file
)) {
308 lxc_error("%s\n", "failed to load config file");
313 if (!c
->clear_config_item(c
, key
)) {
314 lxc_error("failed to clear config item \"%s\"\n", key
);
318 if (!c
->clear_config_item(c
, "lxc.net.0.type")) {
319 lxc_error("%s\n", "lxc.net.0.type");
329 int main(int argc
, char *argv
[])
332 struct lxc_container
*c
;
333 int fd
= -1, fret
= EXIT_FAILURE
;
334 char tmpf
[] = "lxc-parse-config-file-XXXXXX";
335 char retval
[4096] = {0};
337 fd
= lxc_make_tmpfile(tmpf
, false);
339 lxc_error("%s\n", "Could not create temporary file");
344 c
= lxc_container_new(tmpf
, NULL
);
346 lxc_error("%s\n", "Failed to create new container");
350 if (set_get_compare_clear_save_load(c
, "lxc.arch", "x86_64", tmpf
,
352 lxc_error("%s\n", "lxc.arch");
356 if (set_get_compare_clear_save_load(c
, "lxc.pty.max", "1000", tmpf
, true) < 0) {
357 lxc_error("%s\n", "lxc.pty.max");
361 if (set_get_compare_clear_save_load(c
, "lxc.tty.max", "4", tmpf
, true) < 0) {
362 lxc_error("%s\n", "lxc.tty.max");
366 if (set_get_compare_clear_save_load(c
, "lxc.tty.dir", "not-dev", tmpf
, true) < 0) {
367 lxc_error("%s\n", "lxc.tty.dir");
371 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.profile", "unconfined", tmpf
, true) < 0) {
372 lxc_error("%s\n", "lxc.apparmor.profile");
376 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.allow_incomplete", "1", tmpf
, true) < 0) {
377 lxc_error("%s\n", "lxc.apparmor.allow_incomplete");
381 if (set_get_compare_clear_save_load(c
, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22", tmpf
, true) < 0) {
382 lxc_error("%s\n", "lxc.selinux.context");
386 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.cpuset.cpus",
387 "1-100", tmpf
, false) < 0) {
388 lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
392 if (!c
->set_config_item(c
, "lxc.cgroup.cpuset.cpus", "1-100")) {
393 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
397 if (!c
->set_config_item(c
, "lxc.cgroup.memory.limit_in_bytes", "123456789")) {
398 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
402 if (!c
->get_config_item(c
, "lxc.cgroup", retval
, sizeof(retval
))) {
403 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
411 * We can't really save the config here since save_config() wants to
412 * chown the container's directory but we haven't created an on-disk
413 * container. So let's test set-get-clear.
415 if (set_get_compare_clear_save_load(c
, "lxc.idmap", "u 0 100000 1000000000", NULL
, false) < 0) {
416 lxc_error("%s\n", "lxc.idmap");
420 if (!c
->set_config_item(c
, "lxc.idmap", "u 1 100000 10000000")) {
421 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"u 1 100000 10000000\"");
425 if (!c
->set_config_item(c
, "lxc.idmap", "g 1 100000 10000000")) {
426 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"g 1 100000 10000000\"");
430 if (!c
->get_config_item(c
, "lxc.idmap", retval
, sizeof(retval
))) {
431 lxc_error("%s\n", "failed to get config item \"lxc.idmap\"");
438 if (set_get_compare_clear_save_load(c
, "lxc.log.level", "DEBUG", tmpf
, true) < 0) {
439 lxc_error("%s\n", "lxc.log.level");
443 if (set_get_compare_clear_save_load(c
, "lxc.log.file", "/some/path", tmpf
, true) < 0) {
444 lxc_error("%s\n", "lxc.log.file");
448 if (set_get_compare_clear_save_load(c
, "lxc.mount.fstab", "/some/path", NULL
, true) < 0) {
449 lxc_error("%s\n", "lxc.mount.fstab");
454 * Note that we cannot compare the values since the getter for
455 * lxc.mount.auto does not preserve ordering.
457 if (set_get_compare_clear_save_load(c
, "lxc.mount.auto", "proc:rw sys:rw cgroup-full:rw", tmpf
, false) < 0) {
458 lxc_error("%s\n", "lxc.mount.auto");
463 * Note that we cannot compare the values since the getter for
464 * lxc.mount.entry appends newlines.
466 if (set_get_compare_clear_save_load(c
, "lxc.mount.entry", "/dev/dri dev/dri none bind,optional,create=dir", tmpf
, false) < 0) {
467 lxc_error("%s\n", "lxc.mount.entry");
471 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.path", "/some/path", tmpf
, true) < 0) {
472 lxc_error("%s\n", "lxc.rootfs.path");
476 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.mount", "/some/path", tmpf
, true) < 0) {
477 lxc_error("%s\n", "lxc.rootfs.mount");
481 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.options", "ext4,discard", tmpf
, true) < 0) {
482 lxc_error("%s\n", "lxc.rootfs.options");
486 if (set_get_compare_clear_save_load(c
, "lxc.uts.name", "the-shire", tmpf
, true) < 0) {
487 lxc_error("%s\n", "lxc.uts.name");
491 if (set_get_compare_clear_save_load(
492 c
, "lxc.hook.pre-start", "/some/pre-start", tmpf
, false) < 0) {
493 lxc_error("%s\n", "lxc.hook.pre-start");
497 if (set_get_compare_clear_save_load(
498 c
, "lxc.hook.pre-mount", "/some/pre-mount", tmpf
, false) < 0) {
499 lxc_error("%s\n", "lxc.hook.pre-mount");
503 if (set_get_compare_clear_save_load(c
, "lxc.hook.mount", "/some/mount", tmpf
, false) < 0) {
504 lxc_error("%s\n", "lxc.hook.mount");
508 if (set_get_compare_clear_save_load(c
, "lxc.hook.autodev", "/some/autodev", tmpf
, false) < 0) {
509 lxc_error("%s\n", "lxc.hook.autodev");
513 if (set_get_compare_clear_save_load(c
, "lxc.hook.start", "/some/start", tmpf
, false) < 0) {
514 lxc_error("%s\n", "lxc.hook.start");
518 if (set_get_compare_clear_save_load(c
, "lxc.hook.stop", "/some/stop", tmpf
, false) < 0) {
519 lxc_error("%s\n", "lxc.hook.stop");
523 if (set_get_compare_clear_save_load(c
, "lxc.hook.post-stop", "/some/post-stop", tmpf
, false) < 0) {
524 lxc_error("%s\n", "lxc.hook.post-stop");
528 if (set_get_compare_clear_save_load(c
, "lxc.hook.clone", "/some/clone", tmpf
, false) < 0) {
529 lxc_error("%s\n", "lxc.hook.clone");
533 if (set_get_compare_clear_save_load(c
, "lxc.hook.destroy", "/some/destroy", tmpf
, false) < 0) {
534 lxc_error("%s\n", "lxc.hook.destroy");
538 if (set_get_compare_clear_save_load(c
, "lxc.cap.drop", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
539 lxc_error("%s\n", "lxc.cap.drop");
543 if (set_get_compare_clear_save_load(c
, "lxc.cap.keep", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
544 lxc_error("%s\n", "lxc.cap.keep");
548 if (set_get_compare_clear_save_load(c
, "lxc.console.path", "none", tmpf
, true) < 0) {
549 lxc_error("%s\n", "lxc.console.path");
553 if (set_get_compare_clear_save_load(c
, "lxc.console.logfile", "/some/logfile", tmpf
, true) < 0) {
554 lxc_error("%s\n", "lxc.console.logfile");
558 if (set_get_compare_clear_save_load(c
, "lxc.seccomp.profile", "/some/seccomp/file", tmpf
, true) < 0) {
559 lxc_error("%s\n", "lxc.seccomp.profile");
563 if (set_get_compare_clear_save_load(c
, "lxc.autodev.tmpfs.size", "1", tmpf
, true) < 0) {
564 lxc_error("%s\n", "lxc.autodev.tmpfs.size");
568 if (set_get_compare_clear_save_load(c
, "lxc.autodev", "1", tmpf
, true) <
570 lxc_error("%s\n", "lxc.autodev");
574 if (set_get_compare_clear_save_load(c
, "lxc.signal.halt", "1", tmpf
, true) < 0) {
575 lxc_error("%s\n", "lxc.signal.halt");
579 if (set_get_compare_clear_save_load(c
, "lxc.signal.reboot", "1", tmpf
, true) < 0) {
580 lxc_error("%s\n", "lxc.signal.reboot");
584 if (set_get_compare_clear_save_load(c
, "lxc.signal.stop", "1", tmpf
, true) < 0) {
585 lxc_error("%s\n", "lxc.signal.stop");
589 if (set_get_compare_clear_save_load(c
, "lxc.start.auto", "1", tmpf
, true) < 0) {
590 lxc_error("%s\n", "lxc.start.auto");
594 if (set_get_compare_clear_save_load(c
, "lxc.start.delay", "5", tmpf
, true) < 0) {
595 lxc_error("%s\n", "lxc.start.delay");
599 if (set_get_compare_clear_save_load(c
, "lxc.start.order", "1", tmpf
, true) < 0) {
600 lxc_error("%s\n", "lxc.start.order");
604 if (set_get_compare_clear_save_load(c
, "lxc.log.syslog", "local0", tmpf
, true) < 0) {
605 lxc_error("%s\n", "lxc.log.syslog");
609 if (set_get_compare_clear_save_load(c
, "lxc.monitor.unshare", "1", tmpf
, true) < 0) {
610 lxc_error("%s\n", "lxc.monitor.unshare");
614 if (set_get_compare_clear_save_load(c
, "lxc.group", "some,container,groups", tmpf
, false) < 0) {
615 lxc_error("%s\n", "lxc.group");
619 if (set_get_compare_clear_save_load(c
, "lxc.environment", "FOO=BAR", tmpf
, false) < 0) {
620 lxc_error("%s\n", "lxc.environment");
624 if (set_get_compare_clear_save_load(c
, "lxc.init.cmd", "/bin/bash", tmpf
, true) < 0) {
625 lxc_error("%s\n", "lxc.init.cmd");
629 if (set_get_compare_clear_save_load(c
, "lxc.init.uid", "1000", tmpf
, true) < 0) {
630 lxc_error("%s\n", "lxc.init.uid");
634 if (set_get_compare_clear_save_load(c
, "lxc.init.gid", "1000", tmpf
, true) < 0) {
635 lxc_error("%s\n", "lxc.init.gid");
639 if (set_get_compare_clear_save_load(c
, "lxc.ephemeral", "1", tmpf
, true) < 0) {
640 lxc_error("%s\n", "lxc.ephemeral");
644 if (set_get_compare_clear_save_load(c
, "lxc.no_new_privs", "1", tmpf
, true) < 0) {
645 lxc_error("%s\n", "lxc.no_new_privs");
649 if (set_get_compare_clear_save_load(c
, "lxc.sysctl.net.core.somaxconn", "256", tmpf
, true) < 0) {
650 lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
654 if (set_get_compare_clear_save_load(c
, "lxc.proc.oom_score_adj", "10", tmpf
, true) < 0) {
655 lxc_error("%s\n", "lxc.proc.oom_score_adj");
659 if (set_get_compare_clear_save_load(c
, "lxc.prlimit.nofile", "65536", tmpf
, true) < 0) {
660 lxc_error("%s\n", "lxc.prlimit.nofile");
664 if (test_idmap_parser() < 0) {
665 lxc_error("%s\n", "failed to test parser for \"lxc.id_map\"");
669 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "veth", tmpf
, true)) {
670 lxc_error("%s\n", "lxc.net.0.type");
674 if (set_get_compare_clear_save_load(c
, "lxc.net.2.type", "none", tmpf
, true)) {
675 lxc_error("%s\n", "lxc.net.2.type");
679 if (set_get_compare_clear_save_load(c
, "lxc.net.3.type", "empty", tmpf
, true)) {
680 lxc_error("%s\n", "lxc.net.3.type");
684 if (set_get_compare_clear_save_load(c
, "lxc.net.4.type", "vlan", tmpf
, true)) {
685 lxc_error("%s\n", "lxc.net.4.type");
689 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "macvlan", tmpf
, true)) {
690 lxc_error("%s\n", "lxc.net.0.type");
694 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "ipvlan", tmpf
, true)) {
695 lxc_error("%s\n", "lxc.net.0.type");
699 if (set_get_compare_clear_save_load(c
, "lxc.net.1000.type", "phys", tmpf
, true)) {
700 lxc_error("%s\n", "lxc.net.1000.type");
704 if (set_get_compare_clear_save_load(c
, "lxc.net.0.flags", "up", tmpf
, true)) {
705 lxc_error("%s\n", "lxc.net.0.flags");
709 if (set_get_compare_clear_save_load(c
, "lxc.net.0.name", "eth0", tmpf
, true)) {
710 lxc_error("%s\n", "lxc.net.0.name");
714 if (set_get_compare_clear_save_load(c
, "lxc.net.0.link", "bla", tmpf
, true)) {
715 lxc_error("%s\n", "lxc.net.0.link");
719 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "private", tmpf
, true, "macvlan")) {
720 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
724 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "vepa", tmpf
, true, "macvlan")) {
725 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
729 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "bridge", tmpf
, true, "macvlan")) {
730 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
734 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3", tmpf
, true, "ipvlan")) {
735 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
739 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3s", tmpf
, true, "ipvlan")) {
740 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
744 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l2", tmpf
, true, "ipvlan")) {
745 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
749 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "bridge", tmpf
, true, "ipvlan")) {
750 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
754 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "private", tmpf
, true, "ipvlan")) {
755 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
759 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "vepa", tmpf
, true, "ipvlan")) {
760 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
764 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.pair", "clusterfuck", tmpf
, true, "veth")) {
765 lxc_error("%s\n", "lxc.net.0.veth.pair");
769 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv4.route", "192.0.2.1/32", tmpf
, true, "veth")) {
770 lxc_error("%s\n", "lxc.net.0.veth.ipv4.route");
774 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv6.route", "2001:db8::1/128", tmpf
, true, "veth")) {
775 lxc_error("%s\n", "lxc.net.0.veth.ipv6.route");
779 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.up", "/some/up/path", tmpf
, true)) {
780 lxc_error("%s\n", "lxc.net.0.script.up");
784 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.down", "/some/down/path", tmpf
, true)) {
785 lxc_error("%s\n", "lxc.net.0.script.down");
789 if (set_get_compare_clear_save_load(c
, "lxc.net.0.hwaddr", "52:54:00:80:7a:5d", tmpf
, true)) {
790 lxc_error("%s\n", "lxc.net.0.hwaddr");
794 if (set_get_compare_clear_save_load(c
, "lxc.net.0.mtu", "2000", tmpf
, true)) {
795 lxc_error("%s\n", "lxc.net.0.mtu");
799 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.vlan.id", "2", tmpf
, true, "vlan")) {
800 lxc_error("%s\n", "lxc.net.0.vlan.id");
804 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "10.0.2.2", tmpf
, true)) {
805 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
809 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "auto", tmpf
, true)) {
810 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
814 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "dev", tmpf
, true)) {
815 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
819 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "2003:db8:1::1", tmpf
, true)) {
820 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
824 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "auto", tmpf
, true)) {
825 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
829 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "dev", tmpf
, true)) {
830 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
834 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.address", "10.0.2.3/24", tmpf
, true)) {
835 lxc_error("%s\n", "lxc.net.0.ipv4.address");
839 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64", tmpf
, true)) {
840 lxc_error("%s\n", "lxc.net.0.ipv6.address");
844 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.dir", "lxd", tmpf
, true)) {
845 lxc_error("%s\n", "lxc.cgroup.dir");
849 if (set_and_clear_complete_netdev(c
) < 0) {
850 lxc_error("%s\n", "failed to clear whole network");
854 if (set_invalid_netdev(c
) < 0) {
855 lxc_error("%s\n", "failed to reject invalid configuration");
859 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "1", tmpf
, true);
861 lxc_error("%s\n", "lxc.hook.version");
865 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "2", tmpf
, true);
867 lxc_error("%s\n", "lxc.hook.version");
871 ret
= set_get_compare_clear_save_load(c
, "lxc.monitor.signal.pdeath", "SIGKILL", tmpf
, true);
873 lxc_error("%s\n", "lxc.hook.version");
877 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.managed", "1", tmpf
, true) < 0) {
878 lxc_error("%s\n", "lxc.rootfs.managed");
882 if (c
->set_config_item(c
, "lxc.notaconfigkey", "invalid")) {
883 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.notaconfigkey\" to \"invalid\"");
891 (void)rmdir(dirname(c
->configfile
));
892 lxc_container_put(c
);