Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9e734ab7
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看板
提交
9e734ab7
编写于
8月 26, 2014
作者:
P
Pavel Hrdina
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add an example how to use tunable event
Signed-off-by:
N
Pavel Hrdina
<
phrdina@redhat.com
>
上级
e4267181
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
51 addition
and
1 deletion
+51
-1
examples/object-events/event-test.c
examples/object-events/event-test.c
+51
-1
未找到文件。
examples/object-events/event-test.c
浏览文件 @
9e734ab7
...
...
@@ -464,6 +464,48 @@ static int myNetworkEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
return
0
;
}
static
int
myDomainEventTunableCallback
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainPtr
dom
,
virTypedParameterPtr
params
,
int
nparams
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
size_t
i
;
printf
(
"%s EVENT: Domain %s(%d) tunable updated:
\n
"
,
__func__
,
virDomainGetName
(
dom
),
virDomainGetID
(
dom
));
for
(
i
=
0
;
i
<
nparams
;
i
++
)
{
switch
(
params
[
i
].
type
)
{
case
VIR_TYPED_PARAM_INT
:
printf
(
"
\t
%s: %d
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
i
);
break
;
case
VIR_TYPED_PARAM_UINT
:
printf
(
"
\t
%s: %u
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
ui
);
break
;
case
VIR_TYPED_PARAM_LLONG
:
printf
(
"
\t
%s: %lld
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
l
);
break
;
case
VIR_TYPED_PARAM_ULLONG
:
printf
(
"
\t
%s: %llu
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
ul
);
break
;
case
VIR_TYPED_PARAM_DOUBLE
:
printf
(
"
\t
%s: %g
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
d
);
break
;
case
VIR_TYPED_PARAM_BOOLEAN
:
printf
(
"
\t
%s: %d
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
b
);
break
;
case
VIR_TYPED_PARAM_STRING
:
printf
(
"
\t
%s: %s
\n
"
,
params
[
i
].
field
,
params
[
i
].
value
.
s
);
break
;
default:
printf
(
"
\t
%s: unknown type
\n
"
,
params
[
i
].
field
);
}
}
return
0
;
}
static
void
myFreeFunc
(
void
*
opaque
)
{
...
...
@@ -506,6 +548,7 @@ int main(int argc, char **argv)
int
callback14ret
=
-
1
;
int
callback15ret
=
-
1
;
int
callback16ret
=
-
1
;
int
callback17ret
=
-
1
;
struct
sigaction
action_stop
;
memset
(
&
action_stop
,
0
,
sizeof
(
action_stop
));
...
...
@@ -624,6 +667,11 @@ int main(int argc, char **argv)
VIR_NETWORK_EVENT_ID_LIFECYCLE
,
VIR_NETWORK_EVENT_CALLBACK
(
myNetworkEventCallback
),
strdup
(
"net callback"
),
myFreeFunc
);
callback17ret
=
virConnectDomainEventRegisterAny
(
dconn
,
NULL
,
VIR_DOMAIN_EVENT_ID_TUNABLE
,
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventTunableCallback
),
strdup
(
"tunable"
),
myFreeFunc
);
if
((
callback1ret
!=
-
1
)
&&
(
callback2ret
!=
-
1
)
&&
...
...
@@ -639,7 +687,8 @@ int main(int argc, char **argv)
(
callback13ret
!=
-
1
)
&&
(
callback14ret
!=
-
1
)
&&
(
callback15ret
!=
-
1
)
&&
(
callback16ret
!=
-
1
))
{
(
callback16ret
!=
-
1
)
&&
(
callback17ret
!=
-
1
))
{
if
(
virConnectSetKeepAlive
(
dconn
,
5
,
3
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Failed to start keepalive protocol: %s
\n
"
,
...
...
@@ -671,6 +720,7 @@ int main(int argc, char **argv)
virConnectDomainEventDeregisterAny
(
dconn
,
callback14ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback15ret
);
virConnectNetworkEventDeregisterAny
(
dconn
,
callback16ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback17ret
);
if
(
callback8ret
!=
-
1
)
virConnectDomainEventDeregisterAny
(
dconn
,
callback8ret
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录