Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8e45b887
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看板
提交
8e45b887
编写于
2月 05, 2014
作者:
C
Cédric Bosdonnat
提交者:
Daniel P. Berrange
2月 12, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
LXC from native: convert macvlan network configuration
上级
f01fe54e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
77 addition
and
10 deletion
+77
-10
src/lxc/lxc_native.c
src/lxc/lxc_native.c
+37
-10
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.config
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.config
+13
-0
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml
+26
-0
tests/lxcconf2xmltest.c
tests/lxcconf2xmltest.c
+1
-0
未找到文件。
src/lxc/lxc_native.c
浏览文件 @
8e45b887
...
...
@@ -332,9 +332,11 @@ static virDomainNetDefPtr
lxcCreateNetDef
(
const
char
*
type
,
const
char
*
link
,
const
char
*
mac
,
const
char
*
flag
)
const
char
*
flag
,
const
char
*
macvlanmode
)
{
virDomainNetDefPtr
net
=
NULL
;
virMacAddr
macAddr
;
if
(
VIR_ALLOC
(
net
)
<
0
)
goto
error
;
...
...
@@ -346,9 +348,11 @@ lxcCreateNetDef(const char *type,
net
->
linkstate
=
VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN
;
}
if
(
STREQ
(
type
,
"veth"
))
{
virMacAddr
macAddr
;
if
(
mac
&&
virMacAddrParse
(
mac
,
&
macAddr
)
==
0
)
net
->
mac
=
macAddr
;
if
(
STREQ
(
type
,
"veth"
))
{
if
(
!
link
)
goto
error
;
...
...
@@ -357,9 +361,20 @@ lxcCreateNetDef(const char *type,
if
(
VIR_STRDUP
(
net
->
data
.
bridge
.
brname
,
link
)
<
0
)
goto
error
;
if
(
mac
&&
virMacAddrParse
(
mac
,
&
macAddr
)
==
0
)
net
->
mac
=
macAddr
;
}
else
if
(
STREQ
(
type
,
"macvlan"
))
{
net
->
type
=
VIR_DOMAIN_NET_TYPE_DIRECT
;
if
(
!
link
||
VIR_STRDUP
(
net
->
data
.
direct
.
linkdev
,
link
)
<
0
)
goto
error
;
if
(
!
macvlanmode
||
STREQ
(
macvlanmode
,
"private"
))
net
->
data
.
direct
.
mode
=
VIR_NETDEV_MACVLAN_MODE_PRIVATE
;
else
if
(
STREQ
(
macvlanmode
,
"vepa"
))
net
->
data
.
direct
.
mode
=
VIR_NETDEV_MACVLAN_MODE_VEPA
;
else
if
(
STREQ
(
macvlanmode
,
"bridge"
))
net
->
data
.
direct
.
mode
=
VIR_NETDEV_MACVLAN_MODE_BRIDGE
;
else
VIR_WARN
(
"Unknown macvlan type: %s"
,
macvlanmode
);
}
return
net
;
...
...
@@ -394,7 +409,8 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
const
char
*
type
,
const
char
*
link
,
const
char
*
mac
,
const
char
*
flag
)
const
char
*
flag
,
const
char
*
macvlanmode
)
{
virDomainNetDefPtr
net
=
NULL
;
virDomainHostdevDefPtr
hostdev
=
NULL
;
...
...
@@ -414,7 +430,7 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
goto
error
;
def
->
hostdevs
[
def
->
nhostdevs
-
1
]
=
hostdev
;
}
else
{
if
(
!
(
net
=
lxcCreateNetDef
(
type
,
link
,
mac
,
flag
)))
if
(
!
(
net
=
lxcCreateNetDef
(
type
,
link
,
mac
,
flag
,
macvlanmode
)))
goto
error
;
if
(
VIR_EXPAND_N
(
def
->
nets
,
def
->
nnets
,
1
)
<
0
)
...
...
@@ -436,6 +452,7 @@ typedef struct {
char
*
link
;
char
*
mac
;
char
*
flag
;
char
*
macvlanmode
;
bool
privnet
;
size_t
networks
;
}
lxcNetworkParseData
;
...
...
@@ -450,7 +467,9 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
/* Store the previous NIC */
status
=
lxcAddNetworkDefinition
(
parseData
->
def
,
parseData
->
type
,
parseData
->
link
,
parseData
->
mac
,
parseData
->
flag
);
parseData
->
flag
,
parseData
->
macvlanmode
);
if
(
status
<
0
)
return
-
1
;
else
if
(
status
>
0
)
...
...
@@ -463,6 +482,7 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
parseData
->
link
=
NULL
;
parseData
->
mac
=
NULL
;
parseData
->
flag
=
NULL
;
parseData
->
macvlanmode
=
NULL
;
/* Keep the new value */
parseData
->
type
=
value
->
str
;
...
...
@@ -473,6 +493,12 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
parseData
->
mac
=
value
->
str
;
else
if
(
STREQ
(
name
,
"lxc.network.flags"
))
parseData
->
flag
=
value
->
str
;
else
if
(
STREQ
(
name
,
"lxc.network.macvlan.mode"
))
parseData
->
macvlanmode
=
value
->
str
;
else
if
(
STRPREFIX
(
name
,
"lxc.network"
))
VIR_WARN
(
"Unhandled network property: %s = %s"
,
name
,
value
->
str
);
return
0
;
}
...
...
@@ -481,13 +507,14 @@ static int
lxcConvertNetworkSettings
(
virDomainDefPtr
def
,
virConfPtr
properties
)
{
int
status
;
lxcNetworkParseData
data
=
{
def
,
NULL
,
NULL
,
NULL
,
NULL
,
true
,
0
};
lxcNetworkParseData
data
=
{
def
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
true
,
0
};
virConfWalk
(
properties
,
lxcNetworkWalkCallback
,
&
data
);
/* Add the last network definition found */
status
=
lxcAddNetworkDefinition
(
def
,
data
.
type
,
data
.
link
,
data
.
mac
,
data
.
flag
);
data
.
mac
,
data
.
flag
,
data
.
macvlanmode
);
if
(
status
<
0
)
return
-
1
;
else
if
(
status
>
0
)
...
...
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.config
0 → 100644
浏览文件 @
8e45b887
# Template used to create this container: opensuse
# Template script checksum (SHA-1): 27307e0a95bd81b2c0bd82d6f87fdbe83be075ef
lxc
.
network
.
type
=
macvlan
lxc
.
network
.
flags
=
up
lxc
.
network
.
link
=
eth0
lxc
.
network
.
hwaddr
=
02
:
00
:
15
:
8
f
:
05
:
c1
lxc
.
network
.
macvlan
.
mode
=
vepa
#remove next line if host DNS configuration should not be available to container
lxc
.
rootfs
= /
var
/
lib
/
lxc
/
migrate_test
/
rootfs
lxc
.
utsname
=
migrate_test
lxc
.
autodev
=
1
tests/lxcconf2xmldata/lxcconf2xml-macvlannetwork.xml
0 → 100644
浏览文件 @
8e45b887
<domain
type=
'lxc'
>
<name>
migrate_test
</name>
<uuid>
c7a5fdbd-edaf-9455-926a-d65c16db1809
</uuid>
<memory
unit=
'KiB'
>
65536
</memory>
<currentMemory
unit=
'KiB'
>
0
</currentMemory>
<vcpu
placement=
'static'
current=
'0'
>
1
</vcpu>
<os>
<type>
exe
</type>
<init>
/sbin/init
</init>
</os>
<clock
offset=
'utc'
/>
<on_poweroff>
destroy
</on_poweroff>
<on_reboot>
restart
</on_reboot>
<on_crash>
destroy
</on_crash>
<devices>
<filesystem
type=
'mount'
accessmode=
'passthrough'
>
<source
dir=
'/var/lib/lxc/migrate_test/rootfs'
/>
<target
dir=
'/'
/>
</filesystem>
<interface
type=
'direct'
>
<mac
address=
'02:00:15:8f:05:c1'
/>
<source
dev=
'eth0'
mode=
'vepa'
/>
<link
state=
'up'
/>
</interface>
</devices>
</domain>
tests/lxcconf2xmltest.c
浏览文件 @
8e45b887
...
...
@@ -107,6 +107,7 @@ mymain(void)
DO_TEST
(
"nonetwork"
,
false
);
DO_TEST
(
"nonenetwork"
,
false
);
DO_TEST
(
"physnetwork"
,
false
);
DO_TEST
(
"macvlannetwork"
,
false
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录