Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
a1511e8d
Commit
a1511e8d
authored
Oct 12, 2009
by
Daniel Lezcano
Committed by
Daniel Lezcano
Oct 12, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix compilation error for tests
Fix test program compilation errors. Signed-off-by:
Daniel Lezcano
<
dlezcano@fr.ibm.com
>
parent
a79cf704
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
215 deletions
+13
-215
Makefile.am
test/Makefile.am
+0
-5
ipv6_add.c
test/ipv6_add.c
+10
-2
lxc_create.c
test/lxc_create.c
+3
-109
lxc_monitor.c
test/lxc_monitor.c
+0
-99
No files found.
test/Makefile.am
View file @
a1511e8d
...
@@ -21,7 +21,6 @@ noinst_PROGRAMS = \
...
@@ -21,7 +21,6 @@ noinst_PROGRAMS = \
lxc_destroy
\
lxc_destroy
\
lxc_start
\
lxc_start
\
lxc_stop
\
lxc_stop
\
lxc_monitor
\
lxc_low_monitor
\
lxc_low_monitor
\
lxc_state
lxc_state
...
@@ -87,10 +86,6 @@ lxc_stop_SOURCES = lxc_stop.c
...
@@ -87,10 +86,6 @@ lxc_stop_SOURCES = lxc_stop.c
lxc_stop_LDADD
=
\
lxc_stop_LDADD
=
\
$(top_builddir)
/src/lxc/liblxc.la
$(top_builddir)
/src/lxc/liblxc.la
lxc_monitor_SOURCES
=
lxc_monitor.c
lxc_monitor_LDADD
=
\
$(top_builddir)
/src/lxc/liblxc.la
lxc_low_monitor_SOURCES
=
lxc_low_monitor.c
lxc_low_monitor_SOURCES
=
lxc_low_monitor.c
lxc_low_monitor_LDADD
=
\
lxc_low_monitor_LDADD
=
\
$(top_builddir)
/src/lxc/liblxc.la
$(top_builddir)
/src/lxc/liblxc.la
...
...
test/ipv6_add.c
View file @
a1511e8d
...
@@ -26,7 +26,8 @@
...
@@ -26,7 +26,8 @@
#include <errno.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <lxc/network.h>
#include <lxc/network.h>
void
usage
(
char
*
cmd
)
void
usage
(
char
*
cmd
)
...
@@ -37,6 +38,7 @@ void usage(char *cmd)
...
@@ -37,6 +38,7 @@ void usage(char *cmd)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
char
*
ifname
=
NULL
,
*
addr
=
NULL
;
char
*
ifname
=
NULL
,
*
addr
=
NULL
;
struct
in6_addr
in6
;
int
opt
,
ret
=
-
EINVAL
;
int
opt
,
ret
=
-
EINVAL
;
while
((
opt
=
getopt
(
argc
,
argv
,
"i:a:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"i:a:"
))
!=
-
1
)
{
...
@@ -55,7 +57,13 @@ int main(int argc, char *argv[])
...
@@ -55,7 +57,13 @@ int main(int argc, char *argv[])
return
1
;
return
1
;
}
}
ret
=
lxc_ip6_addr_add
(
ifname
,
addr
,
64
,
NULL
);
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
)
{
if
(
ret
)
{
fprintf
(
stderr
,
"failed to set %s: %s
\n
"
,
fprintf
(
stderr
,
"failed to set %s: %s
\n
"
,
ifname
,
strerror
(
-
ret
));
ifname
,
strerror
(
-
ret
));
...
...
test/lxc_create.c
View file @
a1511e8d
...
@@ -42,116 +42,8 @@ int main(int argc, char *argv[])
...
@@ -42,116 +42,8 @@ int main(int argc, char *argv[])
{
{
const
char
*
name
=
NULL
;
const
char
*
name
=
NULL
;
int
opt
;
int
opt
;
/* struct list mclist; */
/* struct list mclist2; */
/* struct list vethlist; */
/* struct list vethlist2; */
struct
lxc_list
phylist
;
/* struct inetdev idev; */
struct
lxc_conf
lxc_conf
;
/* struct list l1 = init_list(&l1); */
/* l1.elem = &idev; */
/* struct inetdev idev_2; */
/* struct list l2 = init_list(&l2); */
/* l2.elem = &idev_2; */
/* struct inet6dev idev6; */
/* struct list l3 = init_list(&l3); */
/* l3.elem = &idev6; */
/* struct inet6dev idev6_2; */
/* struct list l4 = init_list(&l4); */
/* l4.elem = idev6_2; */
/* inet_pton(AF_INET, "1.2.3.4", &idev.addr); */
/* inet_pton(AF_INET, "1.2.3.255", &idev.bcast); */
/* idev.prefix = 24; */
/* inet_pton(AF_INET, "4.3.2.1", &idev_2.addr); */
/* inet_pton(AF_INET, "4.3.2.255", &idev_2.bcast); */
/* inet_pton(AF_INET6, "2003:db8:1:0:214:5eff:fe0b:3596", &idev6.addr); */
/* inet_pton(AF_INET6, "2003:db8:1:0:214:1234:fe0b:3596", &idev6_2.addr); */
/* struct network veth = { */
/* .type = VETH, */
/* .netdev = { */
/* .flags = IFF_UP, */
/* .ifname = "br0", */
/* .newname = "eth0", */
/* .ipv4 = init_list(&veth.netdev.ipv4), */
/* .ipv6 = init_list(&veth.netdev.ipv6), */
/* }, */
/* }; */
/* vethlist.elem = &veth; */
/* list_add(&veth.netdev.ipv4, &l1); */
/* list_add(&veth.netdev.ipv4, &l2); */
/* list_add(&veth.netdev.ipv6, &l4); */
/* struct network veth2 = { */
/* .type = VETH, */
/* .netdev = { */
/* .flags = IFF_UP, */
/* .ifname = "br0", */
/* .newname = "eth1", */
/* .ipv4 = init_list(&veth2.netdev.ipv4), */
/* .ipv6 = init_list(&veth2.netdev.ipv6), */
/* }, */
/* }; */
/* list_add(&veth2.netdev.ipv6, &l3); */
/* vethlist2.elem = &veth2; */
/* struct network macvlan = { */
/* .type = MACVLAN, */
/* .netdev = { */
/* .flags = IFF_UP, */
/* .ifname = "eth0", */
/* .ipv4 = init_list(&macvlan.netdev.ipv4), */
/* .ipv6 = init_list(&macvlan.netdev.ipv6), */
/* }, */
/* }; */
/* mclist.elem = &macvlan; */
/* struct network macvlan2 = { */
/* .type = MACVLAN, */
/* .netdev = { */
/* .ifname = "eth0", */
/* .ipv4 = init_list(&macvlan2.netdev.ipv4), */
/* .ipv6 = init_list(&macvlan2.netdev.ipv6), */
/* }, */
/* }; */
/* mclist2.elem = &macvlan2; */
struct
lxc_netdev
nd
=
{
.
ifname
=
"dummy0"
,
.
ipv4
=
lxc_init_list
(
&
nd
.
ipv4
),
.
ipv6
=
lxc_init_list
(
&
nd
.
ipv6
),
};
struct
lxc_list
ndlist
=
lxc_init_list
(
&
ndlist
);
ndlist
.
elem
=
&
nd
;
struct
lxc_network
phys
=
{
.
type
=
PHYS
,
.
netdev
=
lxc_init_list
(
&
phys
.
netdev
),
};
phylist
.
elem
=
&
phys
;
struct
lxc_conf
lxc_conf
=
{
.
networks
=
lxc_init_list
(
&
lxc_conf
.
networks
),
.
rootfs
=
"/mnt/iso"
,
};
lxc_list_add
(
&
phys
.
netdev
,
&
ndlist
);
/* list_add(&lxc_conf.networks, &vethlist); */
/* list_add(&lxc_conf.networks, &mclist); */
lxc_list_add
(
&
lxc_conf
.
networks
,
&
phylist
);
/* list_add(&lxc_conf.networks, &mclist); */
/* list_add(&lxc_conf.networks, &vethlist2); */
while
((
opt
=
getopt
(
argc
,
argv
,
"n:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"n:"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
...
@@ -164,6 +56,8 @@ int main(int argc, char *argv[])
...
@@ -164,6 +56,8 @@ int main(int argc, char *argv[])
if
(
!
name
)
if
(
!
name
)
usage
(
argv
[
0
]);
usage
(
argv
[
0
]);
lxc_conf_init
(
&
lxc_conf
);
if
(
lxc_create
(
name
,
&
lxc_conf
))
{
if
(
lxc_create
(
name
,
&
lxc_conf
))
{
fprintf
(
stderr
,
"failed to create the container %s
\n
"
,
name
);
fprintf
(
stderr
,
"failed to create the container %s
\n
"
,
name
);
return
1
;
return
1
;
...
...
test/lxc_monitor.c
deleted
100644 → 0
View file @
a79cf704
/*
* 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
fds
[
2
];
pid_t
pid
;
while
((
opt
=
getopt
(
argc
,
argv
,
"n:"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'n'
:
name
=
optarg
;
break
;
}
}
if
(
!
name
)
usage
(
argv
[
0
]);
if
(
pipe
(
fds
))
{
perror
(
"pipe"
);
return
1
;
}
pid
=
fork
();
if
(
pid
<
0
)
{
perror
(
"fork"
);
return
1
;
}
if
(
!
pid
)
{
close
(
fds
[
0
]);
if
(
lxc_monitor
(
name
,
fds
[
1
]))
{
fprintf
(
stderr
,
"failed to monitor %s
\n
"
,
name
);
return
1
;
}
return
0
;
}
close
(
fds
[
1
]);
for
(;;)
{
int
err
,
state
;
err
=
read
(
fds
[
0
],
&
state
,
sizeof
(
state
));
if
(
err
<
0
)
{
perror
(
"read"
);
return
1
;
}
if
(
!
err
)
{
printf
(
"container has been destroyed
\n
"
);
return
0
;
}
printf
(
"container has changed the state to %d - %s
\n
"
,
state
,
lxc_state2str
(
state
));
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment