]>
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 ret
= set_get_compare_clear_save_load(c
, "lxc.seccomp.profile", "/some/seccomp/file", tmpf
, true);
587 lxc_error("%s\n", "lxc.seccomp.profile");
591 if (set_get_compare_clear_save_load(c
, "lxc.autodev.tmpfs.size", "1", tmpf
, true) < 0) {
592 lxc_error("%s\n", "lxc.autodev.tmpfs.size");
596 if (set_get_compare_clear_save_load(c
, "lxc.autodev", "1", tmpf
, true) <
598 lxc_error("%s\n", "lxc.autodev");
602 if (set_get_compare_clear_save_load(c
, "lxc.signal.halt", "1", tmpf
, true) < 0) {
603 lxc_error("%s\n", "lxc.signal.halt");
607 if (set_get_compare_clear_save_load(c
, "lxc.signal.reboot", "1", tmpf
, true) < 0) {
608 lxc_error("%s\n", "lxc.signal.reboot");
612 if (set_get_compare_clear_save_load(c
, "lxc.signal.stop", "1", tmpf
, true) < 0) {
613 lxc_error("%s\n", "lxc.signal.stop");
617 if (set_get_compare_clear_save_load(c
, "lxc.start.auto", "1", tmpf
, true) < 0) {
618 lxc_error("%s\n", "lxc.start.auto");
622 if (set_get_compare_clear_save_load(c
, "lxc.start.delay", "5", tmpf
, true) < 0) {
623 lxc_error("%s\n", "lxc.start.delay");
627 if (set_get_compare_clear_save_load(c
, "lxc.start.order", "1", tmpf
, true) < 0) {
628 lxc_error("%s\n", "lxc.start.order");
632 if (set_get_compare_clear_save_load(c
, "lxc.log.syslog", "local0", tmpf
, true) < 0) {
633 lxc_error("%s\n", "lxc.log.syslog");
637 if (set_get_compare_clear_save_load(c
, "lxc.monitor.unshare", "1", tmpf
, true) < 0) {
638 lxc_error("%s\n", "lxc.monitor.unshare");
642 if (set_get_compare_clear_save_load(c
, "lxc.group", "some,container,groups", tmpf
, false) < 0) {
643 lxc_error("%s\n", "lxc.group");
647 if (set_get_compare_clear_save_load(c
, "lxc.environment", "FOO=BAR", tmpf
, false) < 0) {
648 lxc_error("%s\n", "lxc.environment");
652 if (set_get_compare_clear_save_load(c
, "lxc.init.cmd", "/bin/bash", tmpf
, true) < 0) {
653 lxc_error("%s\n", "lxc.init.cmd");
657 if (set_get_compare_clear_save_load(c
, "lxc.init.uid", "1000", tmpf
, true) < 0) {
658 lxc_error("%s\n", "lxc.init.uid");
662 if (set_get_compare_clear_save_load(c
, "lxc.init.gid", "1000", tmpf
, true) < 0) {
663 lxc_error("%s\n", "lxc.init.gid");
667 if (set_get_compare_clear_save_load(c
, "lxc.ephemeral", "1", tmpf
, true) < 0) {
668 lxc_error("%s\n", "lxc.ephemeral");
672 if (set_get_compare_clear_save_load(c
, "lxc.no_new_privs", "1", tmpf
, true) < 0) {
673 lxc_error("%s\n", "lxc.no_new_privs");
677 if (set_get_compare_clear_save_load(c
, "lxc.sysctl.net.core.somaxconn", "256", tmpf
, true) < 0) {
678 lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
682 if (set_get_compare_clear_save_load(c
, "lxc.proc.oom_score_adj", "10", tmpf
, true) < 0) {
683 lxc_error("%s\n", "lxc.proc.oom_score_adj");
687 if (set_get_compare_clear_save_load(c
, "lxc.prlimit.nofile", "65536", tmpf
, true) < 0) {
688 lxc_error("%s\n", "lxc.prlimit.nofile");
692 if (test_idmap_parser() < 0) {
693 lxc_error("%s\n", "failed to test parser for \"lxc.id_map\"");
697 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "veth", tmpf
, true)) {
698 lxc_error("%s\n", "lxc.net.0.type");
702 if (set_get_compare_clear_save_load(c
, "lxc.net.2.type", "none", tmpf
, true)) {
703 lxc_error("%s\n", "lxc.net.2.type");
707 if (set_get_compare_clear_save_load(c
, "lxc.net.3.type", "empty", tmpf
, true)) {
708 lxc_error("%s\n", "lxc.net.3.type");
712 if (set_get_compare_clear_save_load(c
, "lxc.net.4.type", "vlan", tmpf
, true)) {
713 lxc_error("%s\n", "lxc.net.4.type");
717 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "macvlan", tmpf
, true)) {
718 lxc_error("%s\n", "lxc.net.0.type");
722 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "ipvlan", tmpf
, true)) {
723 lxc_error("%s\n", "lxc.net.0.type");
727 if (set_get_compare_clear_save_load(c
, "lxc.net.1000.type", "phys", tmpf
, true)) {
728 lxc_error("%s\n", "lxc.net.1000.type");
732 if (set_get_compare_clear_save_load(c
, "lxc.net.0.flags", "up", tmpf
, true)) {
733 lxc_error("%s\n", "lxc.net.0.flags");
737 if (set_get_compare_clear_save_load(c
, "lxc.net.0.name", "eth0", tmpf
, true)) {
738 lxc_error("%s\n", "lxc.net.0.name");
742 if (set_get_compare_clear_save_load(c
, "lxc.net.0.link", "bla", tmpf
, true)) {
743 lxc_error("%s\n", "lxc.net.0.link");
747 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "private", tmpf
, true, "macvlan")) {
748 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
752 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "vepa", tmpf
, true, "macvlan")) {
753 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
757 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.macvlan.mode", "bridge", tmpf
, true, "macvlan")) {
758 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
762 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3", tmpf
, true, "ipvlan")) {
763 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
767 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l3s", tmpf
, true, "ipvlan")) {
768 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
772 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.mode", "l2", tmpf
, true, "ipvlan")) {
773 lxc_error("%s\n", "lxc.net.0.ipvlan.mode");
777 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "bridge", tmpf
, true, "ipvlan")) {
778 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
782 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "private", tmpf
, true, "ipvlan")) {
783 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
787 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.ipvlan.isolation", "vepa", tmpf
, true, "ipvlan")) {
788 lxc_error("%s\n", "lxc.net.0.ipvlan.isolation");
792 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.pair", "clusterfuck", tmpf
, true, "veth")) {
793 lxc_error("%s\n", "lxc.net.0.veth.pair");
797 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv4.route", "192.0.2.1/32", tmpf
, true, "veth")) {
798 lxc_error("%s\n", "lxc.net.0.veth.ipv4.route");
802 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.ipv6.route", "2001:db8::1/128", tmpf
, true, "veth")) {
803 lxc_error("%s\n", "lxc.net.0.veth.ipv6.route");
807 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.id", "none", tmpf
, false, "veth")) {
808 lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
812 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.id", "2", tmpf
, true, "veth")) {
813 lxc_error("%s\n", "lxc.net.0.veth.vlan.id");
817 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.veth.vlan.tagged.id", "2", tmpf
, true, "veth")) {
818 lxc_error("%s\n", "lxc.net.0.veth.vlan.tagged.id");
822 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.up", "/some/up/path", tmpf
, true)) {
823 lxc_error("%s\n", "lxc.net.0.script.up");
827 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.down", "/some/down/path", tmpf
, true)) {
828 lxc_error("%s\n", "lxc.net.0.script.down");
832 if (set_get_compare_clear_save_load(c
, "lxc.net.0.hwaddr", "52:54:00:80:7a:5d", tmpf
, true)) {
833 lxc_error("%s\n", "lxc.net.0.hwaddr");
837 if (set_get_compare_clear_save_load(c
, "lxc.net.0.mtu", "2000", tmpf
, true)) {
838 lxc_error("%s\n", "lxc.net.0.mtu");
842 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.vlan.id", "2", tmpf
, true, "vlan")) {
843 lxc_error("%s\n", "lxc.net.0.vlan.id");
847 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "10.0.2.2", tmpf
, true)) {
848 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
852 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "auto", tmpf
, true)) {
853 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
857 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway", "dev", tmpf
, true)) {
858 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
862 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "2003:db8:1::1", tmpf
, true)) {
863 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
867 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "auto", tmpf
, true)) {
868 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
872 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway", "dev", tmpf
, true)) {
873 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
877 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.address", "10.0.2.3/24", tmpf
, true)) {
878 lxc_error("%s\n", "lxc.net.0.ipv4.address");
882 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64", tmpf
, true)) {
883 lxc_error("%s\n", "lxc.net.0.ipv6.address");
887 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.dir", "lxd", tmpf
, true)) {
888 lxc_error("%s\n", "lxc.cgroup.dir");
892 if (set_and_clear_complete_netdev(c
) < 0) {
893 lxc_error("%s\n", "failed to clear whole network");
897 if (set_invalid_netdev(c
) < 0) {
898 lxc_error("%s\n", "failed to reject invalid configuration");
902 ret
= set_get_compare_clear_save_load(c
, "lxc.hook.version", "1", tmpf
, true);
904 lxc_error("%s\n", "lxc.hook.version");
908 if (c
->set_config_item(c
, "lxc.hook.version", "2")) {
909 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.version\" to \"2\"");
913 if (!c
->set_config_item(c
, "lxc.monitor.signal.pdeath", "SIGKILL")) {
914 lxc_error("%s\n", "Failed to set to set invalid config item \"lxc.monitor.signal.pdeath\" to \"SIGKILL\"");
918 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.managed", "1", tmpf
, true) < 0) {
919 lxc_error("%s\n", "lxc.rootfs.managed");
923 if (c
->set_config_item(c
, "lxc.notaconfigkey", "invalid")) {
924 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.notaconfigkey\" to \"invalid\"");
928 if (c
->set_config_item(c
, "lxc.log.file=", "./")) {
929 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.log.file\" to \"./\"");
933 if (c
->set_config_item(c
, "lxc.hook.versionasdfsadfsadf", "1")) {
934 lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.hook.versionasdfsadfsadf\" to \"2\"");
938 if (set_get_compare_clear_save_load(c
, "lxc.sched.core", "1", tmpf
, true) < 0) {
939 lxc_error("%s\n", "lxc.sched.core");
947 (void)rmdir(dirname(c
->configfile
));
948 lxc_container_put(c
);