Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
ee023f6c
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,发现更多精彩内容 >>
提交
ee023f6c
编写于
6月 19, 2013
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
examples: Handle VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED event
上级
4421e257
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
1 deletion
+26
-1
examples/domain-events/events-c/event-test.c
examples/domain-events/events-c/event-test.c
+22
-1
examples/domain-events/events-python/event-test.py
examples/domain-events/events-python/event-test.py
+4
-0
未找到文件。
examples/domain-events/events-c/event-test.c
浏览文件 @
ee023f6c
...
@@ -428,6 +428,17 @@ static int myDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSE
...
@@ -428,6 +428,17 @@ static int myDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSE
return
0
;
return
0
;
}
}
static
int
myDomainEventDeviceRemovedCallback
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virDomainPtr
dom
,
const
char
*
devAlias
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
printf
(
"%s EVENT: Domain %s(%d) device removed: %s
\n
"
,
__func__
,
virDomainGetName
(
dom
),
virDomainGetID
(
dom
),
devAlias
);
return
0
;
}
static
void
myFreeFunc
(
void
*
opaque
)
static
void
myFreeFunc
(
void
*
opaque
)
{
{
char
*
str
=
opaque
;
char
*
str
=
opaque
;
...
@@ -467,6 +478,7 @@ int main(int argc, char **argv)
...
@@ -467,6 +478,7 @@ int main(int argc, char **argv)
int
callback12ret
=
-
1
;
int
callback12ret
=
-
1
;
int
callback13ret
=
-
1
;
int
callback13ret
=
-
1
;
int
callback14ret
=
-
1
;
int
callback14ret
=
-
1
;
int
callback15ret
=
-
1
;
struct
sigaction
action_stop
;
struct
sigaction
action_stop
;
memset
(
&
action_stop
,
0
,
sizeof
(
action_stop
));
memset
(
&
action_stop
,
0
,
sizeof
(
action_stop
));
...
@@ -575,6 +587,12 @@ int main(int argc, char **argv)
...
@@ -575,6 +587,12 @@ int main(int argc, char **argv)
VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
,
VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
,
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventPMSuspendDiskCallback
),
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventPMSuspendDiskCallback
),
strdup
(
"pmsuspend-disk"
),
myFreeFunc
);
strdup
(
"pmsuspend-disk"
),
myFreeFunc
);
callback15ret
=
virConnectDomainEventRegisterAny
(
dconn
,
NULL
,
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
,
VIR_DOMAIN_EVENT_CALLBACK
(
myDomainEventDeviceRemovedCallback
),
strdup
(
"device removed"
),
myFreeFunc
);
if
((
callback1ret
!=
-
1
)
&&
if
((
callback1ret
!=
-
1
)
&&
(
callback2ret
!=
-
1
)
&&
(
callback2ret
!=
-
1
)
&&
(
callback3ret
!=
-
1
)
&&
(
callback3ret
!=
-
1
)
&&
...
@@ -587,7 +605,8 @@ int main(int argc, char **argv)
...
@@ -587,7 +605,8 @@ int main(int argc, char **argv)
(
callback11ret
!=
-
1
)
&&
(
callback11ret
!=
-
1
)
&&
(
callback12ret
!=
-
1
)
&&
(
callback12ret
!=
-
1
)
&&
(
callback13ret
!=
-
1
)
&&
(
callback13ret
!=
-
1
)
&&
(
callback14ret
!=
-
1
))
{
(
callback14ret
!=
-
1
)
&&
(
callback15ret
!=
-
1
))
{
if
(
virConnectSetKeepAlive
(
dconn
,
5
,
3
)
<
0
)
{
if
(
virConnectSetKeepAlive
(
dconn
,
5
,
3
)
<
0
)
{
virErrorPtr
err
=
virGetLastError
();
virErrorPtr
err
=
virGetLastError
();
fprintf
(
stderr
,
"Failed to start keepalive protocol: %s
\n
"
,
fprintf
(
stderr
,
"Failed to start keepalive protocol: %s
\n
"
,
...
@@ -616,6 +635,8 @@ int main(int argc, char **argv)
...
@@ -616,6 +635,8 @@ int main(int argc, char **argv)
virConnectDomainEventDeregisterAny
(
dconn
,
callback11ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback11ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback12ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback12ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback13ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback13ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback14ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback15ret
);
if
(
callback8ret
!=
-
1
)
if
(
callback8ret
!=
-
1
)
virConnectDomainEventDeregisterAny
(
dconn
,
callback8ret
);
virConnectDomainEventDeregisterAny
(
dconn
,
callback8ret
);
}
}
...
...
examples/domain-events/events-python/event-test.py
浏览文件 @
ee023f6c
...
@@ -495,6 +495,9 @@ def myDomainEventBalloonChangeCallback(conn, dom, actual, opaque):
...
@@ -495,6 +495,9 @@ def myDomainEventBalloonChangeCallback(conn, dom, actual, opaque):
def
myDomainEventPMSuspendDiskCallback
(
conn
,
dom
,
reason
,
opaque
):
def
myDomainEventPMSuspendDiskCallback
(
conn
,
dom
,
reason
,
opaque
):
print
"myDomainEventPMSuspendDiskCallback: Domain %s(%s) system pmsuspend_disk"
%
(
print
"myDomainEventPMSuspendDiskCallback: Domain %s(%s) system pmsuspend_disk"
%
(
dom
.
name
(),
dom
.
ID
())
dom
.
name
(),
dom
.
ID
())
def
myDomainEventDeviceRemovedCallback
(
conn
,
dom
,
dev
,
opaque
):
print
"myDomainEventDeviceRemovedCallback: Domain %s(%s) device removed: %s"
%
(
dom
.
name
(),
dom
.
ID
(),
dev
)
run
=
True
run
=
True
...
@@ -570,6 +573,7 @@ def main():
...
@@ -570,6 +573,7 @@ def main():
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_PMSUSPEND
,
myDomainEventPMSuspendCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_PMSUSPEND
,
myDomainEventPMSuspendCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
,
myDomainEventBalloonChangeCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE
,
myDomainEventBalloonChangeCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
,
myDomainEventPMSuspendDiskCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK
,
myDomainEventPMSuspendDiskCallback
,
None
)
vc
.
domainEventRegisterAny
(
None
,
libvirt
.
VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
,
myDomainEventDeviceRemovedCallback
,
None
)
vc
.
setKeepAlive
(
5
,
3
)
vc
.
setKeepAlive
(
5
,
3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录