]>
Commit | Line | Data |
---|---|---|
72d0e1cb SG |
1 | /* liblxcapi |
2 | * | |
3 | * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>. | |
4 | * Copyright © 2012 Canonical Ltd. | |
5 | * | |
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. | |
9 | * | |
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. | |
14 | * | |
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. | |
18 | */ | |
948955a2 | 19 | #include <lxc/lxccontainer.h> |
72d0e1cb SG |
20 | |
21 | #include <unistd.h> | |
22 | #include <signal.h> | |
23 | #include <stdio.h> | |
24 | #include <sys/types.h> | |
25 | #include <sys/wait.h> | |
26 | #include <stdlib.h> | |
27 | #include <errno.h> | |
28 | #include <lxc/state.h> | |
29 | ||
30 | #define MYNAME "lxctest1" | |
31 | ||
32 | int main(int argc, char *argv[]) | |
33 | { | |
34 | struct lxc_container *c; | |
35 | int len, ret; | |
38b280ca | 36 | char v3[2048]; |
72d0e1cb | 37 | |
afeecbba | 38 | if ((c = lxc_container_new(MYNAME, NULL)) == NULL) { |
72d0e1cb SG |
39 | fprintf(stderr, "%d: error opening lxc_container %s\n", __LINE__, MYNAME); |
40 | ret = 1; | |
41 | goto out; | |
42 | } | |
43 | ||
44 | c->set_config_item(c, "lxc.network.type", "veth"); | |
45 | ||
46 | len = c->get_keys(c, NULL, NULL, 0); | |
47 | if (len < 0) { | |
48 | fprintf(stderr, "%d: failed to get length of all keys (%d)\n", __LINE__, len); | |
49 | ret = 1; | |
50 | goto out; | |
51 | } | |
52 | ret = c->get_keys(c, NULL, v3, len+1); | |
53 | if (ret != len) { | |
54 | fprintf(stderr, "%d: failed to get keys (%d)\n", __LINE__, ret); | |
55 | ret = 1; | |
56 | goto out; | |
57 | } | |
58 | printf("get_keys returned %d\n%s", ret, v3); | |
59 | ||
60 | ret = c->get_keys(c, "lxc.network.0", v3, 2000); | |
61 | if (ret < 0) { | |
62 | fprintf(stderr, "%d: failed to get nic 0 keys(%d)\n", __LINE__, ret); | |
63 | ret = 1; | |
64 | goto out; | |
65 | } | |
66 | printf("get_keys for nic 1 returned %d\n%s", ret, v3); | |
67 | ||
68 | out: | |
69 | lxc_container_put(c); | |
70 | exit(ret); | |
71 | } |