]>
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.ipv6.address",
112 "2003:db8:1:0:214:1234:fe0b:3596/64")) {
113 lxc_error("%s\n", "lxc.net.1.ipv6.address");
117 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway",
118 "2003:db8:1:0::1")) {
119 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
123 if (!c
->set_config_item(c
, "lxc.net.1.flags", "up")) {
124 lxc_error("%s\n", "lxc.net.1.flags");
128 if (!c
->set_config_item(c
, "lxc.net.1.link", "br0")) {
129 lxc_error("%s\n", "lxc.net.1.link");
133 if (!c
->set_config_item(c
, "lxc.net.1.veth.pair", "bla")) {
134 lxc_error("%s\n", "lxc.net.1.veth.pair");
138 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv4.route", "192.0.2.1/32")) {
139 lxc_error("%s\n", "lxc.net.1.veth.ipv4.route");
143 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv6.route", "2001:db8::1/128")) {
144 lxc_error("%s\n", "lxc.net.1.veth.ipv6.route");
148 if (!c
->set_config_item(c
, "lxc.net.1.hwaddr",
149 "52:54:00:80:7a:5d")) {
150 lxc_error("%s\n", "lxc.net.1.hwaddr");
154 if (!c
->set_config_item(c
, "lxc.net.1.mtu", "2000")) {
155 lxc_error("%s\n", "lxc.net.1.mtu");
159 if (!c
->clear_config_item(c
, "lxc.net.1")) {
160 lxc_error("%s", "failed to clear \"lxc.net.1\"\n");
170 static int set_invalid_netdev(struct lxc_container
*c
) {
171 if (c
->set_config_item(c
, "lxc.net.0.asdf", "veth")) {
172 lxc_error("%s\n", "lxc.net.0.asdf should be invalid");
176 if (c
->set_config_item(c
, "lxc.net.2147483647.type", "veth")) {
177 lxc_error("%s\n", "lxc.net.2147483647.type should be invalid");
181 if (c
->set_config_item(c
, "lxc.net.0.", "veth")) {
182 lxc_error("%s\n", "lxc.net.0. should be invalid");
192 int test_idmap_parser(void)
199 static struct idmap_check idmaps
[] = {
203 { true, "u 1 100001 999999999" },
204 { true, "g 1 100001 999999999" },
207 { true, "u 1000 165536 65536" },
208 { true, "g 999 999 1" },
209 { true, "u 0 5000 100000" },
210 { true, "g 577 789 5" },
211 { true, "u 65536 65536 1 " },
213 { false, "1u 0 0 0" },
214 { false, "1g 0 0 0a" },
215 { false, "1 u 0 0 0" },
216 { false, "1g 0 0 0 1" },
217 { false, "1u a0 b0 c0 d1" },
218 { false, "1g 0 b0 0 d1" },
219 { false, "1u a0 0 c0 1" },
220 { false, "g -1 0 -10" },
221 { false, "a 1 0 10" },
222 { false, "u 1 1 0 10" },
223 { false, "g 1 0 10 z " },
226 for (i
= 0; i
< sizeof(idmaps
) / sizeof(struct idmap_check
); i
++) {
227 unsigned long hostid
, nsid
, range
;
230 ret
= parse_idmaps(idmaps
[i
].idmap
, &type
, &nsid
, &hostid
,
232 if ((ret
< 0 && idmaps
[i
].is_valid
) ||
233 (ret
== 0 && !idmaps
[i
].is_valid
)) {
234 lxc_error("failed to parse idmap \"%s\"\n",
243 static int set_get_compare_clear_save_load_network(
244 struct lxc_container
*c
, const char *key
, const char *value
,
245 const char *config_file
, bool compare
, const char *network_type
)
247 char retval
[4096] = {0};
250 if (!c
->set_config_item(c
, "lxc.net.0.type", network_type
)) {
251 lxc_error("%s\n", "lxc.net.0.type");
255 if (!c
->set_config_item(c
, key
, value
)) {
256 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
261 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
263 lxc_error("failed to get config item \"%s\"\n", key
);
268 ret
= strcmp(retval
, value
);
271 "expected value \"%s\" and retrieved value \"%s\" "
272 "for config key \"%s\" do not match\n",
279 if (!c
->save_config(c
, config_file
)) {
280 lxc_error("%s\n", "failed to save config file");
287 if (!c
->load_config(c
, config_file
)) {
288 lxc_error("%s\n", "failed to load config file");
293 if (!c
->clear_config_item(c
, key
)) {
294 lxc_error("failed to clear config item \"%s\"\n", key
);
298 if (!c
->clear_config_item(c
, "lxc.net.0.type")) {
299 lxc_error("%s\n", "lxc.net.0.type");
309 int main(int argc
, char *argv
[])
312 struct lxc_container
*c
;
313 int fd
= -1, fret
= EXIT_FAILURE
;
314 char tmpf
[] = "lxc-parse-config-file-XXXXXX";
315 char retval
[4096] = {0};
317 fd
= lxc_make_tmpfile(tmpf
, false);
319 lxc_error("%s\n", "Could not create temporary file");
324 c
= lxc_container_new(tmpf
, NULL
);
326 lxc_error("%s\n", "Failed to create new container");
330 if (set_get_compare_clear_save_load(c
, "lxc.arch", "x86_64", tmpf
,
332 lxc_error("%s\n", "lxc.arch");
336 if (set_get_compare_clear_save_load(c
, "lxc.pty.max", "1000", tmpf
, true) < 0) {
337 lxc_error("%s\n", "lxc.pty.max");
341 if (set_get_compare_clear_save_load(c
, "lxc.tty.max", "4", tmpf
, true) < 0) {
342 lxc_error("%s\n", "lxc.tty.max");
346 if (set_get_compare_clear_save_load(c
, "lxc.tty.dir", "not-dev", tmpf
, true) < 0) {
347 lxc_error("%s\n", "lxc.tty.dir");
351 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.profile", "unconfined", tmpf
, true) < 0) {
352 lxc_error("%s\n", "lxc.apparmor.profile");
356 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.allow_incomplete", "1", tmpf
, true) < 0) {
357 lxc_error("%s\n", "lxc.apparmor.allow_incomplete");
361 if (set_get_compare_clear_save_load(c
, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22", tmpf
, true) < 0) {
362 lxc_error("%s\n", "lxc.selinux.context");
366 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.cpuset.cpus",
367 "1-100", tmpf
, false) < 0) {
368 lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
372 if (!c
->set_config_item(c
, "lxc.cgroup.cpuset.cpus", "1-100")) {
373 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
377 if (!c
->set_config_item(c
, "lxc.cgroup.memory.limit_in_bytes", "123456789")) {
378 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
382 if (!c
->get_config_item(c
, "lxc.cgroup", retval
, sizeof(retval
))) {
383 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
391 * We can't really save the config here since save_config() wants to
392 * chown the container's directory but we haven't created an on-disk
393 * container. So let's test set-get-clear.
395 if (set_get_compare_clear_save_load(c
, "lxc.idmap", "u 0 100000 1000000000", NULL
, false) < 0) {
396 lxc_error("%s\n", "lxc.idmap");
400 if (!c
->set_config_item(c
, "lxc.idmap", "u 1 100000 10000000")) {
401 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"u 1 100000 10000000\"");
405 if (!c
->set_config_item(c
, "lxc.idmap", "g 1 100000 10000000")) {
406 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"g 1 100000 10000000\"");
410 if (!c
->get_config_item(c
, "lxc.idmap", retval
, sizeof(retval
))) {
411 lxc_error("%s\n", "failed to get config item \"lxc.idmap\"");
418 if (set_get_compare_clear_save_load(c
, "lxc.log.level", "DEBUG", tmpf
, true) < 0) {
419 lxc_error("%s\n", "lxc.log.level");
423 if (set_get_compare_clear_save_load(c
, "lxc.log.file", "/some/path", tmpf
, true) < 0) {
424 lxc_error("%s\n", "lxc.log.file");
428 if (set_get_compare_clear_save_load(c
, "lxc.mount.fstab", "/some/path", NULL
, true) < 0) {
429 lxc_error("%s\n", "lxc.mount.fstab");
434 * Note that we cannot compare the values since the getter for
435 * lxc.mount.auto does not preserve ordering.
437 if (set_get_compare_clear_save_load(c
, "lxc.mount.auto", "proc:rw sys:rw cgroup-full:rw", tmpf
, false) < 0) {
438 lxc_error("%s\n", "lxc.mount.auto");
443 * Note that we cannot compare the values since the getter for
444 * lxc.mount.entry appends newlines.
446 if (set_get_compare_clear_save_load(c
, "lxc.mount.entry", "/dev/dri dev/dri none bind,optional,create=dir", tmpf
, false) < 0) {
447 lxc_error("%s\n", "lxc.mount.entry");
451 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.path", "/some/path", tmpf
, true) < 0) {
452 lxc_error("%s\n", "lxc.rootfs.path");
456 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.mount", "/some/path", tmpf
, true) < 0) {
457 lxc_error("%s\n", "lxc.rootfs.mount");
461 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.options", "ext4,discard", tmpf
, true) < 0) {
462 lxc_error("%s\n", "lxc.rootfs.options");
466 if (set_get_compare_clear_save_load(c
, "lxc.uts.name", "the-shire", tmpf
, true) < 0) {
467 lxc_error("%s\n", "lxc.uts.name");
471 if (set_get_compare_clear_save_load(
472 c
, "lxc.hook.pre-start", "/some/pre-start", tmpf
, false) < 0) {
473 lxc_error("%s\n", "lxc.hook.pre-start");
477 if (set_get_compare_clear_save_load(
478 c
, "lxc.hook.pre-mount", "/some/pre-mount", tmpf
, false) < 0) {
479 lxc_error("%s\n", "lxc.hook.pre-mount");
483 if (set_get_compare_clear_save_load(c
, "lxc.hook.mount", "/some/mount", tmpf
, false) < 0) {
484 lxc_error("%s\n", "lxc.hook.mount");
488 if (set_get_compare_clear_save_load(c
, "lxc.hook.autodev", "/some/autodev", tmpf
, false) < 0) {
489 lxc_error("%s\n", "lxc.hook.autodev");
493 if (set_get_compare_clear_save_load(c
, "lxc.hook.start", "/some/start", tmpf
, false) < 0) {
494 lxc_error("%s\n", "lxc.hook.start");
498 if (set_get_compare_clear_save_load(c
, "lxc.hook.stop", "/some/stop", tmpf
, false) < 0) {
499 lxc_error("%s\n", "lxc.hook.stop");
503 if (set_get_compare_clear_save_load(c
, "lxc.hook.post-stop", "/some/post-stop", tmpf
, false) < 0) {
504 lxc_error("%s\n", "lxc.hook.post-stop");
508 if (set_get_compare_clear_save_load(c
, "lxc.hook.clone", "/some/clone", tmpf
, false) < 0) {
509 lxc_error("%s\n", "lxc.hook.clone");
513 if (set_get_compare_clear_save_load(c
, "lxc.hook.destroy", "/some/destroy", tmpf
, false) < 0) {
514 lxc_error("%s\n", "lxc.hook.destroy");
518 if (set_get_compare_clear_save_load(c
, "lxc.cap.drop", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
519 lxc_error("%s\n", "lxc.cap.drop");
523 if (set_get_compare_clear_save_load(c
, "lxc.cap.keep", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
524 lxc_error("%s\n", "lxc.cap.keep");
528 if (set_get_compare_clear_save_load(c
, "lxc.console.path", "none", tmpf
, true) < 0) {
529 lxc_error("%s\n", "lxc.console.path");
533 if (set_get_compare_clear_save_load(c
, "lxc.console.logfile", "/some/logfile", tmpf
, true) < 0) {
534 lxc_error("%s\n", "lxc.console.logfile");
538 if (set_get_compare_clear_save_load(c
, "lxc.seccomp.profile", "/some/seccomp/file", tmpf
, true) < 0) {
539 lxc_error("%s\n", "lxc.seccomp.profile");
543 if (set_get_compare_clear_save_load(c
, "lxc.autodev", "1", tmpf
, true) <
545 lxc_error("%s\n", "lxc.autodev");
549 if (set_get_compare_clear_save_load(c
, "lxc.signal.halt", "1", tmpf
, true) < 0) {
550 lxc_error("%s\n", "lxc.signal.halt");
554 if (set_get_compare_clear_save_load(c
, "lxc.signal.reboot", "1", tmpf
, true) < 0) {
555 lxc_error("%s\n", "lxc.signal.reboot");
559 if (set_get_compare_clear_save_load(c
, "lxc.signal.stop", "1", tmpf
, true) < 0) {
560 lxc_error("%s\n", "lxc.signal.stop");
564 if (set_get_compare_clear_save_load(c
, "lxc.start.auto", "1", tmpf
, true) < 0) {
565 lxc_error("%s\n", "lxc.start.auto");
569 if (set_get_compare_clear_save_load(c
, "lxc.start.delay", "5", tmpf
, true) < 0) {
570 lxc_error("%s\n", "lxc.start.delay");
574 if (set_get_compare_clear_save_load(c
, "lxc.start.order", "1", tmpf
, true) < 0) {
575 lxc_error("%s\n", "lxc.start.order");
579 if (set_get_compare_clear_save_load(c
, "lxc.log.syslog", "local0", tmpf
, true) < 0) {
580 lxc_error("%s\n", "lxc.log.syslog");
584 if (set_get_compare_clear_save_load(c
, "lxc.monitor.unshare", "1", tmpf
, true) < 0) {
585 lxc_error("%s\n", "lxc.monitor.unshare");
589 if (set_get_compare_clear_save_load(c
, "lxc.group", "some,container,groups", tmpf
, false) < 0) {
590 lxc_error("%s\n", "lxc.group");
594 if (set_get_compare_clear_save_load(c
, "lxc.environment", "FOO=BAR", tmpf
, false) < 0) {
595 lxc_error("%s\n", "lxc.environment");
599 if (set_get_compare_clear_save_load(c
, "lxc.init.cmd", "/bin/bash", tmpf
, true) < 0) {
600 lxc_error("%s\n", "lxc.init.cmd");
604 if (set_get_compare_clear_save_load(c
, "lxc.init.uid", "1000", tmpf
, true) < 0) {
605 lxc_error("%s\n", "lxc.init.uid");
609 if (set_get_compare_clear_save_load(c
, "lxc.init.gid", "1000", tmpf
, true) < 0) {
610 lxc_error("%s\n", "lxc.init.gid");
614 if (set_get_compare_clear_save_load(c
, "lxc.ephemeral", "1", tmpf
, true) < 0) {
615 lxc_error("%s\n", "lxc.ephemeral");
619 if (set_get_compare_clear_save_load(c
, "lxc.no_new_privs", "1", tmpf
, true) < 0) {
620 lxc_error("%s\n", "lxc.no_new_privs");
624 if (set_get_compare_clear_save_load(c
, "lxc.sysctl.net.core.somaxconn", "256", tmpf
, true) < 0) {
625 lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
629 if (set_get_compare_clear_save_load(c
, "lxc.proc.oom_score_adj", "10", tmpf
, true) < 0) {
630 lxc_error("%s\n", "lxc.proc.oom_score_adj");
634 if (set_get_compare_clear_save_load(c
, "lxc.prlimit.nofile", "65536", tmpf
, true) < 0) {
635 lxc_error("%s\n", "lxc.prlimit.nofile");
639 if (test_idmap_parser() < 0) {
640 lxc_error("%s\n", "failed to test parser for \"lxc.id_map\"");
644 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "veth", tmpf
, true)) {
645 lxc_error("%s\n", "lxc.net.0.type");
649 if (set_get_compare_clear_save_load(c
, "lxc.net.2.type", "none", tmpf
, true)) {
650 lxc_error("%s\n", "lxc.net.2.type");
654 if (set_get_compare_clear_save_load(c
, "lxc.net.3.type", "empty", tmpf
, true)) {
655 lxc_error("%s\n", "lxc.net.3.type");
659 if (set_get_compare_clear_save_load(c
, "lxc.net.4.type", "vlan", tmpf
, true)) {
660 lxc_error("%s\n", "lxc.net.4.type");
664 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "macvlan", tmpf
, true)) {
665 lxc_error("%s\n", "lxc.net.0.type");
669 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "ipvlan", tmpf
, true)) {
670 lxc_error("%s\n", "lxc.net.0.type");
674 if (set_get_compare_clear_save_load(c
, "lxc.net.1000.type", "phys", tmpf
, true)) {
675 lxc_error("%s\n", "lxc.net.1000.type");
679 if (set_get_compare_clear_save_load(c
, "lxc.net.0.flags", "up", tmpf
, true)) {
680 lxc_error("%s\n", "lxc.net.0.flags");
684 if (set_get_compare_clear_save_load(c
, "lxc.net.0.name", "eth0", tmpf
, true)) {
685 lxc_error("%s\n", "lxc.net.0.name");
689 if (set_get_compare_clear_save_load(c
, "lxc.net.0.link", "bla", tmpf
, true)) {
690 lxc_error("%s\n", "lxc.net.0.link");
694 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "private", tmpf
, true, "macvlan")) {
695 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
699 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "vepa", tmpf
, true, "macvlan")) {
700 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
704 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "bridge", tmpf
, true, "macvlan")) {
705 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
709 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3", tmpf
, true, "ipvlan")) {
710 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
714 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3s", tmpf
, true, "ipvlan")) {
715 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
719 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l2", tmpf
, true, "ipvlan")) {
720 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
724 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "bridge", tmpf
, true, "ipvlan")) {
725 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
729 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "private", tmpf
, true, "ipvlan")) {
730 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
734 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "vepa", tmpf
, true, "ipvlan")) {
735 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
739 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.pair", "clusterfuck", tmpf
, true, "veth")) {
740 lxc_error("%s\n", "lxc.net.0.veth.pair");
744 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv4.route", "192.0.2.1/32", tmpf
, true, "veth")) {
745 lxc_error("%s\n", "lxc.net.0.veth.ipv4.route");
749 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv6.route", "2001:db8::1/128", tmpf
, true, "veth")) {
750 lxc_error("%s\n", "lxc.net.0.veth.ipv6.route");
754 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.up", "/some/up/path", tmpf
, true)) {
755 lxc_error("%s\n", "lxc.net.0.script.up");
759 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.down", "/some/down/path", tmpf
, true)) {
760 lxc_error("%s\n", "lxc.net.0.script.down");
764 if (set_get_compare_clear_save_load(c
, "lxc.net.0.hwaddr", "52:54:00:80:7a:5d", tmpf
, true)) {
765 lxc_error("%s\n", "lxc.net.0.hwaddr");
769 if (set_get_compare_clear_save_load(c
, "lxc.net.0.mtu", "2000", tmpf
, true)) {
770 lxc_error("%s\n", "lxc.net.0.mtu");
774 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.vlan.id", "2", tmpf
, true, "vlan")) {
775 lxc_error("%s\n", "lxc.net.0.vlan.id");
779 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "10.0.2.2", tmpf
, true)) {
780 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
784 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "2003:db8:1::1", tmpf
, true)) {
785 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
789 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.address", "10.0.2.3/24", tmpf
, true)) {
790 lxc_error("%s\n", "lxc.net.0.ipv4.address");
794 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64", tmpf
, true)) {
795 lxc_error("%s\n", "lxc.net.0.ipv6.address");
799 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.dir", "lxd", tmpf
, true)) {
800 lxc_error("%s\n", "lxc.cgroup.dir");
804 if (set_and_clear_complete_netdev(c
) < 0) {
805 lxc_error("%s\n", "failed to clear whole network");
809 if (set_invalid_netdev(c
) < 0) {
810 lxc_error("%s\n", "failed to reject invalid configuration");
814 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "1", tmpf
, true);
816 lxc_error("%s\n", "lxc.hook.version");
820 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "2", tmpf
, true);
822 lxc_error("%s\n", "lxc.hook.version");
826 ret
= set_get_compare_clear_save_load(c
, "lxc.monitor.signal.pdeath", "SIGKILL", tmpf
, true);
828 lxc_error("%s\n", "lxc.hook.version");
832 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.managed", "1", tmpf
, true) < 0) {
833 lxc_error("%s\n", "lxc.rootfs.managed");
837 if (c
->set_config_item(c
, "lxc.notaconfigkey", "invalid")) {
838 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.notaconfigkey\" to \"invalid\"");
846 (void)rmdir(dirname(c
->configfile
));
847 lxc_container_put(c
);