Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
430e9391
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
430e9391
编写于
7月 24, 2014
作者:
C
Cédric Bosdonnat
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lxc conf2xml: convert lxc.network.ipv[46].gateway
上级
c9a641f1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
64 addition
and
1 deletion
+64
-1
src/lxc/lxc_native.c
src/lxc/lxc_native.c
+56
-1
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
+2
-0
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
+2
-0
tests/lxcconf2xmldata/lxcconf2xml-simple.config
tests/lxcconf2xmldata/lxcconf2xml-simple.config
+2
-0
tests/lxcconf2xmldata/lxcconf2xml-simple.xml
tests/lxcconf2xmldata/lxcconf2xml-simple.xml
+2
-0
未找到文件。
src/lxc/lxc_native.c
浏览文件 @
430e9391
...
...
@@ -424,10 +424,36 @@ typedef struct {
char
*
name
;
virDomainNetIpDefPtr
*
ips
;
size_t
nips
;
char
*
gateway_ipv4
;
char
*
gateway_ipv6
;
bool
privnet
;
size_t
networks
;
}
lxcNetworkParseData
;
static
int
lxcAddNetworkRouteDefinition
(
const
char
*
address
,
int
family
,
virDomainNetRouteDefPtr
**
routes
,
size_t
*
nroutes
)
{
virDomainNetRouteDefPtr
route
=
NULL
;
if
(
VIR_ALLOC
(
route
)
<
0
)
goto
error
;
if
(
virSocketAddrParse
(
&
route
->
via
,
address
,
family
)
<
0
)
goto
error
;
if
(
VIR_APPEND_ELEMENT
(
*
routes
,
*
nroutes
,
route
)
<
0
)
goto
error
;
return
0
;
error:
VIR_FREE
(
route
);
return
-
1
;
}
static
int
lxcAddNetworkDefinition
(
lxcNetworkParseData
*
data
)
{
...
...
@@ -465,6 +491,18 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
hostdev
->
source
.
caps
.
u
.
net
.
ips
=
data
->
ips
;
hostdev
->
source
.
caps
.
u
.
net
.
nips
=
data
->
nips
;
if
(
data
->
gateway_ipv4
&&
lxcAddNetworkRouteDefinition
(
data
->
gateway_ipv4
,
AF_INET
,
&
hostdev
->
source
.
caps
.
u
.
net
.
routes
,
&
hostdev
->
source
.
caps
.
u
.
net
.
nroutes
)
<
0
)
goto
error
;
if
(
data
->
gateway_ipv6
&&
lxcAddNetworkRouteDefinition
(
data
->
gateway_ipv6
,
AF_INET6
,
&
hostdev
->
source
.
caps
.
u
.
net
.
routes
,
&
hostdev
->
source
.
caps
.
u
.
net
.
nroutes
)
<
0
)
goto
error
;
if
(
VIR_EXPAND_N
(
data
->
def
->
hostdevs
,
data
->
def
->
nhostdevs
,
1
)
<
0
)
goto
error
;
data
->
def
->
hostdevs
[
data
->
def
->
nhostdevs
-
1
]
=
hostdev
;
...
...
@@ -477,6 +515,18 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
net
->
ips
=
data
->
ips
;
net
->
nips
=
data
->
nips
;
if
(
data
->
gateway_ipv4
&&
lxcAddNetworkRouteDefinition
(
data
->
gateway_ipv4
,
AF_INET
,
&
net
->
routes
,
&
net
->
nroutes
)
<
0
)
goto
error
;
if
(
data
->
gateway_ipv6
&&
lxcAddNetworkRouteDefinition
(
data
->
gateway_ipv6
,
AF_INET6
,
&
net
->
routes
,
&
net
->
nroutes
)
<
0
)
goto
error
;
if
(
VIR_EXPAND_N
(
data
->
def
->
nets
,
data
->
def
->
nnets
,
1
)
<
0
)
goto
error
;
data
->
def
->
nets
[
data
->
def
->
nnets
-
1
]
=
net
;
...
...
@@ -568,6 +618,10 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
VIR_FREE
(
ip
);
return
-
1
;
}
}
else
if
(
STREQ
(
name
,
"lxc.network.ipv4.gateway"
))
{
parseData
->
gateway_ipv4
=
value
->
str
;
}
else
if
(
STREQ
(
name
,
"lxc.network.ipv6.gateway"
))
{
parseData
->
gateway_ipv6
=
value
->
str
;
}
else
if
(
STRPREFIX
(
name
,
"lxc.network"
))
{
VIR_WARN
(
"Unhandled network property: %s = %s"
,
name
,
...
...
@@ -584,7 +638,8 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
int
result
=
-
1
;
size_t
i
;
lxcNetworkParseData
data
=
{
def
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
true
,
0
};
NULL
,
NULL
,
NULL
,
NULL
,
0
,
NULL
,
NULL
,
true
,
0
};
if
(
virConfWalk
(
properties
,
lxcNetworkWalkCallback
,
&
data
)
<
0
)
goto
error
;
...
...
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
浏览文件 @
430e9391
...
...
@@ -2,7 +2,9 @@ lxc.network.type = phys
lxc
.
network
.
link
=
eth0
lxc
.
network
.
name
=
eth1
lxc
.
network
.
ipv4
=
192
.
168
.
122
.
2
/
24
lxc
.
network
.
ipv4
.
gateway
=
192
.
168
.
122
.
1
lxc
.
network
.
ipv6
=
2003
:
db8
:
1
:
0
:
214
:
1234
:
fe0b
:
3596
/
64
lxc
.
network
.
ipv6
.
gateway
=
2003
:
db8
:
1
:
0
:
214
:
1234
:
fe0b
:
3595
lxc
.
rootfs
= /
var
/
lib
/
lxc
/
migrate_test
/
rootfs
lxc
.
utsname
=
migrate_test
...
...
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
浏览文件 @
430e9391
...
...
@@ -27,6 +27,8 @@
</source>
<ip
address=
'192.168.122.2'
family=
'ipv4'
prefix=
'24'
/>
<ip
address=
'2003:db8:1:0:214:1234:fe0b:3596'
family=
'ipv6'
prefix=
'64'
/>
<route
family=
'ipv4'
via=
'192.168.122.1'
/>
<route
family=
'ipv6'
via=
'2003:db8:1:0:214:1234:fe0b:3595'
/>
</hostdev>
</devices>
</domain>
tests/lxcconf2xmldata/lxcconf2xml-simple.config
浏览文件 @
430e9391
...
...
@@ -7,7 +7,9 @@ lxc.network.link = virbr0
lxc
.
network
.
hwaddr
=
02
:
00
:
15
:
8
f
:
05
:
c1
lxc
.
network
.
name
=
eth0
lxc
.
network
.
ipv4
=
192
.
168
.
122
.
2
/
24
lxc
.
network
.
ipv4
.
gateway
=
192
.
168
.
122
.
1
lxc
.
network
.
ipv6
=
2003
:
db8
:
1
:
0
:
214
:
1234
:
fe0b
:
3596
/
64
lxc
.
network
.
ipv6
.
gateway
=
2003
:
db8
:
1
:
0
:
214
:
1234
:
fe0b
:
3595
#remove next line if host DNS configuration should not be available to container
lxc
.
mount
.
entry
=
proc
proc
proc
nodev
,
noexec
,
nosuid
0
0
...
...
tests/lxcconf2xmldata/lxcconf2xml-simple.xml
浏览文件 @
430e9391
...
...
@@ -39,6 +39,8 @@
<source
bridge=
'virbr0'
/>
<ip
address=
'192.168.122.2'
family=
'ipv4'
prefix=
'24'
/>
<ip
address=
'2003:db8:1:0:214:1234:fe0b:3596'
family=
'ipv6'
prefix=
'64'
/>
<route
family=
'ipv4'
via=
'192.168.122.1'
/>
<route
family=
'ipv6'
via=
'2003:db8:1:0:214:1234:fe0b:3595'
/>
<guest
dev=
'eth0'
/>
<link
state=
'up'
/>
</interface>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录