Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
ac68a785
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看板
提交
ac68a785
编写于
7月 10, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Separate net device removal into a standalone function
上级
92758a71
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
39 deletion
+62
-39
src/qemu/qemu_hotplug.c
src/qemu/qemu_hotplug.c
+62
-39
未找到文件。
src/qemu/qemu_hotplug.c
浏览文件 @
ac68a785
...
...
@@ -2289,6 +2289,62 @@ qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
}
static
void
qemuDomainRemoveNetDevice
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainNetDefPtr
net
)
{
virQEMUDriverConfigPtr
cfg
=
virQEMUDriverGetConfig
(
driver
);
virNetDevVPortProfilePtr
vport
;
size_t
i
;
VIR_DEBUG
(
"Removing network interface %s from domain %p %s"
,
net
->
info
.
alias
,
vm
,
vm
->
def
->
name
);
virDomainAuditNet
(
vm
,
net
,
NULL
,
"detach"
,
true
);
for
(
i
=
0
;
i
<
vm
->
def
->
nnets
;
i
++
)
{
if
(
vm
->
def
->
nets
[
i
]
==
net
)
{
virDomainNetRemove
(
vm
->
def
,
i
);
break
;
}
}
qemuDomainReleaseDeviceAddress
(
vm
,
&
net
->
info
,
NULL
);
virDomainConfNWFilterTeardown
(
net
);
if
(
virDomainNetGetActualType
(
net
)
==
VIR_DOMAIN_NET_TYPE_DIRECT
)
{
ignore_value
(
virNetDevMacVLanDeleteWithVPortProfile
(
net
->
ifname
,
&
net
->
mac
,
virDomainNetGetActualDirectDev
(
net
),
virDomainNetGetActualDirectMode
(
net
),
virDomainNetGetActualVirtPortProfile
(
net
),
cfg
->
stateDir
));
VIR_FREE
(
net
->
ifname
);
}
if
(
cfg
->
macFilter
&&
(
net
->
ifname
!=
NULL
))
{
if
((
errno
=
networkDisallowMacOnPort
(
driver
,
net
->
ifname
,
&
net
->
mac
)))
{
virReportSystemError
(
errno
,
_
(
"failed to remove ebtables rule on '%s'"
),
net
->
ifname
);
}
}
vport
=
virDomainNetGetActualVirtPortProfile
(
net
);
if
(
vport
&&
vport
->
virtPortType
==
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH
)
ignore_value
(
virNetDevOpenvswitchRemovePort
(
virDomainNetGetActualBridgeName
(
net
),
net
->
ifname
));
networkReleaseActualDevice
(
net
);
virDomainNetDefFree
(
net
);
virObjectUnref
(
cfg
);
}
int
qemuDomainDetachVirtioDiskDevice
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
virDomainDiskDefPtr
detach
)
...
...
@@ -2818,8 +2874,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
int
vlan
;
char
*
hostnet_name
=
NULL
;
char
mac
[
VIR_MAC_STRING_BUFLEN
];
virNetDevVPortProfilePtr
vport
=
NULL
;
virQEMUDriverConfigPtr
cfg
=
virQEMUDriverGetConfig
(
driver
);
detachidx
=
virDomainNetFindIdx
(
vm
->
def
,
dev
->
data
.
net
);
if
(
detachidx
==
-
2
)
{
...
...
@@ -2841,6 +2895,11 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
ret
=
qemuDomainDetachThisHostDevice
(
driver
,
vm
,
virDomainNetGetActualHostdev
(
detach
),
-
1
);
if
(
!
ret
)
{
networkReleaseActualDevice
(
detach
);
virDomainNetRemove
(
vm
->
def
,
detachidx
);
virDomainNetDefFree
(
detach
);
}
goto
cleanup
;
}
if
(
STREQLEN
(
vm
->
def
->
os
.
machine
,
"s390-ccw"
,
8
)
&&
...
...
@@ -2908,46 +2967,10 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
}
qemuDomainObjExitMonitor
(
driver
,
vm
);
virDomainAuditNet
(
vm
,
detach
,
NULL
,
"detach"
,
true
);
qemuDomainReleaseDeviceAddress
(
vm
,
&
detach
->
info
,
NULL
);
virDomainConfNWFilterTeardown
(
detach
);
if
(
virDomainNetGetActualType
(
detach
)
==
VIR_DOMAIN_NET_TYPE_DIRECT
)
{
ignore_value
(
virNetDevMacVLanDeleteWithVPortProfile
(
detach
->
ifname
,
&
detach
->
mac
,
virDomainNetGetActualDirectDev
(
detach
),
virDomainNetGetActualDirectMode
(
detach
),
virDomainNetGetActualVirtPortProfile
(
detach
),
cfg
->
stateDir
));
VIR_FREE
(
detach
->
ifname
);
}
if
(
cfg
->
macFilter
&&
(
detach
->
ifname
!=
NULL
))
{
if
((
errno
=
networkDisallowMacOnPort
(
driver
,
detach
->
ifname
,
&
detach
->
mac
)))
{
virReportSystemError
(
errno
,
_
(
"failed to remove ebtables rule on '%s'"
),
detach
->
ifname
);
}
}
vport
=
virDomainNetGetActualVirtPortProfile
(
detach
);
if
(
vport
&&
vport
->
virtPortType
==
VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH
)
ignore_value
(
virNetDevOpenvswitchRemovePort
(
virDomainNetGetActualBridgeName
(
detach
),
detach
->
ifname
));
qemuDomainRemoveNetDevice
(
driver
,
vm
,
detach
);
ret
=
0
;
cleanup:
if
(
!
ret
)
{
networkReleaseActualDevice
(
detach
);
virDomainNetRemove
(
vm
->
def
,
detachidx
);
virDomainNetDefFree
(
detach
);
}
VIR_FREE
(
hostnet_name
);
virObjectUnref
(
cfg
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录