Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4ca2744e
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看板
提交
4ca2744e
编写于
11月 19, 2014
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
examples: Add support for the guest agent lifecycle event
Add code to support the event in the object-event example.
上级
1a460910
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
1 deletion
+66
-1
examples/object-events/event-test.c
examples/object-events/event-test.c
+66
-1
未找到文件。
examples/object-events/event-test.c
浏览文件 @
4ca2744e
...
...
@@ -244,6 +244,47 @@ networkEventToString(int event)
return
ret
;
}
static
const
char
*
guestAgentLifecycleEventStateToString
(
int
event
)
{
const
char
*
ret
=
""
;
switch
((
virConnectDomainEventAgentLifecycleState
)
event
)
{
case
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_DISCONNECTED
:
ret
=
"Disconnected"
;
break
;
case
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_CONNECTED
:
ret
=
"Connected"
;
break
;
}
return
ret
;
}
static
const
char
*
guestAgentLifecycleEventReasonToString
(
int
event
)
{
const
char
*
ret
=
""
;
switch
((
virConnectDomainEventAgentLifecycleReason
)
event
)
{
case
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_UNKNOWN
:
ret
=
"Unknown"
;
break
;
case
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_DOMAIN_STARTED
:
ret
=
"Domain started"
;
break
;
case
VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_CHANNEL
:
ret
=
"Channel event"
;
break
;
}
return
ret
;
}
static
int
myDomainEventCallback1
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainPtr
dom
,
int
event
,
...
...
@@ -509,6 +550,21 @@ myDomainEventTunableCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
return
0
;
}
static
int
myDomainEventAgentLifecycleCallback
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainPtr
dom
,
int
state
,
int
reason
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
printf
(
"%s EVENT: Domain %s(%d) guest agent state changed: %s reason: %s
\n
"
,
__func__
,
virDomainGetName
(
dom
),
virDomainGetID
(
dom
),
guestAgentLifecycleEventStateToString
(
state
),
guestAgentLifecycleEventReasonToString
(
reason
));
return
0
;
}
static
void
myFreeFunc
(
void
*
opaque
)
{
char
*
str
=
opaque
;
...
...
@@ -551,6 +607,7 @@ int main(int argc, char **argv)
int
callback15ret
=
-
1
;
int
callback16ret
=
-
1
;
int
callback17ret
=
-
1
;
int
callback18ret
=
-
1
;
struct
sigaction
action_stop
;
memset
(
&
action_stop
,
0
,
sizeof
(
action_stop
));
...
...
@@ -674,6 +731,11 @@ int main(int argc, char **argv)
VIR_DOMAIN_EVENT_ID_TUNABLE
,
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventTunableCallback
),
strdup
(
"tunable"
),
myFreeFunc
);
callback18ret
=
virConnectDomainEventRegisterAny
(
dconn
,
NULL
,
VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE
,
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventAgentLifecycleCallback
),
strdup
(
"guest agent lifecycle"
),
myFreeFunc
);
if
((
callback1ret
!=
-
1
)
&&
(
callback2ret
!=
-
1
)
&&
...
...
@@ -690,7 +752,8 @@ int main(int argc, char **argv)
(
callback14ret
!=
-
1
)
&&
(
callback15ret
!=
-
1
)
&&
(
callback16ret
!=
-
1
)
&&
(
callback17ret
!=
-
1
))
{
(
callback17ret
!=
-
1
)
&&
(
callback18ret
!=
-
1
))
{
if
(
virConnectSetKeepAlive
(
dconn
,
5
,
3
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Failed to start keepalive protocol: %s
\n
"
,
...
...
@@ -723,6 +786,8 @@ int main(int argc, char **argv)
virConnectDomainEventDeregisterAny
(
dconn
,
callback15ret
);
virConnectNetworkEventDeregisterAny
(
dconn
,
callback16ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback17ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback18ret
);
if
(
callback8ret
!=
-
1
)
virConnectDomainEventDeregisterAny
(
dconn
,
callback8ret
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录