Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
7c99cb93
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,发现更多精彩内容 >>
提交
7c99cb93
编写于
5月 28, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix python domain events example & binding
上级
fb828ed2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
18 deletion
+46
-18
ChangeLog
ChangeLog
+8
-0
examples/domain-events/events-python/event-test.py
examples/domain-events/events-python/event-test.py
+37
-18
python/libvir.c
python/libvir.c
+1
-0
未找到文件。
ChangeLog
浏览文件 @
7c99cb93
Thu May 28 12:00:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Fix python domain events example & binding.
* examples/domain-events/events-python/event-test.py: Fix
broken handling of timers
* python/libvir.c: Take reference on virDomainPtr object
before wrapping it to avoid double-free.
Tue May 26 13:09:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Tue May 26 13:09:30 BST 2009 Daniel P. Berrange <berrange@redhat.com>
Fix error location logging
Fix error location logging
...
...
examples/domain-events/events-python/event-test.py
浏览文件 @
7c99cb93
...
@@ -6,6 +6,8 @@ import select
...
@@ -6,6 +6,8 @@ import select
mypoll
=
select
.
poll
()
mypoll
=
select
.
poll
()
TIMEOUT_MS
=
1000
TIMEOUT_MS
=
1000
debug
=
False
# handle globals
# handle globals
h_fd
=
0
h_fd
=
0
h_events
=
0
h_events
=
0
...
@@ -66,8 +68,9 @@ def myPollEventToEventHandleType(events):
...
@@ -66,8 +68,9 @@ def myPollEventToEventHandleType(events):
return
ret
;
return
ret
;
def
myAddHandle
(
fd
,
events
,
cb
,
opaque
):
def
myAddHandle
(
fd
,
events
,
cb
,
opaque
):
global
h_fd
,
h_events
,
h_cb
,
h_opaque
global
h_fd
,
h_events
,
h_cb
,
h_opaque
,
debug
#print "Adding Handle %s %s %s %s" % (str(fd), str(events), str(cb), str(opaque))
if
debug
:
print
"Adding Handle %s %s %s %s"
%
(
str
(
fd
),
str
(
events
),
str
(
cb
),
str
(
opaque
))
h_fd
=
fd
h_fd
=
fd
h_events
=
events
h_events
=
events
h_cb
=
cb
h_cb
=
cb
...
@@ -76,36 +79,48 @@ def myAddHandle(fd, events, cb, opaque):
...
@@ -76,36 +79,48 @@ def myAddHandle(fd, events, cb, opaque):
return
0
return
0
def
myUpdateHandle
(
watch
,
event
):
def
myUpdateHandle
(
watch
,
event
):
global
h_fd
,
h_events
global
h_fd
,
h_events
,
debug
#print "Updating Handle %s %s" % (str(h_fd), str(event))
if
debug
:
print
"Updating Handle %s %s"
%
(
str
(
h_fd
),
str
(
event
))
h_events
=
event
h_events
=
event
mypoll
.
unregister
(
h_fd
)
mypoll
.
unregister
(
h_fd
)
mypoll
.
register
(
h_fd
,
myEventHandleTypeToPollEvent
(
event
))
mypoll
.
register
(
h_fd
,
myEventHandleTypeToPollEvent
(
event
))
def
myRemoveHandle
(
watch
):
def
myRemoveHandle
(
watch
):
global
h_fd
global
h_fd
,
debug
#print "Removing Handle %s" % str(h_fd)
if
debug
:
print
"Removing Handle %s"
%
str
(
h_fd
)
mypoll
.
unregister
(
h_fd
)
mypoll
.
unregister
(
h_fd
)
h_fd
=
0
h_fd
=
0
return
h_opaque
return
h_opaque
def
myAddTimeout
(
timeout
,
cb
,
opaque
):
def
myAddTimeout
(
timeout
,
cb
,
opaque
):
global
t_active
,
t_timeout
,
t_cb
,
t_opaque
global
t_active
,
t_timeout
,
t_cb
,
t_opaque
,
debug
#print "Adding Timeout %s %s %s" % (str(timeout), str(cb), str(opaque))
if
debug
:
t_active
=
1
;
print
"Adding Timeout %s %s %s"
%
(
str
(
timeout
),
str
(
cb
),
str
(
opaque
))
if
timeout
==
-
1
:
t_active
=
0
else
:
t_active
=
1
t_timeout
=
timeout
;
t_timeout
=
timeout
;
t_cb
=
cb
;
t_cb
=
cb
;
t_opaque
=
opaque
;
t_opaque
=
opaque
;
return
0
return
0
def
myUpdateTimeout
(
timer
,
timeout
):
def
myUpdateTimeout
(
timer
,
timeout
):
global
t_timeout
global
t_timeout
,
t_active
,
debug
#print "Updating Timeout %s %s" % (str(timer), str(timeout))
if
debug
:
print
"Updating Timeout %s %s"
%
(
str
(
timer
),
str
(
timeout
))
if
timeout
==
-
1
:
t_active
=
0
else
:
t_active
=
1
t_timeout
=
timeout
;
t_timeout
=
timeout
;
def
myRemoveTimeout
(
timer
):
def
myRemoveTimeout
(
timer
):
global
t_active
global
t_active
,
debug
#print "Removing Timeout %s" % str(timer)
if
debug
:
print
"Removing Timeout %s"
%
str
(
timer
)
t_active
=
0
;
t_active
=
0
;
return
t_opaque
return
t_opaque
...
@@ -159,6 +174,8 @@ def main():
...
@@ -159,6 +174,8 @@ def main():
while
1
:
while
1
:
try
:
try
:
if
debug
:
print
"Poll sleep %d"
%
t_active
sts
=
mypoll
.
poll
(
TIMEOUT_MS
)
sts
=
mypoll
.
poll
(
TIMEOUT_MS
)
except
select
.
error
,
err
:
except
select
.
error
,
err
:
if
err
[
0
]
==
errno
.
EINTR
:
if
err
[
0
]
==
errno
.
EINTR
:
...
@@ -168,17 +185,19 @@ def main():
...
@@ -168,17 +185,19 @@ def main():
print
"Keyboard Interrupt caught - exiting cleanly"
print
"Keyboard Interrupt caught - exiting cleanly"
break
break
if
t_cb
and
t_active
==
1
:
if
debug
:
print
"Invoking Timeout CB"
t_cb
(
t_timeout
,
t_opaque
[
0
],
t_opaque
[
1
])
if
not
sts
:
if
not
sts
:
#print "Timed out"
if
debug
:
print
"Timed out"
continue
continue
rfd
=
sts
[
0
][
0
]
rfd
=
sts
[
0
][
0
]
revents
=
sts
[
0
][
1
]
revents
=
sts
[
0
][
1
]
if
t_active
:
#print "Invoking Timeout CB"
t_cb
(
t_timeout
,
t_opaque
[
0
],
t_opaque
[
1
])
if
revents
&
select
.
POLLHUP
:
if
revents
&
select
.
POLLHUP
:
print
"Reset by peer"
;
print
"Reset by peer"
;
return
-
1
;
return
-
1
;
...
...
python/libvir.c
浏览文件 @
7c99cb93
...
@@ -1653,6 +1653,7 @@ libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
...
@@ -1653,6 +1653,7 @@ libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
LIBVIRT_ENSURE_THREAD_STATE
;
LIBVIRT_ENSURE_THREAD_STATE
;
/* Create a python instance of this virDomainPtr */
/* Create a python instance of this virDomainPtr */
virDomainRef
(
dom
);
pyobj_dom
=
libvirt_virDomainPtrWrap
(
dom
);
pyobj_dom
=
libvirt_virDomainPtrWrap
(
dom
);
pyobj_dom_args
=
PyTuple_New
(
2
);
pyobj_dom_args
=
PyTuple_New
(
2
);
if
(
PyTuple_SetItem
(
pyobj_dom_args
,
0
,
pyobj_conn_inst
)
!=
0
)
{
if
(
PyTuple_SetItem
(
pyobj_dom_args
,
0
,
pyobj_conn_inst
)
!=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录