Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
527d867a
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看板
提交
527d867a
编写于
3月 19, 2012
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Make autodestroy utilize connection close callbacks
上级
79127360
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
93 deletion
+24
-93
src/qemu/qemu_conf.h
src/qemu/qemu_conf.h
+0
-5
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+0
-5
src/qemu/qemu_process.c
src/qemu/qemu_process.c
+24
-83
未找到文件。
src/qemu/qemu_conf.h
浏览文件 @
527d867a
...
@@ -141,11 +141,6 @@ struct qemud_driver {
...
@@ -141,11 +141,6 @@ struct qemud_driver {
virLockManagerPluginPtr
lockManager
;
virLockManagerPluginPtr
lockManager
;
/* Mapping of 'char *uuidstr' -> virConnectPtr
* of guests which will be automatically killed
* when the virConnectPtr is closed*/
virHashTablePtr
autodestroy
;
/* Mapping of 'char *uuidstr' -> qemuDriverCloseDefPtr of domains
/* Mapping of 'char *uuidstr' -> qemuDriverCloseDefPtr of domains
* which want a specific cleanup to be done when a connection is
* which want a specific cleanup to be done when a connection is
* closed. Such cleanup may be to automatically destroy the
* closed. Such cleanup may be to automatically destroy the
...
...
src/qemu/qemu_driver.c
浏览文件 @
527d867a
...
@@ -659,9 +659,6 @@ qemudStartup(int privileged) {
...
@@ -659,9 +659,6 @@ qemudStartup(int privileged) {
qemu_driver
->
hugepage_path
=
mempath
;
qemu_driver
->
hugepage_path
=
mempath
;
}
}
if
(
qemuProcessAutoDestroyInit
(
qemu_driver
)
<
0
)
goto
error
;
if
(
qemuDriverCloseCallbackInit
(
qemu_driver
)
<
0
)
if
(
qemuDriverCloseCallbackInit
(
qemu_driver
)
<
0
)
goto
error
;
goto
error
;
...
@@ -803,7 +800,6 @@ qemudShutdown(void) {
...
@@ -803,7 +800,6 @@ qemudShutdown(void) {
virSysinfoDefFree
(
qemu_driver
->
hostsysinfo
);
virSysinfoDefFree
(
qemu_driver
->
hostsysinfo
);
qemuProcessAutoDestroyShutdown
(
qemu_driver
);
qemuDriverCloseCallbackShutdown
(
qemu_driver
);
qemuDriverCloseCallbackShutdown
(
qemu_driver
);
VIR_FREE
(
qemu_driver
->
configDir
);
VIR_FREE
(
qemu_driver
->
configDir
);
...
@@ -925,7 +921,6 @@ static int qemudClose(virConnectPtr conn) {
...
@@ -925,7 +921,6 @@ static int qemudClose(virConnectPtr conn) {
qemuDriverLock
(
driver
);
qemuDriverLock
(
driver
);
virDomainEventStateDeregisterConn
(
conn
,
virDomainEventStateDeregisterConn
(
conn
,
driver
->
domainEventState
);
driver
->
domainEventState
);
qemuProcessAutoDestroyRun
(
driver
,
conn
);
qemuDriverCloseCallbackRunAll
(
driver
,
conn
);
qemuDriverCloseCallbackRunAll
(
driver
,
conn
);
qemuDriverUnlock
(
driver
);
qemuDriverUnlock
(
driver
);
...
...
src/qemu/qemu_process.c
浏览文件 @
527d867a
...
@@ -4120,124 +4120,65 @@ cleanup:
...
@@ -4120,124 +4120,65 @@ cleanup:
}
}
int
qemuProcessAutoDestroyInit
(
struct
qemud_driver
*
driver
)
static
virDomainObjPtr
qemuProcessAutoDestroy
(
struct
qemud_driver
*
driver
,
virDomainObjPtr
dom
,
virConnectPtr
conn
)
{
{
if
(
!
(
driver
->
autodestroy
=
virHashCreate
(
5
,
NULL
)))
qemuDomainObjPrivatePtr
priv
=
dom
->
privateData
;
return
-
1
;
return
0
;
}
struct
qemuProcessAutoDestroyData
{
struct
qemud_driver
*
driver
;
virConnectPtr
conn
;
};
static
void
qemuProcessAutoDestroyDom
(
void
*
payload
,
const
void
*
name
,
void
*
opaque
)
{
struct
qemuProcessAutoDestroyData
*
data
=
opaque
;
virConnectPtr
conn
=
payload
;
const
char
*
uuidstr
=
name
;
unsigned
char
uuid
[
VIR_UUID_BUFLEN
];
virDomainObjPtr
dom
;
qemuDomainObjPrivatePtr
priv
;
virDomainEventPtr
event
=
NULL
;
virDomainEventPtr
event
=
NULL
;
VIR_DEBUG
(
"
conn=%p uuidstr=%s thisconn=%p"
,
conn
,
uuidstr
,
data
->
conn
);
VIR_DEBUG
(
"
vm=%s, conn=%p"
,
dom
->
def
->
name
,
conn
);
if
(
data
->
conn
!=
conn
)
return
;
if
(
virUUIDParse
(
uuidstr
,
uuid
)
<
0
)
{
VIR_WARN
(
"Failed to parse %s"
,
uuidstr
);
return
;
}
if
(
!
(
dom
=
virDomainFindByUUID
(
&
data
->
driver
->
domains
,
uuid
)))
{
VIR_DEBUG
(
"No domain object to kill"
);
return
;
}
priv
=
dom
->
privateData
;
if
(
priv
->
job
.
asyncJob
)
{
if
(
priv
->
job
.
asyncJob
)
{
VIR_DEBUG
(
"vm=%s has long-term job active, cancelling"
,
VIR_DEBUG
(
"vm=%s has long-term job active, cancelling"
,
dom
->
def
->
name
);
dom
->
def
->
name
);
qemuDomainObjDiscardAsyncJob
(
d
ata
->
d
river
,
dom
);
qemuDomainObjDiscardAsyncJob
(
driver
,
dom
);
}
}
if
(
qemuDomainObjBeginJobWithDriver
(
d
ata
->
d
river
,
dom
,
if
(
qemuDomainObjBeginJobWithDriver
(
driver
,
dom
,
QEMU_JOB_DESTROY
)
<
0
)
QEMU_JOB_DESTROY
)
<
0
)
goto
cleanup
;
goto
cleanup
;
VIR_DEBUG
(
"Killing domain"
);
VIR_DEBUG
(
"Killing domain"
);
qemuProcessStop
(
d
ata
->
d
river
,
dom
,
1
,
VIR_DOMAIN_SHUTOFF_DESTROYED
);
qemuProcessStop
(
driver
,
dom
,
1
,
VIR_DOMAIN_SHUTOFF_DESTROYED
);
virDomainAuditStop
(
dom
,
"destroyed"
);
virDomainAuditStop
(
dom
,
"destroyed"
);
event
=
virDomainEventNewFromObj
(
dom
,
event
=
virDomainEventNewFromObj
(
dom
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED
);
VIR_DOMAIN_EVENT_STOPPED_DESTROYED
);
if
(
qemuDomainObjEndJob
(
data
->
driver
,
dom
)
==
0
)
if
(
qemuDomainObjEndJob
(
driver
,
dom
)
==
0
)
dom
=
NULL
;
dom
=
NULL
;
if
(
dom
&&
!
dom
->
persistent
)
if
(
dom
&&
!
dom
->
persistent
)
qemuDomainRemoveInactive
(
data
->
driver
,
dom
);
qemuDomainRemoveInactive
(
driver
,
dom
);
cleanup:
if
(
dom
)
virDomainObjUnlock
(
dom
);
if
(
event
)
if
(
event
)
qemuDomainEventQueue
(
data
->
driver
,
event
);
qemuDomainEventQueue
(
driver
,
event
);
virHashRemoveEntry
(
data
->
driver
->
autodestroy
,
uuidstr
);
}
/*
* Precondition: driver is locked
*/
void
qemuProcessAutoDestroyRun
(
struct
qemud_driver
*
driver
,
virConnectPtr
conn
)
{
struct
qemuProcessAutoDestroyData
data
=
{
driver
,
conn
};
VIR_DEBUG
(
"conn=%p"
,
conn
);
virHashForEach
(
driver
->
autodestroy
,
qemuProcessAutoDestroyDom
,
&
data
);
}
void
qemuProcessAutoDestroyShutdown
(
struct
qemud_driver
*
driver
)
cleanup:
{
return
dom
;
virHashFree
(
driver
->
autodestroy
);
}
}
int
qemuProcessAutoDestroyAdd
(
struct
qemud_driver
*
driver
,
int
qemuProcessAutoDestroyAdd
(
struct
qemud_driver
*
driver
,
virDomainObjPtr
vm
,
virDomainObjPtr
vm
,
virConnectPtr
conn
)
virConnectPtr
conn
)
{
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
VIR_DEBUG
(
"vm=%s, conn=%p"
,
vm
->
def
->
name
,
conn
);
virUUIDFormat
(
vm
->
def
->
uuid
,
uuidstr
);
return
qemuDriverCloseCallbackSet
(
driver
,
vm
,
conn
,
VIR_DEBUG
(
"vm=%s uuid=%s conn=%p"
,
vm
->
def
->
name
,
uuidstr
,
conn
);
qemuProcessAutoDestroy
);
if
(
virHashAddEntry
(
driver
->
autodestroy
,
uuidstr
,
conn
)
<
0
)
return
-
1
;
return
0
;
}
}
int
qemuProcessAutoDestroyRemove
(
struct
qemud_driver
*
driver
,
int
qemuProcessAutoDestroyRemove
(
struct
qemud_driver
*
driver
,
virDomainObjPtr
vm
)
virDomainObjPtr
vm
)
{
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
VIR_DEBUG
(
"vm=%s"
,
vm
->
def
->
name
);
virUUIDFormat
(
vm
->
def
->
uuid
,
uuidstr
);
return
qemuDriverCloseCallbackUnset
(
driver
,
vm
,
qemuProcessAutoDestroy
);
VIR_DEBUG
(
"vm=%s uuid=%s"
,
vm
->
def
->
name
,
uuidstr
);
if
(
virHashRemoveEntry
(
driver
->
autodestroy
,
uuidstr
)
<
0
)
return
-
1
;
return
0
;
}
}
bool
qemuProcessAutoDestroyActive
(
struct
qemud_driver
*
driver
,
bool
qemuProcessAutoDestroyActive
(
struct
qemud_driver
*
driver
,
virDomainObjPtr
vm
)
virDomainObjPtr
vm
)
{
{
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
qemuDriverCloseCallback
cb
;
virUUIDFormat
(
vm
->
def
->
uuid
,
uuidstr
);
VIR_DEBUG
(
"vm=%s"
,
vm
->
def
->
name
);
VIR_DEBUG
(
"vm=%s uuid=%s"
,
vm
->
def
->
name
,
uuidstr
);
cb
=
qemuDriverCloseCallbackGet
(
driver
,
vm
,
NULL
);
if
(
virHashLookup
(
driver
->
autodestroy
,
uuidstr
)
!=
NULL
)
return
cb
==
qemuProcessAutoDestroy
;
return
true
;
return
false
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录