Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
8ab78578
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8ab78578
编写于
2月 27, 2012
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hooks: Add support for capturing hook output
Hooks may now be used as filters.
上级
c0f72224
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
14 deletion
+34
-14
daemon/libvirtd.c
daemon/libvirtd.c
+3
-3
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+4
-2
src/qemu/qemu_process.c
src/qemu/qemu_process.c
+8
-4
src/util/hooks.c
src/util/hooks.c
+18
-4
src/util/hooks.h
src/util/hooks.h
+1
-1
未找到文件。
daemon/libvirtd.c
浏览文件 @
8ab78578
...
...
@@ -1148,7 +1148,7 @@ static void daemonReloadHandler(virNetServerPtr srv ATTRIBUTE_UNUSED,
{
VIR_INFO
(
"Reloading configuration on SIGHUP"
);
virHookCall
(
VIR_HOOK_DRIVER_DAEMON
,
"-"
,
VIR_HOOK_DAEMON_OP_RELOAD
,
SIGHUP
,
"SIGHUP"
,
NULL
);
VIR_HOOK_DAEMON_OP_RELOAD
,
SIGHUP
,
"SIGHUP"
,
NULL
,
NULL
);
if
(
virStateReload
()
<
0
)
VIR_WARN
(
"Error while reloading drivers"
);
}
...
...
@@ -1571,7 +1571,7 @@ int main(int argc, char **argv) {
* an error ?
*/
virHookCall
(
VIR_HOOK_DRIVER_DAEMON
,
"-"
,
VIR_HOOK_DAEMON_OP_START
,
0
,
"start"
,
NULL
);
0
,
"start"
,
NULL
,
NULL
);
if
(
daemonSetupNetworking
(
srv
,
config
,
sock_file
,
sock_file_ro
,
...
...
@@ -1604,7 +1604,7 @@ int main(int argc, char **argv) {
ret
=
0
;
virHookCall
(
VIR_HOOK_DRIVER_DAEMON
,
"-"
,
VIR_HOOK_DAEMON_OP_SHUTDOWN
,
0
,
"shutdown"
,
NULL
);
0
,
"shutdown"
,
NULL
,
NULL
);
cleanup:
virNetServerProgramFree
(
remoteProgram
);
...
...
src/lxc/lxc_driver.c
浏览文件 @
8ab78578
...
...
@@ -1115,7 +1115,8 @@ static void lxcVmCleanup(lxc_driver_t *driver,
/* we can't stop the operation even if the script raised an error */
virHookCall
(
VIR_HOOK_DRIVER_LXC
,
vm
->
def
->
name
,
VIR_HOOK_LXC_OP_STOPPED
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
);
VIR_HOOK_LXC_OP_STOPPED
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
}
...
...
@@ -1632,7 +1633,8 @@ lxcBuildControllerCmd(lxc_driver_t *driver,
int
hookret
;
hookret
=
virHookCall
(
VIR_HOOK_DRIVER_LXC
,
vm
->
def
->
name
,
VIR_HOOK_LXC_OP_START
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
);
VIR_HOOK_LXC_OP_START
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
/*
...
...
src/qemu/qemu_process.c
浏览文件 @
8ab78578
...
...
@@ -3120,7 +3120,8 @@ int qemuProcessStart(virConnectPtr conn,
int
hookret
;
hookret
=
virHookCall
(
VIR_HOOK_DRIVER_QEMU
,
vm
->
def
->
name
,
VIR_HOOK_QEMU_OP_PREPARE
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
);
VIR_HOOK_QEMU_OP_PREPARE
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
/*
...
...
@@ -3305,7 +3306,8 @@ int qemuProcessStart(virConnectPtr conn,
int
hookret
;
hookret
=
virHookCall
(
VIR_HOOK_DRIVER_QEMU
,
vm
->
def
->
name
,
VIR_HOOK_QEMU_OP_START
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
);
VIR_HOOK_QEMU_OP_START
,
VIR_HOOK_SUBOP_BEGIN
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
/*
...
...
@@ -3726,7 +3728,8 @@ void qemuProcessStop(struct qemud_driver *driver,
/* we can't stop the operation even if the script raised an error */
virHookCall
(
VIR_HOOK_DRIVER_QEMU
,
vm
->
def
->
name
,
VIR_HOOK_QEMU_OP_STOPPED
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
);
VIR_HOOK_QEMU_OP_STOPPED
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
}
...
...
@@ -3819,7 +3822,8 @@ retry:
/* we can't stop the operation even if the script raised an error */
virHookCall
(
VIR_HOOK_DRIVER_QEMU
,
vm
->
def
->
name
,
VIR_HOOK_QEMU_OP_RELEASE
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
);
VIR_HOOK_QEMU_OP_RELEASE
,
VIR_HOOK_SUBOP_END
,
NULL
,
xml
,
NULL
);
VIR_FREE
(
xml
);
}
...
...
src/util/hooks.c
浏览文件 @
8ab78578
...
...
@@ -173,7 +173,7 @@ virHookPresent(int driver) {
return
(
1
);
}
/*
/*
*
* virHookCall:
* @driver: the driver number (from virHookDriver enum)
* @id: an id for the object '-' if non available for example on daemon hooks
...
...
@@ -181,17 +181,26 @@ virHookPresent(int driver) {
* @sub_op: a sub_operation, currently unused
* @extra: optional string information
* @input: extra input given to the script on stdin
* @output: optional address of variable to store malloced result buffer
*
* Implement a hook call, where the external script for the driver is
* called with the given information. This is a synchronous call, we wait for
* execution completion
* execution completion. If @output is non-NULL, *output is guaranteed to be
* allocated after successful virHookCall, and is best-effort allocated after
* failed virHookCall; the caller is responsible for freeing *output.
*
* Returns: 0 if the execution succeeded, 1 if the script was not found or
* invalid parameters, and -1 if script returned an error
*/
int
virHookCall
(
int
driver
,
const
char
*
id
,
int
op
,
int
sub_op
,
const
char
*
extra
,
const
char
*
input
)
{
virHookCall
(
int
driver
,
const
char
*
id
,
int
op
,
int
sub_op
,
const
char
*
extra
,
const
char
*
input
,
char
**
output
)
{
int
ret
;
int
exitstatus
;
char
*
path
;
...
...
@@ -200,6 +209,9 @@ virHookCall(int driver, const char *id, int op, int sub_op, const char *extra,
const
char
*
opstr
;
const
char
*
subopstr
;
if
(
output
)
*
output
=
NULL
;
if
((
driver
<
VIR_HOOK_DRIVER_DAEMON
)
||
(
driver
>=
VIR_HOOK_DRIVER_LAST
))
return
(
1
);
...
...
@@ -257,6 +269,8 @@ virHookCall(int driver, const char *id, int op, int sub_op, const char *extra,
if
(
input
)
virCommandSetInputBuffer
(
cmd
,
input
);
if
(
output
)
virCommandSetOutputBuffer
(
cmd
,
output
);
ret
=
virCommandRun
(
cmd
,
&
exitstatus
);
if
(
ret
==
0
&&
exitstatus
!=
0
)
{
...
...
src/util/hooks.h
浏览文件 @
8ab78578
...
...
@@ -72,6 +72,6 @@ int virHookInitialize(void);
int
virHookPresent
(
int
driver
);
int
virHookCall
(
int
driver
,
const
char
*
id
,
int
op
,
int
sub_op
,
const
char
*
extra
,
const
char
*
input
);
const
char
*
extra
,
const
char
*
input
,
char
**
output
);
#endif
/* __VIR_HOOKS_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录