]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/device_add_remove.c
3 * Copyright © 2014 S.Çağlar Onur <caglar@10ur.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2, as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <lxc/lxccontainer.h>
23 #define NAME "device_add_remove_test"
24 #define DEVICE "/dev/network_latency"
26 int main(int argc
, char *argv
[])
29 struct lxc_container
*c
;
31 c
= lxc_container_new(NAME
, NULL
);
33 fprintf(stderr
, "Unable to instantiate container (%s)...\n", NAME
);
37 if (!c
->create(c
, "busybox", NULL
, NULL
, 1, NULL
)) {
38 fprintf(stderr
, "Creating the container (%s) failed...\n", NAME
);
42 c
->want_daemonize(c
, true);
44 if (!c
->start(c
, false, NULL
)) {
45 fprintf(stderr
, "Starting the container (%s) failed...\n", NAME
);
49 if (!c
->add_device_node(c
, DEVICE
, DEVICE
)) {
50 fprintf(stderr
, "Adding %s to the container (%s) failed...\n", DEVICE
, NAME
);
54 if (!c
->remove_device_node(c
, DEVICE
, DEVICE
)) {
55 fprintf(stderr
, "Removing %s from the container (%s) failed...\n", DEVICE
, NAME
);
60 fprintf(stderr
, "Stopping the container (%s) failed...\n", NAME
);
65 fprintf(stderr
, "Destroying the container (%s) failed...\n", NAME
);