]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/getkeys.c
3 * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
4 * Copyright © 2012 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>
24 #include <sys/types.h>
28 #include "lxc/state.h"
30 #define MYNAME "lxctest1"
32 int main(int argc
, char *argv
[])
34 struct lxc_container
*c
;
38 if ((c
= lxc_container_new(MYNAME
, NULL
)) == NULL
) {
39 fprintf(stderr
, "%d: error opening lxc_container %s\n", __LINE__
, MYNAME
);
44 c
->set_config_item(c
, "lxc.network.type", "veth");
46 len
= c
->get_keys(c
, NULL
, NULL
, 0);
48 fprintf(stderr
, "%d: failed to get length of all keys (%d)\n", __LINE__
, len
);
52 ret
= c
->get_keys(c
, NULL
, v3
, len
+1);
54 fprintf(stderr
, "%d: failed to get keys (%d)\n", __LINE__
, ret
);
58 printf("get_keys returned %d\n%s", ret
, v3
);
60 ret
= c
->get_keys(c
, "lxc.network.0", v3
, 2000);
62 fprintf(stderr
, "%d: failed to get nic 0 keys(%d)\n", __LINE__
, ret
);
66 printf("get_keys for nic 1 returned %d\n%s", ret
, v3
);