]>
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.
22 #include <lxc/lxccontainer.h>
29 #include <sys/types.h>
35 #include "confile_utils.h"
40 static int set_get_compare_clear_save_load(struct lxc_container
*c
,
41 const char *key
, const char *value
,
42 const char *config_file
,
45 char retval
[4096] = {0};
48 if (!c
->set_config_item(c
, key
, value
)) {
49 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
54 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
56 lxc_error("failed to get config item \"%s\"\n", key
);
61 ret
= strcmp(retval
, value
);
64 "expected value \"%s\" and retrieved value \"%s\" "
65 "for config key \"%s\" do not match\n",
72 if (!c
->save_config(c
, config_file
)) {
73 lxc_error("%s\n", "failed to save config file");
80 if (!c
->load_config(c
, config_file
)) {
81 lxc_error("%s\n", "failed to load config file");
86 if (!c
->clear_config_item(c
, key
)) {
87 lxc_error("failed to clear config item \"%s\"\n", key
);
97 static int set_and_clear_complete_netdev(struct lxc_container
*c
)
99 if (!c
->set_config_item(c
, "lxc.net.1.type", "veth")) {
100 lxc_error("%s\n", "lxc.net.1.type");
104 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.address", "10.0.2.3/24")) {
105 lxc_error("%s\n", "lxc.net.1.ipv4.address");
109 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "10.0.2.2")) {
110 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
114 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "auto")) {
115 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
119 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "dev")) {
120 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
124 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.address",
125 "2003:db8:1:0:214:1234:fe0b:3596/64")) {
126 lxc_error("%s\n", "lxc.net.1.ipv6.address");
130 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway",
131 "2003:db8:1:0::1")) {
132 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
136 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway", "auto")) {
137 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
141 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway", "dev")) {
142 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
146 if (!c
->set_config_item(c
, "lxc.net.1.flags", "up")) {
147 lxc_error("%s\n", "lxc.net.1.flags");
151 if (!c
->set_config_item(c
, "lxc.net.1.link", "br0")) {
152 lxc_error("%s\n", "lxc.net.1.link");
156 if (!c
->set_config_item(c
, "lxc.net.1.veth.pair", "bla")) {
157 lxc_error("%s\n", "lxc.net.1.veth.pair");
161 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv4.route", "192.0.2.1/32")) {
162 lxc_error("%s\n", "lxc.net.1.veth.ipv4.route");
166 if (!c
->set_config_item(c
, "lxc.net.1.veth.ipv6.route", "2001:db8::1/128")) {
167 lxc_error("%s\n", "lxc.net.1.veth.ipv6.route");
171 if (!c
->set_config_item(c
, "lxc.net.1.hwaddr",
172 "52:54:00:80:7a:5d")) {
173 lxc_error("%s\n", "lxc.net.1.hwaddr");
177 if (!c
->set_config_item(c
, "lxc.net.1.mtu", "2000")) {
178 lxc_error("%s\n", "lxc.net.1.mtu");
182 if (!c
->clear_config_item(c
, "lxc.net.1")) {
183 lxc_error("%s", "failed to clear \"lxc.net.1\"\n");
193 static int set_invalid_netdev(struct lxc_container
*c
) {
194 if (c
->set_config_item(c
, "lxc.net.0.asdf", "veth")) {
195 lxc_error("%s\n", "lxc.net.0.asdf should be invalid");
199 if (c
->set_config_item(c
, "lxc.net.2147483647.type", "veth")) {
200 lxc_error("%s\n", "lxc.net.2147483647.type should be invalid");
204 if (c
->set_config_item(c
, "lxc.net.0.", "veth")) {
205 lxc_error("%s\n", "lxc.net.0. should be invalid");
215 int test_idmap_parser(void)
222 static struct idmap_check idmaps
[] = {
226 { true, "u 1 100001 999999999" },
227 { true, "g 1 100001 999999999" },
230 { true, "u 1000 165536 65536" },
231 { true, "g 999 999 1" },
232 { true, "u 0 5000 100000" },
233 { true, "g 577 789 5" },
234 { true, "u 65536 65536 1 " },
236 { false, "1u 0 0 0" },
237 { false, "1g 0 0 0a" },
238 { false, "1 u 0 0 0" },
239 { false, "1g 0 0 0 1" },
240 { false, "1u a0 b0 c0 d1" },
241 { false, "1g 0 b0 0 d1" },
242 { false, "1u a0 0 c0 1" },
243 { false, "g -1 0 -10" },
244 { false, "a 1 0 10" },
245 { false, "u 1 1 0 10" },
246 { false, "g 1 0 10 z " },
249 for (i
= 0; i
< sizeof(idmaps
) / sizeof(struct idmap_check
); i
++) {
250 unsigned long hostid
, nsid
, range
;
253 ret
= parse_idmaps(idmaps
[i
].idmap
, &type
, &nsid
, &hostid
,
255 if ((ret
< 0 && idmaps
[i
].is_valid
) ||
256 (ret
== 0 && !idmaps
[i
].is_valid
)) {
257 lxc_error("failed to parse idmap \"%s\"\n",
266 static int set_get_compare_clear_save_load_network(
267 struct lxc_container
*c
, const char *key
, const char *value
,
268 const char *config_file
, bool compare
, const char *network_type
)
270 char retval
[4096] = {0};
273 if (!c
->set_config_item(c
, "lxc.net.0.type", network_type
)) {
274 lxc_error("%s\n", "lxc.net.0.type");
278 if (!c
->set_config_item(c
, key
, value
)) {
279 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
284 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
286 lxc_error("failed to get config item \"%s\"\n", key
);
291 ret
= strcmp(retval
, value
);
294 "expected value \"%s\" and retrieved value \"%s\" "
295 "for config key \"%s\" do not match\n",
302 if (!c
->save_config(c
, config_file
)) {
303 lxc_error("%s\n", "failed to save config file");
310 if (!c
->load_config(c
, config_file
)) {
311 lxc_error("%s\n", "failed to load config file");
316 if (!c
->clear_config_item(c
, key
)) {
317 lxc_error("failed to clear config item \"%s\"\n", key
);
321 if (!c
->clear_config_item(c
, "lxc.net.0.type")) {
322 lxc_error("%s\n", "lxc.net.0.type");
332 int main(int argc
, char *argv
[])
335 struct lxc_container
*c
;
336 int fd
= -1, fret
= EXIT_FAILURE
;
337 char tmpf
[] = "lxc-parse-config-file-XXXXXX";
338 char retval
[4096] = {0};
340 fd
= lxc_make_tmpfile(tmpf
, false);
342 lxc_error("%s\n", "Could not create temporary file");
347 c
= lxc_container_new(tmpf
, NULL
);
349 lxc_error("%s\n", "Failed to create new container");
353 if (set_get_compare_clear_save_load(c
, "lxc.arch", "x86_64", tmpf
,
355 lxc_error("%s\n", "lxc.arch");
359 if (set_get_compare_clear_save_load(c
, "lxc.pty.max", "1000", tmpf
, true) < 0) {
360 lxc_error("%s\n", "lxc.pty.max");
364 if (set_get_compare_clear_save_load(c
, "lxc.tty.max", "4", tmpf
, true) < 0) {
365 lxc_error("%s\n", "lxc.tty.max");
369 if (set_get_compare_clear_save_load(c
, "lxc.tty.dir", "not-dev", tmpf
, true) < 0) {
370 lxc_error("%s\n", "lxc.tty.dir");
374 ret
= set_get_compare_clear_save_load(c
, "lxc.apparmor.profile", "unconfined", tmpf
, true);
381 lxc_error("%s\n", "lxc.apparmor.profile");
385 ret
= set_get_compare_clear_save_load(c
, "lxc.apparmor.allow_incomplete", "1", tmpf
, true);
392 lxc_error("%s\n", "lxc.apparmor.allow_incomplete");
396 ret
= set_get_compare_clear_save_load(c
, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22", tmpf
, true);
403 lxc_error("%s\n", "lxc.selinux.context");
407 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.cpuset.cpus",
408 "1-100", tmpf
, false) < 0) {
409 lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
413 if (!c
->set_config_item(c
, "lxc.cgroup.cpuset.cpus", "1-100")) {
414 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
418 if (!c
->set_config_item(c
, "lxc.cgroup.memory.limit_in_bytes", "123456789")) {
419 lxc_error("%s\n", "failed to set config item \"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
423 if (!c
->get_config_item(c
, "lxc.cgroup", retval
, sizeof(retval
))) {
424 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
432 * We can't really save the config here since save_config() wants to
433 * chown the container's directory but we haven't created an on-disk
434 * container. So let's test set-get-clear.
436 if (set_get_compare_clear_save_load(c
, "lxc.idmap", "u 0 100000 1000000000", NULL
, false) < 0) {
437 lxc_error("%s\n", "lxc.idmap");
441 if (!c
->set_config_item(c
, "lxc.idmap", "u 1 100000 10000000")) {
442 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"u 1 100000 10000000\"");
446 if (!c
->set_config_item(c
, "lxc.idmap", "g 1 100000 10000000")) {
447 lxc_error("%s\n", "failed to set config item \"lxc.idmap\" to \"g 1 100000 10000000\"");
451 if (!c
->get_config_item(c
, "lxc.idmap", retval
, sizeof(retval
))) {
452 lxc_error("%s\n", "failed to get config item \"lxc.idmap\"");
459 if (set_get_compare_clear_save_load(c
, "lxc.log.level", "DEBUG", tmpf
, true) < 0) {
460 lxc_error("%s\n", "lxc.log.level");
464 if (set_get_compare_clear_save_load(c
, "lxc.log.file", "/some/path", tmpf
, true) < 0) {
465 lxc_error("%s\n", "lxc.log.file");
469 if (set_get_compare_clear_save_load(c
, "lxc.mount.fstab", "/some/path", NULL
, true) < 0) {
470 lxc_error("%s\n", "lxc.mount.fstab");
475 * Note that we cannot compare the values since the getter for
476 * lxc.mount.auto does not preserve ordering.
478 if (set_get_compare_clear_save_load(c
, "lxc.mount.auto", "proc:rw sys:rw cgroup-full:rw", tmpf
, false) < 0) {
479 lxc_error("%s\n", "lxc.mount.auto");
484 * Note that we cannot compare the values since the getter for
485 * lxc.mount.entry appends newlines.
487 if (set_get_compare_clear_save_load(c
, "lxc.mount.entry", "/dev/dri dev/dri none bind,optional,create=dir", tmpf
, false) < 0) {
488 lxc_error("%s\n", "lxc.mount.entry");
492 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.path", "/some/path", tmpf
, true) < 0) {
493 lxc_error("%s\n", "lxc.rootfs.path");
497 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.mount", "/some/path", tmpf
, true) < 0) {
498 lxc_error("%s\n", "lxc.rootfs.mount");
502 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.options", "ext4,discard", tmpf
, true) < 0) {
503 lxc_error("%s\n", "lxc.rootfs.options");
507 if (set_get_compare_clear_save_load(c
, "lxc.uts.name", "the-shire", tmpf
, true) < 0) {
508 lxc_error("%s\n", "lxc.uts.name");
512 if (set_get_compare_clear_save_load(
513 c
, "lxc.hook.pre-start", "/some/pre-start", tmpf
, false) < 0) {
514 lxc_error("%s\n", "lxc.hook.pre-start");
518 if (set_get_compare_clear_save_load(
519 c
, "lxc.hook.pre-mount", "/some/pre-mount", tmpf
, false) < 0) {
520 lxc_error("%s\n", "lxc.hook.pre-mount");
524 if (set_get_compare_clear_save_load(c
, "lxc.hook.mount", "/some/mount", tmpf
, false) < 0) {
525 lxc_error("%s\n", "lxc.hook.mount");
529 if (set_get_compare_clear_save_load(c
, "lxc.hook.autodev", "/some/autodev", tmpf
, false) < 0) {
530 lxc_error("%s\n", "lxc.hook.autodev");
534 if (set_get_compare_clear_save_load(c
, "lxc.hook.start", "/some/start", tmpf
, false) < 0) {
535 lxc_error("%s\n", "lxc.hook.start");
539 if (set_get_compare_clear_save_load(c
, "lxc.hook.stop", "/some/stop", tmpf
, false) < 0) {
540 lxc_error("%s\n", "lxc.hook.stop");
544 if (set_get_compare_clear_save_load(c
, "lxc.hook.post-stop", "/some/post-stop", tmpf
, false) < 0) {
545 lxc_error("%s\n", "lxc.hook.post-stop");
549 if (set_get_compare_clear_save_load(c
, "lxc.hook.clone", "/some/clone", tmpf
, false) < 0) {
550 lxc_error("%s\n", "lxc.hook.clone");
554 if (set_get_compare_clear_save_load(c
, "lxc.hook.destroy", "/some/destroy", tmpf
, false) < 0) {
555 lxc_error("%s\n", "lxc.hook.destroy");
559 if (set_get_compare_clear_save_load(c
, "lxc.cap.drop", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
560 lxc_error("%s\n", "lxc.cap.drop");
564 if (set_get_compare_clear_save_load(c
, "lxc.cap.keep", "sys_module mknod setuid net_raw", tmpf
, false) < 0) {
565 lxc_error("%s\n", "lxc.cap.keep");
569 if (set_get_compare_clear_save_load(c
, "lxc.console.path", "none", tmpf
, true) < 0) {
570 lxc_error("%s\n", "lxc.console.path");
574 if (set_get_compare_clear_save_load(c
, "lxc.console.logfile", "/some/logfile", tmpf
, true) < 0) {
575 lxc_error("%s\n", "lxc.console.logfile");
579 if (set_get_compare_clear_save_load(c
, "lxc.seccomp.profile", "/some/seccomp/file", tmpf
, true) < 0) {
580 lxc_error("%s\n", "lxc.seccomp.profile");
584 if (set_get_compare_clear_save_load(c
, "lxc.autodev.tmpfs.size", "1", tmpf
, true) < 0) {
585 lxc_error("%s\n", "lxc.autodev.tmpfs.size");
589 if (set_get_compare_clear_save_load(c
, "lxc.autodev", "1", tmpf
, true) <
591 lxc_error("%s\n", "lxc.autodev");
595 if (set_get_compare_clear_save_load(c
, "lxc.signal.halt", "1", tmpf
, true) < 0) {
596 lxc_error("%s\n", "lxc.signal.halt");
600 if (set_get_compare_clear_save_load(c
, "lxc.signal.reboot", "1", tmpf
, true) < 0) {
601 lxc_error("%s\n", "lxc.signal.reboot");
605 if (set_get_compare_clear_save_load(c
, "lxc.signal.stop", "1", tmpf
, true) < 0) {
606 lxc_error("%s\n", "lxc.signal.stop");
610 if (set_get_compare_clear_save_load(c
, "lxc.start.auto", "1", tmpf
, true) < 0) {
611 lxc_error("%s\n", "lxc.start.auto");
615 if (set_get_compare_clear_save_load(c
, "lxc.start.delay", "5", tmpf
, true) < 0) {
616 lxc_error("%s\n", "lxc.start.delay");
620 if (set_get_compare_clear_save_load(c
, "lxc.start.order", "1", tmpf
, true) < 0) {
621 lxc_error("%s\n", "lxc.start.order");
625 if (set_get_compare_clear_save_load(c
, "lxc.log.syslog", "local0", tmpf
, true) < 0) {
626 lxc_error("%s\n", "lxc.log.syslog");
630 if (set_get_compare_clear_save_load(c
, "lxc.monitor.unshare", "1", tmpf
, true) < 0) {
631 lxc_error("%s\n", "lxc.monitor.unshare");
635 if (set_get_compare_clear_save_load(c
, "lxc.group", "some,container,groups", tmpf
, false) < 0) {
636 lxc_error("%s\n", "lxc.group");
640 if (set_get_compare_clear_save_load(c
, "lxc.environment", "FOO=BAR", tmpf
, false) < 0) {
641 lxc_error("%s\n", "lxc.environment");
645 if (set_get_compare_clear_save_load(c
, "lxc.init.cmd", "/bin/bash", tmpf
, true) < 0) {
646 lxc_error("%s\n", "lxc.init.cmd");
650 if (set_get_compare_clear_save_load(c
, "lxc.init.uid", "1000", tmpf
, true) < 0) {
651 lxc_error("%s\n", "lxc.init.uid");
655 if (set_get_compare_clear_save_load(c
, "lxc.init.gid", "1000", tmpf
, true) < 0) {
656 lxc_error("%s\n", "lxc.init.gid");
660 if (set_get_compare_clear_save_load(c
, "lxc.ephemeral", "1", tmpf
, true) < 0) {
661 lxc_error("%s\n", "lxc.ephemeral");
665 if (set_get_compare_clear_save_load(c
, "lxc.no_new_privs", "1", tmpf
, true) < 0) {
666 lxc_error("%s\n", "lxc.no_new_privs");
670 if (set_get_compare_clear_save_load(c
, "lxc.sysctl.net.core.somaxconn", "256", tmpf
, true) < 0) {
671 lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
675 if (set_get_compare_clear_save_load(c
, "lxc.proc.oom_score_adj", "10", tmpf
, true) < 0) {
676 lxc_error("%s\n", "lxc.proc.oom_score_adj");
680 if (set_get_compare_clear_save_load(c
, "lxc.prlimit.nofile", "65536", tmpf
, true) < 0) {
681 lxc_error("%s\n", "lxc.prlimit.nofile");
685 if (test_idmap_parser() < 0) {
686 lxc_error("%s\n", "failed to test parser for \"lxc.id_map\"");
690 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "veth", tmpf
, true)) {
691 lxc_error("%s\n", "lxc.net.0.type");
695 if (set_get_compare_clear_save_load(c
, "lxc.net.2.type", "none", tmpf
, true)) {
696 lxc_error("%s\n", "lxc.net.2.type");
700 if (set_get_compare_clear_save_load(c
, "lxc.net.3.type", "empty", tmpf
, true)) {
701 lxc_error("%s\n", "lxc.net.3.type");
705 if (set_get_compare_clear_save_load(c
, "lxc.net.4.type", "vlan", tmpf
, true)) {
706 lxc_error("%s\n", "lxc.net.4.type");
710 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "macvlan", tmpf
, true)) {
711 lxc_error("%s\n", "lxc.net.0.type");
715 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "ipvlan", tmpf
, true)) {
716 lxc_error("%s\n", "lxc.net.0.type");
720 if (set_get_compare_clear_save_load(c
, "lxc.net.1000.type", "phys", tmpf
, true)) {
721 lxc_error("%s\n", "lxc.net.1000.type");
725 if (set_get_compare_clear_save_load(c
, "lxc.net.0.flags", "up", tmpf
, true)) {
726 lxc_error("%s\n", "lxc.net.0.flags");
730 if (set_get_compare_clear_save_load(c
, "lxc.net.0.name", "eth0", tmpf
, true)) {
731 lxc_error("%s\n", "lxc.net.0.name");
735 if (set_get_compare_clear_save_load(c
, "lxc.net.0.link", "bla", tmpf
, true)) {
736 lxc_error("%s\n", "lxc.net.0.link");
740 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "private", tmpf
, true, "macvlan")) {
741 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
745 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "vepa", tmpf
, true, "macvlan")) {
746 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
750 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "bridge", tmpf
, true, "macvlan")) {
751 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
755 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3", tmpf
, true, "ipvlan")) {
756 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
760 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3s", tmpf
, true, "ipvlan")) {
761 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
765 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l2", tmpf
, true, "ipvlan")) {
766 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
770 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "bridge", tmpf
, true, "ipvlan")) {
771 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
775 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "private", tmpf
, true, "ipvlan")) {
776 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
780 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "vepa", tmpf
, true, "ipvlan")) {
781 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
785 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.pair", "clusterfuck", tmpf
, true, "veth")) {
786 lxc_error("%s\n", "lxc.net.0.veth.pair");
790 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv4.route", "192.0.2.1/32", tmpf
, true, "veth")) {
791 lxc_error("%s\n", "lxc.net.0.veth.ipv4.route");
795 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv6.route", "2001:db8::1/128", tmpf
, true, "veth")) {
796 lxc_error("%s\n", "lxc.net.0.veth.ipv6.route");
800 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.id", "none", tmpf
, false, "veth")) {
801 lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
805 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.id", "2", tmpf
, true, "veth")) {
806 lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
810 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.tagged.id", "2", tmpf
, true, "veth")) {
811 lxc_error("%s\n", "lxc.net.0.veth.vlan.tagged.id");
815 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.up", "/some/up/path", tmpf
, true)) {
816 lxc_error("%s\n", "lxc.net.0.script.up");
820 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.down", "/some/down/path", tmpf
, true)) {
821 lxc_error("%s\n", "lxc.net.0.script.down");
825 if (set_get_compare_clear_save_load(c
, "lxc.net.0.hwaddr", "52:54:00:80:7a:5d", tmpf
, true)) {
826 lxc_error("%s\n", "lxc.net.0.hwaddr");
830 if (set_get_compare_clear_save_load(c
, "lxc.net.0.mtu", "2000", tmpf
, true)) {
831 lxc_error("%s\n", "lxc.net.0.mtu");
835 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.vlan.id", "2", tmpf
, true, "vlan")) {
836 lxc_error("%s\n", "lxc.net.0.vlan.id");
840 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "10.0.2.2", tmpf
, true)) {
841 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
845 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "auto", tmpf
, true)) {
846 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
850 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "dev", tmpf
, true)) {
851 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
855 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "2003:db8:1::1", tmpf
, true)) {
856 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
860 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "auto", tmpf
, true)) {
861 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
865 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "dev", tmpf
, true)) {
866 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
870 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.address", "10.0.2.3/24", tmpf
, true)) {
871 lxc_error("%s\n", "lxc.net.0.ipv4.address");
875 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64", tmpf
, true)) {
876 lxc_error("%s\n", "lxc.net.0.ipv6.address");
880 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.dir", "lxd", tmpf
, true)) {
881 lxc_error("%s\n", "lxc.cgroup.dir");
885 if (set_and_clear_complete_netdev(c
) < 0) {
886 lxc_error("%s\n", "failed to clear whole network");
890 if (set_invalid_netdev(c
) < 0) {
891 lxc_error("%s\n", "failed to reject invalid configuration");
895 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "1", tmpf
, true);
897 lxc_error("%s\n", "lxc.hook.version");
901 if (c
->set_config_item(c
, "lxc.hook.version", "2")) {
902 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.version\" to \"2\"");
906 if (!c
->set_config_item(c
, "lxc.monitor.signal.pdeath", "SIGKILL")) {
907 lxc_error("%s\n", "Failed to set to set invalid config item \"lxc.monitor.signal.pdeath\" to \"SIGKILL\"");
911 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.managed", "1", tmpf
, true) < 0) {
912 lxc_error("%s\n", "lxc.rootfs.managed");
916 if (c
->set_config_item(c
, "lxc.notaconfigkey", "invalid")) {
917 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.notaconfigkey\" to \"invalid\"");
921 if (c
->set_config_item(c
, "lxc.log.file=", "./")) {
922 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.log.file\" to \"./\"");
926 if (c
->set_config_item(c
, "lxc.hook.versionasdfsadfsadf", "1")) {
927 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.versionasdfsadfsadf\" to \"2\"");
931 if (set_get_compare_clear_save_load(c
, "lxc.sched.core", "1", tmpf
, true) < 0) {
932 lxc_error("%s\n", "lxc.sched.core");
940 (void)rmdir(dirname(c
->configfile
));
941 lxc_container_put(c
);