]>
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>
31 #include "confile_utils.h"
32 #include "lxc/state.h"
35 static int set_get_compare_clear_save_load(struct lxc_container
*c
,
36 const char *key
, const char *value
,
37 const char *config_file
,
40 char retval
[4096] = {0};
43 if (!c
->set_config_item(c
, key
, value
)) {
44 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
49 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
51 lxc_error("failed to get config item \"%s\"\n", key
);
56 ret
= strcmp(retval
, value
);
59 "expected value \"%s\" and retrieved value \"%s\" "
60 "for config key \"%s\" do not match\n",
67 if (!c
->save_config(c
, config_file
)) {
68 lxc_error("%s\n", "failed to save config file");
75 if (!c
->load_config(c
, config_file
)) {
76 lxc_error("%s\n", "failed to load config file");
81 if (!c
->clear_config_item(c
, key
)) {
82 lxc_error("failed to clear config item \"%s\"\n", key
);
92 static int set_and_clear_complete_netdev(struct lxc_container
*c
)
94 if (!c
->set_config_item(c
, "lxc.net.1.type", "veth")) {
95 lxc_error("%s\n", "lxc.net.1.type");
99 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.address", "10.0.2.3/24")) {
100 lxc_error("%s\n", "lxc.net.1.ipv4.address");
104 if (!c
->set_config_item(c
, "lxc.net.1.ipv4.gateway", "10.0.2.2")) {
105 lxc_error("%s\n", "lxc.net.1.ipv4.gateway");
109 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.address",
110 "2003:db8:1:0:214:1234:fe0b:3596/64")) {
111 lxc_error("%s\n", "lxc.net.1.ipv6.address");
115 if (!c
->set_config_item(c
, "lxc.net.1.ipv6.gateway",
116 "2003:db8:1:0::1")) {
117 lxc_error("%s\n", "lxc.net.1.ipv6.gateway");
121 if (!c
->set_config_item(c
, "lxc.net.1.flags", "up")) {
122 lxc_error("%s\n", "lxc.net.1.flags");
126 if (!c
->set_config_item(c
, "lxc.net.1.link", "br0")) {
127 lxc_error("%s\n", "lxc.net.1.link");
131 if (!c
->set_config_item(c
, "lxc.net.1.veth.pair", "bla")) {
132 lxc_error("%s\n", "lxc.net.1.veth.pair");
136 if (!c
->set_config_item(c
, "lxc.net.1.hwaddr",
137 "52:54:00:80:7a:5d")) {
138 lxc_error("%s\n", "lxc.net.1.hwaddr");
142 if (!c
->set_config_item(c
, "lxc.net.1.mtu", "2000")) {
143 lxc_error("%s\n", "lxc.net.1.mtu");
147 if (!c
->clear_config_item(c
, "lxc.net.1")) {
148 lxc_error("%s", "failed to clear \"lxc.net.1\"\n");
158 static int set_invalid_netdev(struct lxc_container
*c
) {
159 if (c
->set_config_item(c
, "lxc.net.0.asdf", "veth")) {
160 lxc_error("%s\n", "lxc.net.0.asdf should be invalid");
164 if (c
->set_config_item(c
, "lxc.net.2147483647.type", "veth")) {
165 lxc_error("%s\n", "lxc.net.2147483647.type should be invalid");
169 if (c
->set_config_item(c
, "lxc.net.0.", "veth")) {
170 lxc_error("%s\n", "lxc.net.0. should be invalid");
174 if (c
->set_config_item(c
, "lxc.network.0.", "veth")) {
175 lxc_error("%s\n", "lxc.network.0. should be invalid");
185 int test_idmap_parser(void)
192 static struct idmap_check idmaps
[] = {
196 { true, "u 1 100001 999999999" },
197 { true, "g 1 100001 999999999" },
200 { true, "u 1000 165536 65536" },
201 { true, "g 999 999 1" },
202 { true, "u 0 5000 100000" },
203 { true, "g 577 789 5" },
204 { true, "u 65536 65536 1 " },
206 { false, "1u 0 0 0" },
207 { false, "1g 0 0 0a" },
208 { false, "1 u 0 0 0" },
209 { false, "1g 0 0 0 1" },
210 { false, "1u a0 b0 c0 d1" },
211 { false, "1g 0 b0 0 d1" },
212 { false, "1u a0 0 c0 1" },
213 { false, "g -1 0 -10" },
214 { false, "a 1 0 10" },
215 { false, "u 1 1 0 10" },
216 { false, "g 1 0 10 z " },
219 for (i
= 0; i
< sizeof(idmaps
) / sizeof(struct idmap_check
); i
++) {
220 unsigned long hostid
, nsid
, range
;
223 ret
= parse_idmaps(idmaps
[i
].idmap
, &type
, &nsid
, &hostid
,
225 if ((ret
< 0 && idmaps
[i
].is_valid
) ||
226 (ret
== 0 && !idmaps
[i
].is_valid
)) {
227 lxc_error("failed to parse idmap \"%s\"\n",
236 static int set_get_compare_clear_save_load_network(
237 struct lxc_container
*c
, const char *key
, const char *value
,
238 const char *config_file
, bool compare
, const char *network_type
)
240 char retval
[4096] = {0};
243 if (!c
->set_config_item(c
, "lxc.net.0.type", network_type
)) {
244 lxc_error("%s\n", "lxc.net.0.type");
248 if (!c
->set_config_item(c
, key
, value
)) {
249 lxc_error("failed to set config item \"%s\" to \"%s\"\n", key
,
254 ret
= c
->get_config_item(c
, key
, retval
, sizeof(retval
));
256 lxc_error("failed to get config item \"%s\"\n", key
);
261 ret
= strcmp(retval
, value
);
264 "expected value \"%s\" and retrieved value \"%s\" "
265 "for config key \"%s\" do not match\n",
272 if (!c
->save_config(c
, config_file
)) {
273 lxc_error("%s\n", "failed to save config file");
280 if (!c
->load_config(c
, config_file
)) {
281 lxc_error("%s\n", "failed to load config file");
286 if (!c
->clear_config_item(c
, key
)) {
287 lxc_error("failed to clear config item \"%s\"\n", key
);
291 if (!c
->clear_config_item(c
, "lxc.net.0.type")) {
292 lxc_error("%s\n", "lxc.net.0.type");
302 int main(int argc
, char *argv
[])
304 struct lxc_container
*c
;
306 int ret
= EXIT_FAILURE
;
307 char tmpf
[] = "lxc-parse-config-file-XXXXXX";
308 char retval
[4096] = {0};
312 lxc_error("%s\n", "Could not create temporary file");
317 c
= lxc_container_new(tmpf
, NULL
);
319 lxc_error("%s\n", "Failed to create new container");
324 if (set_get_compare_clear_save_load(c
, "lxc.arch", "x86_64", tmpf
,
326 lxc_error("%s\n", "lxc.arch");
333 if (set_get_compare_clear_save_load(c
, "lxc.pts", "1000", tmpf
, true) <
335 lxc_error("%s\n", "lxc.pts");
340 if (set_get_compare_clear_save_load(c
, "lxc.pty.max", "1000", tmpf
, true) <
342 lxc_error("%s\n", "lxc.pty.max");
349 if (set_get_compare_clear_save_load(c
, "lxc.tty", "4", tmpf
, true) <
351 lxc_error("%s\n", "lxc.tty");
356 if (set_get_compare_clear_save_load(c
, "lxc.tty.max", "4", tmpf
, true) <
358 lxc_error("%s\n", "lxc.tty.max");
363 legacy devttydir keys
365 if (set_get_compare_clear_save_load(c
, "lxc.devttydir", "not-dev", tmpf
,
367 lxc_error("%s\n", "lxc.devttydir");
372 if (set_get_compare_clear_save_load(c
, "lxc.tty.dir", "not-dev", tmpf
,
374 lxc_error("%s\n", "lxc.tty.dir");
381 if (set_get_compare_clear_save_load(c
, "lxc.aa_profile", "unconfined",
383 lxc_error("%s\n", "lxc.aa_profile");
390 if (set_get_compare_clear_save_load(c
, "lxc.aa_allow_incomplete", "1",
392 lxc_error("%s\n", "lxc.aa_allow_incomplete");
399 if (set_get_compare_clear_save_load(c
, "lxc.se_context", "system_u:system_r:lxc_t:s0:c22",
401 lxc_error("%s\n", "lxc.se_context");
405 /* lxc.apparmor.profile */
406 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.profile", "unconfined",
408 lxc_error("%s\n", "lxc.apparmor.profile");
412 /* lxc.apparmor.allow_incomplete */
413 if (set_get_compare_clear_save_load(c
, "lxc.apparmor.allow_incomplete", "1",
415 lxc_error("%s\n", "lxc.apparmor.allow_incomplete");
419 /* lxc.selinux.context */
420 if (set_get_compare_clear_save_load(c
, "lxc.selinux.context", "system_u:system_r:lxc_t:s0:c22",
422 lxc_error("%s\n", "lxc.selinux.context");
426 /* lxc.cgroup.cpuset.cpus */
427 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.cpuset.cpus",
428 "1-100", tmpf
, false) < 0) {
429 lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
434 if (!c
->set_config_item(c
, "lxc.cgroup.cpuset.cpus", "1-100")) {
435 lxc_error("%s\n", "failed to set config item "
436 "\"lxc.cgroup.cpuset.cpus\" to \"1-100\"");
440 if (!c
->set_config_item(c
, "lxc.cgroup.memory.limit_in_bytes",
444 "failed to set config item "
445 "\"lxc.cgroup.memory.limit_in_bytes\" to \"123456789\"");
449 if (!c
->get_config_item(c
, "lxc.cgroup", retval
, sizeof(retval
))) {
450 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
458 * We can't really save the config here since save_config() wants to
459 * chown the container's directory but we haven't created an on-disk
460 * container. So let's test set-get-clear.
462 if (set_get_compare_clear_save_load(
463 c
, "lxc.id_map", "u 0 100000 1000000000", NULL
, false) < 0) {
464 lxc_error("%s\n", "lxc.id_map");
468 if (!c
->set_config_item(c
, "lxc.id_map", "u 1 100000 10000000")) {
469 lxc_error("%s\n", "failed to set config item "
470 "\"lxc.id_map\" to \"u 1 100000 10000000\"");
474 if (!c
->set_config_item(c
, "lxc.id_map", "g 1 100000 10000000")) {
475 lxc_error("%s\n", "failed to set config item "
476 "\"lxc.id_map\" to \"g 1 100000 10000000\"");
480 if (!c
->get_config_item(c
, "lxc.id_map", retval
, sizeof(retval
))) {
481 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
486 * We can't really save the config here since save_config() wants to
487 * chown the container's directory but we haven't created an on-disk
488 * container. So let's test set-get-clear.
490 if (set_get_compare_clear_save_load(
491 c
, "lxc.idmap", "u 0 100000 1000000000", NULL
, false) < 0) {
492 lxc_error("%s\n", "lxc.idmap");
496 if (!c
->set_config_item(c
, "lxc.idmap", "u 1 100000 10000000")) {
497 lxc_error("%s\n", "failed to set config item "
498 "\"lxc.idmap\" to \"u 1 100000 10000000\"");
502 if (!c
->set_config_item(c
, "lxc.idmap", "g 1 100000 10000000")) {
503 lxc_error("%s\n", "failed to set config item "
504 "\"lxc.idmap\" to \"g 1 100000 10000000\"");
508 if (!c
->get_config_item(c
, "lxc.idmap", retval
, sizeof(retval
))) {
509 lxc_error("%s\n", "failed to get config item \"lxc.cgroup\"");
517 legacy lxc.loglevel key
519 if (set_get_compare_clear_save_load(c
, "lxc.loglevel", "DEBUG", tmpf
,
521 lxc_error("%s\n", "lxc.loglevel");
526 legacy lxc.logfile key
528 if (set_get_compare_clear_save_load(c
, "lxc.logfile", "/some/path",
530 lxc_error("%s\n", "lxc.logfile");
536 if (set_get_compare_clear_save_load(c
, "lxc.log.level", "DEBUG", tmpf
,
538 lxc_error("%s\n", "lxc.log.level");
543 if (set_get_compare_clear_save_load(c
, "lxc.log.file", "/some/path",
545 lxc_error("%s\n", "lxc.log.file");
552 if (set_get_compare_clear_save_load(c
, "lxc.mount", "/some/path", NULL
,
554 lxc_error("%s\n", "lxc.mount");
558 /* lxc.mount.fstab */
559 if (set_get_compare_clear_save_load(c
, "lxc.mount.fstab", "/some/path", NULL
,
561 lxc_error("%s\n", "lxc.mount.fstab");
566 * Note that we cannot compare the values since the getter for
567 * lxc.mount.auto does not preserve ordering.
569 if (set_get_compare_clear_save_load(c
, "lxc.mount.auto",
570 "proc:rw sys:rw cgroup-full:rw",
572 lxc_error("%s\n", "lxc.mount.auto");
577 * Note that we cannot compare the values since the getter for
578 * lxc.mount.entry appends newlines.
580 if (set_get_compare_clear_save_load(
581 c
, "lxc.mount.entry",
582 "/dev/dri dev/dri none bind,optional,create=dir", tmpf
,
584 lxc_error("%s\n", "lxc.mount.entry");
589 legacy lxc.rootfs key
591 if (set_get_compare_clear_save_load(c
, "lxc.rootfs", "/some/path", tmpf
,
593 lxc_error("%s\n", "lxc.rootfs");
597 /* lxc.rootfs.path */
598 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.path", "/some/path", tmpf
,
600 lxc_error("%s\n", "lxc.rootfs.path");
604 /* lxc.rootfs.mount */
605 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.mount", "/some/path",
607 lxc_error("%s\n", "lxc.rootfs.mount");
611 /* lxc.rootfs.options */
612 if (set_get_compare_clear_save_load(c
, "lxc.rootfs.options",
613 "ext4,discard", tmpf
, true) < 0) {
614 lxc_error("%s\n", "lxc.rootfs.options");
619 legacy lxc.utsname key
621 if (set_get_compare_clear_save_load(c
, "lxc.utsname", "the-shire", tmpf
,
623 lxc_error("%s\n", "lxc.utsname");
628 if (set_get_compare_clear_save_load(c
, "lxc.uts.name", "the-shire", tmpf
,
630 lxc_error("%s\n", "lxc.uts.name");
634 /* lxc.hook.pre-start */
635 if (set_get_compare_clear_save_load(
636 c
, "lxc.hook.pre-start", "/some/pre-start", tmpf
, false) < 0) {
637 lxc_error("%s\n", "lxc.hook.pre-start");
641 /* lxc.hook.pre-mount */
642 if (set_get_compare_clear_save_load(
643 c
, "lxc.hook.pre-mount", "/some/pre-mount", tmpf
, false) < 0) {
644 lxc_error("%s\n", "lxc.hook.pre-mount");
649 if (set_get_compare_clear_save_load(c
, "lxc.hook.mount", "/some/mount",
651 lxc_error("%s\n", "lxc.hook.mount");
655 /* lxc.hook.autodev */
656 if (set_get_compare_clear_save_load(c
, "lxc.hook.autodev",
657 "/some/autodev", tmpf
, false) < 0) {
658 lxc_error("%s\n", "lxc.hook.autodev");
663 if (set_get_compare_clear_save_load(c
, "lxc.hook.start", "/some/start",
665 lxc_error("%s\n", "lxc.hook.start");
670 if (set_get_compare_clear_save_load(c
, "lxc.hook.stop", "/some/stop",
672 lxc_error("%s\n", "lxc.hook.stop");
676 /* lxc.hook.post-stop */
677 if (set_get_compare_clear_save_load(
678 c
, "lxc.hook.post-stop", "/some/post-stop", tmpf
, false) < 0) {
679 lxc_error("%s\n", "lxc.hook.post-stop");
684 if (set_get_compare_clear_save_load(c
, "lxc.hook.clone", "/some/clone",
686 lxc_error("%s\n", "lxc.hook.clone");
690 /* lxc.hook.destroy */
691 if (set_get_compare_clear_save_load(c
, "lxc.hook.destroy",
692 "/some/destroy", tmpf
, false) < 0) {
693 lxc_error("%s\n", "lxc.hook.destroy");
698 if (set_get_compare_clear_save_load(c
, "lxc.cap.drop",
699 "sys_module mknod setuid net_raw",
701 lxc_error("%s\n", "lxc.cap.drop");
706 if (set_get_compare_clear_save_load(c
, "lxc.cap.keep",
707 "sys_module mknod setuid net_raw",
709 lxc_error("%s\n", "lxc.cap.keep");
714 legacy lxc.console key
716 if (set_get_compare_clear_save_load(c
, "lxc.console", "none", tmpf
,
718 lxc_error("%s\n", "lxc.console");
722 /* lxc.console.path */
723 if (set_get_compare_clear_save_load(c
, "lxc.console.path", "none", tmpf
,
725 lxc_error("%s\n", "lxc.console.path");
729 /* lxc.console.logfile */
730 if (set_get_compare_clear_save_load(c
, "lxc.console.logfile",
731 "/some/logfile", tmpf
, true) < 0) {
732 lxc_error("%s\n", "lxc.console.logfile");
739 if (set_get_compare_clear_save_load(
740 c
, "lxc.seccomp", "/some/seccomp/file", tmpf
, true) < 0) {
741 lxc_error("%s\n", "lxc.seccomp");
745 /* lxc.seccomp.profile */
746 if (set_get_compare_clear_save_load(
747 c
, "lxc.seccomp.profile", "/some/seccomp/file", tmpf
, true) < 0) {
748 lxc_error("%s\n", "lxc.seccomp.profile");
753 if (set_get_compare_clear_save_load(c
, "lxc.autodev", "1", tmpf
, true) <
755 lxc_error("%s\n", "lxc.autodev");
760 legacy lxc.haltsignal key
762 if (set_get_compare_clear_save_load(c
, "lxc.haltsignal", "1", tmpf
,
764 lxc_error("%s\n", "lxc.haltsignal");
768 /* lxc.signal.halt */
769 if (set_get_compare_clear_save_load(c
, "lxc.signal.halt", "1", tmpf
,
771 lxc_error("%s\n", "lxc.signal.halt");
776 legacy lxc.rebootsignal key
778 if (set_get_compare_clear_save_load(c
, "lxc.rebootsignal", "1", tmpf
,
780 lxc_error("%s\n", "lxc.rebootsignal");
784 /* lxc.signal.reboot */
785 if (set_get_compare_clear_save_load(c
, "lxc.signal.reboot", "1", tmpf
,
787 lxc_error("%s\n", "lxc.signal.reboot");
792 legacy lxc.stopsignal key
794 if (set_get_compare_clear_save_load(c
, "lxc.stopsignal", "1", tmpf
,
796 lxc_error("%s\n", "lxc.stopsignal");
800 /* lxc.signal.stop */
801 if (set_get_compare_clear_save_load(c
, "lxc.signal.stop", "1", tmpf
,
803 lxc_error("%s\n", "lxc.signal.stop");
808 if (set_get_compare_clear_save_load(c
, "lxc.start.auto", "1", tmpf
,
810 lxc_error("%s\n", "lxc.start.auto");
814 /* lxc.start.delay */
815 if (set_get_compare_clear_save_load(c
, "lxc.start.delay", "5", tmpf
,
817 lxc_error("%s\n", "lxc.start.delay");
821 /* lxc.start.order */
822 if (set_get_compare_clear_save_load(c
, "lxc.start.order", "1", tmpf
,
824 lxc_error("%s\n", "lxc.start.order");
829 if (set_get_compare_clear_save_load(c
, "lxc.log.syslog", "local0", tmpf
,
831 lxc_error("%s\n", "lxc.log.syslog");
836 if (set_get_compare_clear_save_load(c
, "lxc.utsname", "get-schwifty",
838 lxc_error("%s\n", "lxc.utsname");
842 /* lxc.monitor.unshare */
843 if (set_get_compare_clear_save_load(c
, "lxc.monitor.unshare", "1", tmpf
,
845 lxc_error("%s\n", "lxc.monitor.unshare");
850 if (set_get_compare_clear_save_load(
851 c
, "lxc.group", "some,container,groups", tmpf
, false) < 0) {
852 lxc_error("%s\n", "lxc.group");
856 /* lxc.environment */
857 if (set_get_compare_clear_save_load(c
, "lxc.environment", "FOO=BAR",
859 lxc_error("%s\n", "lxc.environment");
864 legacy lxc.init_cmd key
866 if (set_get_compare_clear_save_load(c
, "lxc.init_cmd", "/bin/bash",
868 lxc_error("%s\n", "lxc.init_cmd");
873 if (set_get_compare_clear_save_load(c
, "lxc.init.cmd", "/bin/bash",
875 lxc_error("%s\n", "lxc.init.cmd");
880 legacy lxc.init_uid key
882 if (set_get_compare_clear_save_load(c
, "lxc.init_uid", "1000", tmpf
,
884 lxc_error("%s\n", "lxc.init_uid");
889 if (set_get_compare_clear_save_load(c
, "lxc.init.uid", "1000", tmpf
,
891 lxc_error("%s\n", "lxc.init.uid");
896 legacy lxc.init_gid key
898 if (set_get_compare_clear_save_load(c
, "lxc.init_gid", "1000", tmpf
,
900 lxc_error("%s\n", "lxc.init_gid");
905 if (set_get_compare_clear_save_load(c
, "lxc.init.gid", "1000", tmpf
,
907 lxc_error("%s\n", "lxc.init.gid");
912 if (set_get_compare_clear_save_load(c
, "lxc.ephemeral", "1", tmpf
,
914 lxc_error("%s\n", "lxc.ephemeral");
918 /* lxc.no_new_privs */
919 if (set_get_compare_clear_save_load(c
, "lxc.no_new_privs", "1", tmpf
,
921 lxc_error("%s\n", "lxc.no_new_privs");
926 if (set_get_compare_clear_save_load(c
, "lxc.sysctl.net.core.somaxconn", "256", tmpf
,
928 lxc_error("%s\n", "lxc.sysctl.net.core.somaxconn");
933 if (set_get_compare_clear_save_load(c
, "lxc.proc.oom_score_adj", "10", tmpf
,
935 lxc_error("%s\n", "lxc.proc.oom_score_adj");
940 legacy lxc.limit.* key
942 if (set_get_compare_clear_save_load(c
, "lxc.limit.nofile", "65536",
944 lxc_error("%s\n", "lxc.limit.nofile");
948 /* lxc.prlimit.nofile */
949 if (set_get_compare_clear_save_load(c
, "lxc.prlimit.nofile", "65536",
951 lxc_error("%s\n", "lxc.prlimit.nofile");
955 if (test_idmap_parser() < 0) {
956 lxc_error("%s\n", "failed to test parser for \"lxc.id_map\"");
960 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "veth",
962 lxc_error("%s\n", "lxc.net.0.type");
966 if (set_get_compare_clear_save_load(c
, "lxc.net.2.type", "none",
968 lxc_error("%s\n", "lxc.net.2.type");
972 if (set_get_compare_clear_save_load(c
, "lxc.net.3.type", "empty",
974 lxc_error("%s\n", "lxc.net.3.type");
978 if (set_get_compare_clear_save_load(c
, "lxc.net.4.type", "vlan",
980 lxc_error("%s\n", "lxc.net.4.type");
984 if (set_get_compare_clear_save_load(c
, "lxc.net.0.type", "macvlan",
986 lxc_error("%s\n", "lxc.net.0.type");
990 if (set_get_compare_clear_save_load(c
, "lxc.net.1000.type", "phys",
992 lxc_error("%s\n", "lxc.net.1000.type");
996 if (set_get_compare_clear_save_load(c
, "lxc.net.0.flags", "up",
998 lxc_error("%s\n", "lxc.net.0.flags");
1002 if (set_get_compare_clear_save_load(c
, "lxc.net.0.name", "eth0",
1004 lxc_error("%s\n", "lxc.net.0.name");
1005 goto non_test_error
;
1008 if (set_get_compare_clear_save_load(c
, "lxc.net.0.link", "bla",
1010 lxc_error("%s\n", "lxc.net.0.link");
1011 goto non_test_error
;
1014 if (set_get_compare_clear_save_load_network(
1015 c
, "lxc.net.0.macvlan.mode", "private", tmpf
, true,
1017 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
1018 goto non_test_error
;
1021 if (set_get_compare_clear_save_load_network(
1022 c
, "lxc.net.0.macvlan.mode", "vepa", tmpf
, true,
1024 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
1025 goto non_test_error
;
1028 if (set_get_compare_clear_save_load_network(
1029 c
, "lxc.net.0.macvlan.mode", "bridge", tmpf
, true,
1031 lxc_error("%s\n", "lxc.net.0.macvlan.mode");
1032 goto non_test_error
;
1035 if (set_get_compare_clear_save_load_network(
1036 c
, "lxc.net.0.veth.pair", "clusterfuck", tmpf
, true,
1038 lxc_error("%s\n", "lxc.net.0.veth.pair");
1039 goto non_test_error
;
1042 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.up",
1043 "/some/up/path", tmpf
, true)) {
1044 lxc_error("%s\n", "lxc.net.0.script.up");
1045 goto non_test_error
;
1048 if (set_get_compare_clear_save_load(c
, "lxc.net.0.script.down",
1049 "/some/down/path", tmpf
, true)) {
1050 lxc_error("%s\n", "lxc.net.0.script.down");
1051 goto non_test_error
;
1054 if (set_get_compare_clear_save_load(c
, "lxc.net.0.hwaddr",
1055 "52:54:00:80:7a:5d", tmpf
, true)) {
1056 lxc_error("%s\n", "lxc.net.0.hwaddr");
1057 goto non_test_error
;
1060 if (set_get_compare_clear_save_load(c
, "lxc.net.0.mtu", "2000",
1062 lxc_error("%s\n", "lxc.net.0.mtu");
1063 goto non_test_error
;
1066 if (set_get_compare_clear_save_load_network(c
, "lxc.net.0.vlan.id",
1067 "2", tmpf
, true, "vlan")) {
1068 lxc_error("%s\n", "lxc.net.0.vlan.id");
1069 goto non_test_error
;
1072 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.gateway",
1073 "10.0.2.2", tmpf
, true)) {
1074 lxc_error("%s\n", "lxc.net.0.ipv4.gateway");
1075 goto non_test_error
;
1078 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv6.gateway",
1079 "2003:db8:1::1", tmpf
, true)) {
1080 lxc_error("%s\n", "lxc.net.0.ipv6.gateway");
1081 goto non_test_error
;
1084 if (set_get_compare_clear_save_load(c
, "lxc.net.0.ipv4.address",
1085 "10.0.2.3/24", tmpf
, true)) {
1086 lxc_error("%s\n", "lxc.net.0.ipv4.address");
1087 goto non_test_error
;
1090 if (set_get_compare_clear_save_load(
1091 c
, "lxc.net.0.ipv6.address", "2003:db8:1:0:214:1234:fe0b:3596/64",
1093 lxc_error("%s\n", "lxc.net.0.ipv6.address");
1094 goto non_test_error
;
1097 if (set_get_compare_clear_save_load(c
, "lxc.cgroup.dir", "lxd", tmpf
,
1099 lxc_error("%s\n", "lxc.cgroup.dir");
1100 goto non_test_error
;
1103 if (set_and_clear_complete_netdev(c
) < 0) {
1104 lxc_error("%s\n", "failed to clear whole network");
1105 goto non_test_error
;
1108 if (set_invalid_netdev(c
) < 0) {
1109 lxc_error("%s\n", "failed to reject invalid configuration");
1110 goto non_test_error
;
1116 (void)rmdir(dirname(c
->configfile
));
1117 lxc_container_put(c
);