Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f803f5ff
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,发现更多精彩内容 >>
提交
f803f5ff
编写于
7月 28, 2016
作者:
J
Jovanka Gulicoska
提交者:
Cole Robinson
8月 02, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
event-test: support node device lifecycle event APIs
上级
546fa3ef
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
68 addition
and
0 deletion
+68
-0
examples/object-events/event-test.c
examples/object-events/event-test.c
+68
-0
未找到文件。
examples/object-events/event-test.c
浏览文件 @
f803f5ff
...
...
@@ -355,6 +355,20 @@ storagePoolEventToString(int event)
return
"unknown"
;
}
static
const
char
*
nodeDeviceEventToString
(
int
event
)
{
switch
((
virNodeDeviceEventLifecycleType
)
event
)
{
case
VIR_NODE_DEVICE_EVENT_CREATED
:
return
"Created"
;
case
VIR_NODE_DEVICE_EVENT_DELETED
:
return
"Deleted"
;
case
VIR_NODE_DEVICE_EVENT_LAST
:
break
;
}
return
"unknown"
;
}
static
int
myDomainEventCallback1
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
...
...
@@ -688,6 +702,21 @@ myStoragePoolEventRefreshCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
}
static
int
myNodeDeviceEventCallback
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virNodeDevicePtr
dev
,
int
event
,
int
detail
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
printf
(
"%s EVENT: Node device %s %s %d
\n
"
,
__func__
,
virNodeDeviceGetName
(
dev
),
nodeDeviceEventToString
(
event
),
detail
);
return
0
;
}
static
void
eventTypedParamsPrint
(
virTypedParameterPtr
params
,
int
nparams
)
...
...
@@ -948,9 +977,24 @@ struct storagePoolEventData storagePoolEvents[] = {
STORAGE_POOL_EVENT
(
VIR_STORAGE_POOL_EVENT_ID_REFRESH
,
myStoragePoolEventRefreshCallback
),
};
struct
nodeDeviceEventData
{
int
event
;
int
id
;
virConnectNodeDeviceEventGenericCallback
cb
;
const
char
*
name
;
};
#define NODE_DEVICE_EVENT(event, callback) \
{event, -1, VIR_NODE_DEVICE_EVENT_CALLBACK(callback), #event}
struct
nodeDeviceEventData
nodeDeviceEvents
[]
=
{
NODE_DEVICE_EVENT
(
VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE
,
myNodeDeviceEventCallback
),
};
/* make sure that the events are kept in sync */
verify
(
ARRAY_CARDINALITY
(
domainEvents
)
==
VIR_DOMAIN_EVENT_ID_LAST
);
verify
(
ARRAY_CARDINALITY
(
storagePoolEvents
)
==
VIR_STORAGE_POOL_EVENT_ID_LAST
);
verify
(
ARRAY_CARDINALITY
(
nodeDeviceEvents
)
==
VIR_NODE_DEVICE_EVENT_ID_LAST
);
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -1042,6 +1086,22 @@ main(int argc, char **argv)
}
}
/* register common node device callbacks */
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
nodeDeviceEvents
);
i
++
)
{
struct
nodeDeviceEventData
*
event
=
nodeDeviceEvents
+
i
;
event
->
id
=
virConnectNodeDeviceEventRegisterAny
(
dconn
,
NULL
,
event
->
event
,
event
->
cb
,
strdup
(
event
->
name
),
myFreeFunc
);
if
(
event
->
id
<
0
)
{
fprintf
(
stderr
,
"Failed to register event '%s'
\n
"
,
event
->
name
);
goto
cleanup
;
}
}
if
((
callback1ret
==
-
1
)
||
(
callback16ret
==
-
1
))
goto
cleanup
;
...
...
@@ -1077,6 +1137,14 @@ main(int argc, char **argv)
virConnectStoragePoolEventDeregisterAny
(
dconn
,
storagePoolEvents
[
i
].
id
);
}
printf
(
"Deregistering node device event callbacks
\n
"
);
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
nodeDeviceEvents
);
i
++
)
{
if
(
nodeDeviceEvents
[
i
].
id
>
0
)
virConnectNodeDeviceEventDeregisterAny
(
dconn
,
nodeDeviceEvents
[
i
].
id
);
}
virConnectUnregisterCloseCallback
(
dconn
,
connectClose
);
ret
=
EXIT_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录