Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
69fc2362
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看板
提交
69fc2362
编写于
2月 05, 2014
作者:
C
Cédric Bosdonnat
提交者:
Daniel P. Berrange
2月 12, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
LXC from native: convert phys network types to net hostdev devices
上级
b73c029d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
5 deletion
+72
-5
src/lxc/lxc_native.c
src/lxc/lxc_native.c
+39
-5
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
+6
-0
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
+26
-0
tests/lxcconf2xmltest.c
tests/lxcconf2xmltest.c
+1
-0
未找到文件。
src/lxc/lxc_native.c
浏览文件 @
69fc2362
...
@@ -369,6 +369,26 @@ error:
...
@@ -369,6 +369,26 @@ error:
return
NULL
;
return
NULL
;
}
}
static
virDomainHostdevDefPtr
lxcCreateHostdevDef
(
int
mode
,
int
type
,
const
char
*
data
)
{
virDomainHostdevDefPtr
hostdev
=
virDomainHostdevDefAlloc
();
if
(
!
hostdev
)
return
NULL
;
hostdev
->
mode
=
mode
;
hostdev
->
source
.
caps
.
type
=
type
;
if
(
type
==
VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET
&&
VIR_STRDUP
(
hostdev
->
source
.
caps
.
u
.
net
.
iface
,
data
)
<
0
)
{
virDomainHostdevDefFree
(
hostdev
);
hostdev
=
NULL
;
}
return
hostdev
;
}
static
int
static
int
lxcAddNetworkDefinition
(
virDomainDefPtr
def
,
lxcAddNetworkDefinition
(
virDomainDefPtr
def
,
const
char
*
type
,
const
char
*
type
,
...
@@ -377,22 +397,36 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
...
@@ -377,22 +397,36 @@ lxcAddNetworkDefinition(virDomainDefPtr def,
const
char
*
flag
)
const
char
*
flag
)
{
{
virDomainNetDefPtr
net
=
NULL
;
virDomainNetDefPtr
net
=
NULL
;
virDomainHostdevDefPtr
hostdev
=
NULL
;
if
((
type
==
NULL
)
||
STREQ
(
type
,
"empty"
)
||
STREQ
(
type
,
""
)
||
if
((
type
==
NULL
)
||
STREQ
(
type
,
"empty"
)
||
STREQ
(
type
,
""
)
||
STREQ
(
type
,
"none"
))
STREQ
(
type
,
"none"
))
return
0
;
return
0
;
if
(
!
(
net
=
lxcCreateNetDef
(
type
,
link
,
mac
,
flag
)))
if
(
type
!=
NULL
&&
STREQ
(
type
,
"phys"
))
{
goto
error
;
if
(
!
link
||
!
(
hostdev
=
lxcCreateHostdevDef
(
VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES
,
VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET
,
link
)))
goto
error
;
if
(
VIR_EXPAND_N
(
def
->
nets
,
def
->
nnets
,
1
)
<
0
)
if
(
VIR_EXPAND_N
(
def
->
hostdevs
,
def
->
nhostdevs
,
1
)
<
0
)
goto
error
;
goto
error
;
def
->
nets
[
def
->
nnets
-
1
]
=
net
;
def
->
hostdevs
[
def
->
nhostdevs
-
1
]
=
hostdev
;
}
else
{
if
(
!
(
net
=
lxcCreateNetDef
(
type
,
link
,
mac
,
flag
)))
goto
error
;
if
(
VIR_EXPAND_N
(
def
->
nets
,
def
->
nnets
,
1
)
<
0
)
goto
error
;
def
->
nets
[
def
->
nnets
-
1
]
=
net
;
}
return
1
;
return
1
;
error:
error:
virDomainNetDefFree
(
net
);
virDomainNetDefFree
(
net
);
virDomainHostdevDefFree
(
hostdev
);
return
-
1
;
return
-
1
;
}
}
...
...
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.config
0 → 100644
浏览文件 @
69fc2362
lxc
.
network
.
type
=
phys
lxc
.
network
.
link
=
eth0
lxc
.
rootfs
= /
var
/
lib
/
lxc
/
migrate_test
/
rootfs
lxc
.
utsname
=
migrate_test
lxc
.
autodev
=
1
tests/lxcconf2xmldata/lxcconf2xml-physnetwork.xml
0 → 100644
浏览文件 @
69fc2362
<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>
<hostdev
mode=
'capabilities'
type=
'net'
>
<source>
<interface>
eth0
</interface>
</source>
</hostdev>
</devices>
</domain>
tests/lxcconf2xmltest.c
浏览文件 @
69fc2362
...
@@ -106,6 +106,7 @@ mymain(void)
...
@@ -106,6 +106,7 @@ mymain(void)
DO_TEST
(
"fstab"
,
true
);
DO_TEST
(
"fstab"
,
true
);
DO_TEST
(
"nonetwork"
,
false
);
DO_TEST
(
"nonetwork"
,
false
);
DO_TEST
(
"nonenetwork"
,
false
);
DO_TEST
(
"nonenetwork"
,
false
);
DO_TEST
(
"physnetwork"
,
false
);
return
ret
;
return
ret
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录