mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-06 06:34:43 +00:00
remove test directory
These tests are not relevant now. It would be better to write some real test cases with some script using the lxc cli in order to check non regression. I remove these annoying tests I have to port each time a function prototype is changed. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
0e322d2295
commit
92d385229b
@ -2,8 +2,8 @@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I config
|
||||
|
||||
SUBDIRS = src test etc scripts doc
|
||||
DIST_SUBDIRS = config src test etc scripts doc
|
||||
SUBDIRS = src etc scripts doc
|
||||
DIST_SUBDIRS = config src etc scripts doc
|
||||
EXTRA_DIST = autogen.sh lxc.spec CONTRIBUTING MAINTAINERS ChangeLog
|
||||
|
||||
pcdatadir = $(datadir)/pkgconfig
|
||||
|
@ -50,9 +50,6 @@ LXC_MAJOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f1)
|
||||
LXC_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
|
||||
LXC_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
|
||||
|
||||
AC_ARG_ENABLE(test, [ --enable-test compile test program [default=no]],, enable_test=no)
|
||||
AM_CONDITIONAL(ENABLE_TEST, test x$enable_test = xyes)
|
||||
|
||||
AC_SUBST(LXC_MAJOR_VERSION)
|
||||
AC_SUBST(LXC_MINOR_VERSION)
|
||||
AC_SUBST(LXC_MICRO_VERSION)
|
||||
@ -103,8 +100,6 @@ AC_CONFIG_FILES([
|
||||
etc/lxc-phys.conf
|
||||
etc/lxc-veth.conf
|
||||
etc/lxc-complex-config
|
||||
|
||||
test/Makefile
|
||||
])
|
||||
AC_CONFIG_COMMANDS([default],[[]],[[]])
|
||||
AC_OUTPUT
|
||||
|
@ -1,97 +0,0 @@
|
||||
if ENABLE_TEST
|
||||
|
||||
AM_LDFLAGS = -lutil
|
||||
|
||||
INCLUDES= -I$(top_srcdir)/src
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
tst_list \
|
||||
confile \
|
||||
conf \
|
||||
movedev \
|
||||
dev \
|
||||
forward \
|
||||
proxy \
|
||||
veth \
|
||||
macvlan \
|
||||
ipv4_add \
|
||||
ipv6_add \
|
||||
\
|
||||
lxc_create \
|
||||
lxc_destroy \
|
||||
lxc_start \
|
||||
lxc_stop \
|
||||
lxc_low_monitor \
|
||||
lxc_state
|
||||
|
||||
tst_list_SOURCES = tst_list.c
|
||||
tst_list_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
confile_SOURCES = confile.c
|
||||
confile_LDADD = \
|
||||
$(top_builddir)/src/lxc/conf.o \
|
||||
$(top_builddir)/src/lxc/confile.o \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
conf_SOURCES = conf.c
|
||||
conf_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
movedev_SOURCES = movedev.c
|
||||
movedev_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
dev_SOURCES = dev.c
|
||||
dev_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
forward_SOURCES = forward.c
|
||||
forward_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
proxy_SOURCES = proxy.c
|
||||
proxy_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
veth_SOURCES = veth.c
|
||||
veth_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
macvlan_SOURCES = macvlan.c
|
||||
macvlan_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
ipv4_add_SOURCES = ipv4_add.c
|
||||
ipv4_add_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
ipv6_add_SOURCES = ipv6_add.c
|
||||
ipv6_add_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_create_SOURCES = lxc_create.c
|
||||
lxc_create_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_destroy_SOURCES = lxc_destroy.c
|
||||
lxc_destroy_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_start_SOURCES = lxc_start.c
|
||||
lxc_start_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_stop_SOURCES = lxc_stop.c
|
||||
lxc_stop_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_low_monitor_SOURCES = lxc_low_monitor.c
|
||||
lxc_low_monitor_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
lxc_state_SOURCES = lxc_state.c
|
||||
lxc_state_LDADD = \
|
||||
$(top_builddir)/src/lxc/liblxc.la
|
||||
|
||||
endif
|
102
test/conf.c
102
test/conf.c
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <lxc/list.h>
|
||||
#include <lxc/conf.h>
|
||||
|
||||
/*
|
||||
* I want to setup a container with a veth attached on a bridge,
|
||||
* and have them up
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* struct network network = { */
|
||||
/* .net = init_list(&network.net), */
|
||||
/* .netdev = init_list(&network.netdev), */
|
||||
/* }; */
|
||||
|
||||
/* struct veth veth = { */
|
||||
/* .link = "veth1", */
|
||||
/* .peer = "veth2", */
|
||||
/* .bridge = "br0", */
|
||||
/* }; */
|
||||
|
||||
/* struct net net = { */
|
||||
/* .type = VETH, */
|
||||
/* }; */
|
||||
|
||||
/* net.veth = veth; */
|
||||
|
||||
/* struct netdev lo = { */
|
||||
/* .ifname = "lo", */
|
||||
/* .flags = IFF_UP, */
|
||||
/* .ipv4 = init_list(&lo.ipv4), */
|
||||
/* .ipv6 = init_list(&lo.ipv6), */
|
||||
/* }; */
|
||||
|
||||
/* struct netdev veth1 = { */
|
||||
/* .ifname = "veth1", */
|
||||
/* .flags = IFF_UP, */
|
||||
/* .ipv4 = init_list(&veth1.ipv4), */
|
||||
/* .ipv6 = init_list(&veth1.ipv6), */
|
||||
/* }; */
|
||||
|
||||
/* struct netdev veth2 = { */
|
||||
/* .ifname = "veth2", */
|
||||
/* .flags = IFF_UP, */
|
||||
/* .netns = 1, */
|
||||
/* .ipv4 = init_list(&veth2.ipv4), */
|
||||
/* .ipv6 = init_list(&veth2.ipv6), */
|
||||
/* }; */
|
||||
|
||||
/* struct netdev br0 = { */
|
||||
/* .ifname = "br0", */
|
||||
/* .ipv4 = init_list(&br0.ipv4), */
|
||||
/* .ipv6 = init_list(&br0.ipv6), */
|
||||
/* }; */
|
||||
|
||||
/* list_add(&network.netdev, &lo.list); */
|
||||
/* list_add(&network.netdev, &veth1.list); */
|
||||
/* list_add(&network.netdev, &veth2.list); */
|
||||
/* list_add(&network.netdev, &br0.list); */
|
||||
/* list_add(&network.net, &net.list); */
|
||||
|
||||
/* struct lxc_conf lxc_conf = { */
|
||||
/* .network = &network, */
|
||||
/* .mounts = init_list(&lxc_conf.mounts), */
|
||||
/* }; */
|
||||
|
||||
/* if (lxc_configure("foo", &lxc_conf)) { */
|
||||
/* fprintf(stderr, "failed to configure\n"); */
|
||||
/* return 1; */
|
||||
/* } */
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
#include <lxc/conf.h>
|
||||
#include <lxc/confile.h>
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -n <name>\n", cmd);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *file = NULL, *name = NULL;
|
||||
struct lxc_conf lxc_conf;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:f:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
file = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file || !name)
|
||||
usage(argv[0]);
|
||||
|
||||
if (lxc_conf_init(&lxc_conf)) {
|
||||
fprintf(stderr, "failed to initialize configuration structure\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lxc_config_read(file, &lxc_conf)) {
|
||||
fprintf(stderr, "failed to read configuration\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lxc_create(name, file)) {
|
||||
fprintf(stderr, "failed to create <%s>\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
76
test/dev.c
76
test/dev.c
@ -1,76 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -d -f <up|down>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *flag = NULL;
|
||||
int opt, destroy = 0, ret = -EINVAL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:f:d")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
flag = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
destroy = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || (!flag && !destroy)) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (destroy)
|
||||
ret = lxc_device_delete(ifname);
|
||||
else if (!strcmp(flag, "up"))
|
||||
ret = lxc_device_up(ifname);
|
||||
else if (!strcmp(flag, "down"))
|
||||
ret = lxc_device_down(ifname);
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to set %s: %s\n",
|
||||
ifname, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -f <on|off>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *flag = NULL;
|
||||
int opt, ret, family = AF_INET;
|
||||
|
||||
while ((opt = getopt(argc, argv, "6i:f:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
flag = optarg;
|
||||
break;
|
||||
case '6':
|
||||
family = AF_INET6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || !flag) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(flag, "on"))
|
||||
ret = lxc_ip_forward_on(ifname, family);
|
||||
else if (!strcmp(flag, "off"))
|
||||
ret = lxc_ip_forward_off(ifname, family);
|
||||
else {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed for %s: %s\n",
|
||||
ifname, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -a <ip>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *addr = NULL;
|
||||
int opt, ret = -EINVAL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:a:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
addr = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!addr || !ifname) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = lxc_ip_addr_add(ifname, addr, 24, NULL);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to set %s: %s\n",
|
||||
ifname, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -a <ip>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *addr = NULL;
|
||||
struct in6_addr in6;
|
||||
int opt, ret = -EINVAL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:a:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
addr = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!addr || !ifname) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (inet_pton(AF_INET6, addr, &in6)) {
|
||||
perror("inet_pton");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = lxc_ip_addr_add(AF_INET6, if_nametoindex(ifname),
|
||||
&in6, 64);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to set %s: %s\n",
|
||||
ifname, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -n <name>\n", cmd);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *name = NULL;
|
||||
int opt;
|
||||
|
||||
struct lxc_conf lxc_conf;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
lxc_conf_init(&lxc_conf);
|
||||
|
||||
if (lxc_create(name, NULL)) {
|
||||
fprintf(stderr, "failed to create the container %s\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
static void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -n <name>\n", cmd);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *name = NULL;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
if (lxc_destroy(name)) {
|
||||
fprintf(stderr, "failed to destroy %s\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s <command>\n", basename(cmd));
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char opt;
|
||||
char *name = NULL;
|
||||
int fd;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
fd = lxc_monitor_open();
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "failed to open monitor\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
struct lxc_msg msg;
|
||||
lxc_monitor_read(fd, &msg);
|
||||
if (msg.type == lxc_msg_state) {
|
||||
printf("received changing state '%s'\n", lxc_state2str(msg.value));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s <command>\n", basename(cmd));
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char opt;
|
||||
char *name = NULL;
|
||||
char **args;
|
||||
int nbargs = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
|
||||
nbargs++;
|
||||
}
|
||||
|
||||
if (!name || !argv[optind] || !strlen(argv[optind]))
|
||||
usage(argv[0]);
|
||||
|
||||
args = &argv[optind];
|
||||
argc -= nbargs;
|
||||
|
||||
if (lxc_start(name, args)) {
|
||||
fprintf(stderr, "failed to start %s\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s <command>\n", basename(cmd));
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char opt;
|
||||
char *name = NULL;
|
||||
int state;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
state = lxc_state(name);
|
||||
if (state < 0) {
|
||||
fprintf(stderr, "failed to retrieve the state of %s\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("container has the state to %d - %s\n",
|
||||
state, lxc_state2str(state));
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <lxc/lxc.h>
|
||||
|
||||
void usage(char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s <command>\n", basename(cmd));
|
||||
fprintf(stderr, "\t -n <name> : name of the container\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char opt;
|
||||
char *name = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "n:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name)
|
||||
usage(argv[0]);
|
||||
|
||||
if (lxc_stop(name)) {
|
||||
fprintf(stderr, "failed to stop %s\n", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -p <ifname>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *peer = NULL;
|
||||
int opt, ret = -EINVAL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:p:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
peer = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || !peer) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = lxc_macvlan_create(ifname, peer);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to set %s/%s: %s\n",
|
||||
ifname, peer, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -p <pid>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL;
|
||||
pid_t pid = -1;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "p:i:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'p':
|
||||
pid = atoi(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || pid == -1) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lxc_device_move(ifname, pid)) {
|
||||
fprintf(stderr, "failed to move %s\n", ifname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
77
test/proxy.c
77
test/proxy.c
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -f <on|off>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *flag = NULL;
|
||||
int opt, ret, family = AF_INET;
|
||||
|
||||
while ((opt = getopt(argc, argv, "6i:f:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
flag = optarg;
|
||||
break;
|
||||
case '6':
|
||||
family = AF_INET6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || !flag) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(flag, "on"))
|
||||
ret = lxc_neigh_proxy_on(ifname, family);
|
||||
else if (!strcmp(flag, "off"))
|
||||
ret = lxc_neigh_proxy_off(ifname, family);
|
||||
else {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed for %s: %s\n",
|
||||
ifname, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <lxc/list.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct lxc_list *iterator;
|
||||
struct lxc_list head = lxc_init_list(&head);
|
||||
struct lxc_list l1 = lxc_init_list(&l1);
|
||||
struct lxc_list l2 = lxc_init_list(&l2);
|
||||
struct lxc_list l3 = lxc_init_list(&l3);
|
||||
struct lxc_list l4 = lxc_init_list(&l4);
|
||||
|
||||
struct dummy {
|
||||
int a;
|
||||
};
|
||||
|
||||
struct dummy *elem;
|
||||
struct dummy d1 = { .a = 1 };
|
||||
struct dummy d2 = { .a = 2 };
|
||||
struct dummy d3 = { .a = 3 };
|
||||
struct dummy d4 = { .a = 4 };
|
||||
|
||||
if (!lxc_list_empty(&head)) {
|
||||
fprintf(stderr, "expected empty list\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
l1.elem = &d1;
|
||||
l2.elem = &d2;
|
||||
l3.elem = &d3;
|
||||
l4.elem = &d4;
|
||||
|
||||
lxc_list_add(&head, &l1);
|
||||
lxc_list_add(&head, &l2);
|
||||
lxc_list_add(&head, &l3);
|
||||
lxc_list_add(&head, &l4);
|
||||
|
||||
lxc_list_for_each(iterator, &head) {
|
||||
elem = iterator->elem;
|
||||
printf("elem has %d\n", elem->a);
|
||||
}
|
||||
|
||||
lxc_list_del(&l3);
|
||||
|
||||
lxc_list_for_each(iterator, &head) {
|
||||
elem = iterator->elem;
|
||||
printf("elem has %d\n", elem->a);
|
||||
}
|
||||
|
||||
lxc_list_del(&l1);
|
||||
lxc_list_del(&l2);
|
||||
lxc_list_del(&l4);
|
||||
|
||||
if (!lxc_list_empty(&head)) {
|
||||
fprintf(stderr, "expected empty list\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
lxc_list_for_each(iterator, &head) {
|
||||
fprintf(stderr, "should not loop\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
66
test/veth.c
66
test/veth.c
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* lxc: linux Container library
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2007, 2008
|
||||
*
|
||||
* Authors:
|
||||
* Daniel Lezcano <dlezcano at fr.ibm.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <lxc/network.h>
|
||||
|
||||
void usage(const char *cmd)
|
||||
{
|
||||
fprintf(stderr, "%s -i <ifname> -p <ifname>\n", cmd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ifname = NULL, *peer = NULL;
|
||||
int opt, ret = -EINVAL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "i:p:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
peer = optarg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname || !peer) {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = lxc_veth_create(ifname, peer);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to set %s/%s: %s\n",
|
||||
ifname, peer, strerror(-ret));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user