Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
bcf0c144
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看板
提交
bcf0c144
编写于
6月 07, 2013
作者:
C
Chen Fan
提交者:
Eric Blake
7月 02, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: refactor processWatchdogEvent
Split the code to make the driver workpool more generalized
上级
14e7e0ae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
32 deletion
+56
-32
src/qemu/qemu_domain.h
src/qemu/qemu_domain.h
+8
-2
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+41
-24
src/qemu/qemu_process.c
src/qemu/qemu_process.c
+7
-6
未找到文件。
src/qemu/qemu_domain.h
浏览文件 @
bcf0c144
...
...
@@ -170,9 +170,15 @@ struct _qemuDomainObjPrivate {
virCgroupPtr
cgroup
;
};
struct
qemuDomainWatchdogEvent
{
typedef
enum
{
QEMU_PROCESS_EVENT_WATCHDOG
=
0
,
QEMU_PROCESS_EVENT_LAST
}
qemuProcessEventType
;
struct
qemuProcessEvent
{
virDomainObjPtr
vm
;
qemuProcessEventType
eventType
;
int
action
;
};
...
...
src/qemu/qemu_driver.c
浏览文件 @
bcf0c144
...
...
@@ -135,7 +135,11 @@
#define QEMU_NB_BANDWIDTH_PARAM 6
static
void
processWatchdogEvent
(
void
*
data
,
void
*
opaque
);
static
void
processWatchdogEvent
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
int
action
);
static
void
qemuProcessEventHandler
(
void
*
data
,
void
*
opaque
);
static
int
qemuStateCleanup
(
void
);
...
...
@@ -815,7 +819,7 @@ qemuStateInitialize(bool privileged,
qemuDomainManagedSaveLoad
,
qemu_driver
);
qemu_driver
->
workerPool
=
virThreadPoolNew
(
0
,
1
,
0
,
processWatchdogEvent
,
qemu_driver
);
qemu_driver
->
workerPool
=
virThreadPoolNew
(
0
,
1
,
0
,
qemuProcessEventHandler
,
qemu_driver
);
if
(
!
qemu_driver
->
workerPool
)
goto
error
;
...
...
@@ -3561,17 +3565,12 @@ cleanup:
return
ret
;
}
static
void
processWatchdogEvent
(
v
oid
*
data
,
void
*
opaque
)
static
void
processWatchdogEvent
(
v
irQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
int
action
)
{
int
ret
;
struct
qemuDomainWatchdogEvent
*
wdEvent
=
data
;
virQEMUDriverPtr
driver
=
opaque
;
virQEMUDriverConfigPtr
cfg
;
virObjectLock
(
wdEvent
->
vm
);
cfg
=
virQEMUDriverGetConfig
(
driver
);
virQEMUDriverConfigPtr
cfg
=
virQEMUDriverGetConfig
(
driver
);
switch
(
wdEvent
->
action
)
{
switch
(
action
)
{
case
VIR_DOMAIN_WATCHDOG_ACTION_DUMP
:
{
char
*
dumpfile
;
...
...
@@ -3579,19 +3578,19 @@ static void processWatchdogEvent(void *data, void *opaque)
if
(
virAsprintf
(
&
dumpfile
,
"%s/%s-%u"
,
cfg
->
autoDumpPath
,
wdEvent
->
vm
->
def
->
name
,
vm
->
def
->
name
,
(
unsigned
int
)
time
(
NULL
))
<
0
)
{
virReportOOMError
();
goto
unlock
;
goto
cleanup
;
}
if
(
qemuDomainObjBeginAsyncJob
(
driver
,
wdEvent
->
vm
,
QEMU_ASYNC_JOB_DUMP
)
<
0
)
{
if
(
qemuDomainObjBeginAsyncJob
(
driver
,
vm
,
QEMU_ASYNC_JOB_DUMP
)
<
0
)
{
VIR_FREE
(
dumpfile
);
goto
unlock
;
goto
cleanup
;
}
if
(
!
virDomainObjIsActive
(
wdEvent
->
vm
))
{
if
(
!
virDomainObjIsActive
(
vm
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"domain is not running"
));
VIR_FREE
(
dumpfile
);
...
...
@@ -3599,13 +3598,13 @@ static void processWatchdogEvent(void *data, void *opaque)
}
flags
|=
cfg
->
autoDumpBypassCache
?
VIR_DUMP_BYPASS_CACHE
:
0
;
ret
=
doCoreDump
(
driver
,
wdEvent
->
vm
,
dumpfile
,
ret
=
doCoreDump
(
driver
,
vm
,
dumpfile
,
getCompressionType
(
driver
),
flags
);
if
(
ret
<
0
)
virReportError
(
VIR_ERR_OPERATION_FAILED
,
"%s"
,
_
(
"Dump failed"
));
ret
=
qemuProcessStartCPUs
(
driver
,
wdEvent
->
vm
,
NULL
,
ret
=
qemuProcessStartCPUs
(
driver
,
vm
,
NULL
,
VIR_DOMAIN_RUNNING_UNPAUSED
,
QEMU_ASYNC_JOB_DUMP
);
...
...
@@ -3617,22 +3616,40 @@ static void processWatchdogEvent(void *data, void *opaque)
}
break
;
default:
goto
unlock
;
goto
cleanup
;
}
endjob:
/* Safe to ignore value since ref count was incremented in
* qemuProcessHandleWatchdog().
*/
ignore_value
(
qemuDomainObjEndAsyncJob
(
driver
,
wdEvent
->
vm
));
ignore_value
(
qemuDomainObjEndAsyncJob
(
driver
,
vm
));
unlock:
virObjectUnlock
(
wdEvent
->
vm
);
virObjectUnref
(
wdEvent
->
vm
);
VIR_FREE
(
wdEvent
);
cleanup:
virObjectUnref
(
cfg
);
}
static
void
qemuProcessEventHandler
(
void
*
data
,
void
*
opaque
)
{
struct
qemuProcessEvent
*
processEvent
=
data
;
virDomainObjPtr
vm
=
processEvent
->
vm
;
virQEMUDriverPtr
driver
=
opaque
;
virObjectLock
(
vm
);
switch
(
processEvent
->
eventType
)
{
case
QEMU_PROCESS_EVENT_WATCHDOG
:
processWatchdogEvent
(
driver
,
vm
,
processEvent
->
action
);
break
;
default:
break
;
}
if
(
virObjectUnref
(
vm
))
virObjectUnlock
(
vm
);
VIR_FREE
(
processEvent
);
}
static
int
qemuDomainHotplugVcpus
(
virQEMUDriverPtr
driver
,
virDomainObjPtr
vm
,
unsigned
int
nvcpus
)
...
...
src/qemu/qemu_process.c
浏览文件 @
bcf0c144
...
...
@@ -861,18 +861,19 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
if
(
vm
->
def
->
watchdog
->
action
==
VIR_DOMAIN_WATCHDOG_ACTION_DUMP
)
{
struct
qemuDomainWatchdogEvent
*
wdEvent
;
if
(
VIR_ALLOC
(
wdEvent
)
==
0
)
{
wdEvent
->
action
=
VIR_DOMAIN_WATCHDOG_ACTION_DUMP
;
wdEvent
->
vm
=
vm
;
struct
qemuProcessEvent
*
processEvent
;
if
(
VIR_ALLOC
(
processEvent
)
==
0
)
{
processEvent
->
eventType
=
QEMU_PROCESS_EVENT_WATCHDOG
;
processEvent
->
action
=
VIR_DOMAIN_WATCHDOG_ACTION_DUMP
;
processEvent
->
vm
=
vm
;
/* Hold an extra reference because we can't allow 'vm' to be
* deleted before handling watchdog event is finished.
*/
virObjectRef
(
vm
);
if
(
virThreadPoolSendJob
(
driver
->
workerPool
,
0
,
wd
Event
)
<
0
)
{
if
(
virThreadPoolSendJob
(
driver
->
workerPool
,
0
,
process
Event
)
<
0
)
{
if
(
!
virObjectUnref
(
vm
))
vm
=
NULL
;
VIR_FREE
(
wd
Event
);
VIR_FREE
(
process
Event
);
}
}
else
{
virReportOOMError
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录