Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
1ee803e5
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,发现更多精彩内容 >>
提交
1ee803e5
编写于
11月 21, 2013
作者:
C
Cédric Bosdonnat
提交者:
Daniel P. Berrange
12月 10, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Renamed virDomainEventCallbackList* to virObjectEventCallbackList*
Keep the legacy Domain lifecycle event functions as is.
上级
146434ef
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
53 addition
and
44 deletion
+53
-44
src/conf/domain_event.c
src/conf/domain_event.c
+53
-41
src/conf/domain_event.h
src/conf/domain_event.h
+0
-3
未找到文件。
src/conf/domain_event.c
浏览文件 @
1ee803e5
...
@@ -43,11 +43,13 @@ typedef virObjectMeta *virObjectMetaPtr;
...
@@ -43,11 +43,13 @@ typedef virObjectMeta *virObjectMetaPtr;
typedef
struct
_virObjectEventQueue
virObjectEventQueue
;
typedef
struct
_virObjectEventQueue
virObjectEventQueue
;
typedef
virObjectEventQueue
*
virObjectEventQueuePtr
;
typedef
virObjectEventQueue
*
virObjectEventQueuePtr
;
struct
_vir
Domain
EventCallbackList
{
struct
_vir
Object
EventCallbackList
{
unsigned
int
nextID
;
unsigned
int
nextID
;
unsigned
int
count
;
unsigned
int
count
;
virObjectEventCallbackPtr
*
callbacks
;
virObjectEventCallbackPtr
*
callbacks
;
};
};
typedef
struct
_virObjectEventCallbackList
virObjectEventCallbackList
;
typedef
virObjectEventCallbackList
*
virObjectEventCallbackListPtr
;
struct
_virObjectEventQueue
{
struct
_virObjectEventQueue
{
unsigned
int
count
;
unsigned
int
count
;
...
@@ -56,7 +58,7 @@ struct _virObjectEventQueue {
...
@@ -56,7 +58,7 @@ struct _virObjectEventQueue {
struct
_virObjectEventState
{
struct
_virObjectEventState
{
/* The list of domain event callbacks */
/* The list of domain event callbacks */
vir
Domain
EventCallbackListPtr
callbacks
;
vir
Object
EventCallbackListPtr
callbacks
;
/* The queue of object events */
/* The queue of object events */
virObjectEventQueuePtr
queue
;
virObjectEventQueuePtr
queue
;
/* Timer for flushing events queue */
/* Timer for flushing events queue */
...
@@ -132,13 +134,13 @@ struct _virDomainEvent {
...
@@ -132,13 +134,13 @@ struct _virDomainEvent {
};
};
/**
/**
* vir
Domain
EventCallbackListFree:
* vir
Object
EventCallbackListFree:
* @list: event callback list head
* @list: event callback list head
*
*
* Free the memory in the domain event callback list
* Free the memory in the domain event callback list
*/
*/
static
void
static
void
vir
DomainEventCallbackListFree
(
virDomain
EventCallbackListPtr
list
)
vir
ObjectEventCallbackListFree
(
virObject
EventCallbackListPtr
list
)
{
{
size_t
i
;
size_t
i
;
if
(
!
list
)
if
(
!
list
)
...
@@ -161,11 +163,11 @@ virDomainEventCallbackListFree(virDomainEventCallbackListPtr list)
...
@@ -161,11 +163,11 @@ virDomainEventCallbackListFree(virDomainEventCallbackListPtr list)
* @cbList: the list
* @cbList: the list
* @callback: the callback to remove
* @callback: the callback to remove
*
*
* Internal function to remove a callback from a vir
Domain
EventCallbackListPtr
* Internal function to remove a callback from a vir
Object
EventCallbackListPtr
*/
*/
static
int
static
int
virDomainEventCallbackListRemove
(
virConnectPtr
conn
,
virDomainEventCallbackListRemove
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
virConnectDomainEventCallback
callback
)
virConnectDomainEventCallback
callback
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -207,16 +209,16 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
...
@@ -207,16 +209,16 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
/**
/**
* vir
Domain
EventCallbackListRemoveID:
* vir
Object
EventCallbackListRemoveID:
* @conn: pointer to the connection
* @conn: pointer to the connection
* @cbList: the list
* @cbList: the list
* @callback: the callback to remove
* @callback: the callback to remove
*
*
* Internal function to remove a callback from a vir
Domain
EventCallbackListPtr
* Internal function to remove a callback from a vir
Object
EventCallbackListPtr
*/
*/
static
int
static
int
vir
Domain
EventCallbackListRemoveID
(
virConnectPtr
conn
,
vir
Object
EventCallbackListRemoveID
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
int
callbackID
)
int
callbackID
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -258,7 +260,7 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn,
...
@@ -258,7 +260,7 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn,
static
int
static
int
virDomainEventCallbackListMarkDelete
(
virConnectPtr
conn
,
virDomainEventCallbackListMarkDelete
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
virConnectDomainEventCallback
callback
)
virConnectDomainEventCallback
callback
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -283,8 +285,8 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn,
...
@@ -283,8 +285,8 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn,
static
int
static
int
vir
Domain
EventCallbackListMarkDeleteID
(
virConnectPtr
conn
,
vir
Object
EventCallbackListMarkDeleteID
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
int
callbackID
)
int
callbackID
)
{
{
int
ret
=
0
;
int
ret
=
0
;
...
@@ -308,7 +310,7 @@ virDomainEventCallbackListMarkDeleteID(virConnectPtr conn,
...
@@ -308,7 +310,7 @@ virDomainEventCallbackListMarkDeleteID(virConnectPtr conn,
static
int
static
int
vir
DomainEventCallbackListPurgeMarked
(
virDomain
EventCallbackListPtr
cbList
)
vir
ObjectEventCallbackListPurgeMarked
(
virObject
EventCallbackListPtr
cbList
)
{
{
int
old_count
=
cbList
->
count
;
int
old_count
=
cbList
->
count
;
int
n
;
int
n
;
...
@@ -338,20 +340,25 @@ virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList)
...
@@ -338,20 +340,25 @@ virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList)
/**
/**
* vir
Domain
EventCallbackListAddID:
* vir
Object
EventCallbackListAddID:
* @conn: pointer to the connection
* @conn: pointer to the connection
* @cbList: the list
* @cbList: the list
* @uuid: the uuid of the object to filter on
* @name: the name of the object to filter on
* @id: the ID of the object to filter on
* @eventID: the event ID
* @eventID: the event ID
* @callback: the callback to add
* @callback: the callback to add
* @opaque: opaque data tio pass to callback
* @opaque: opaque data tio pass to callback
* @callbackID: filled with callback ID
* @callbackID: filled with callback ID
*
*
* Internal function to add a callback from a vir
Domain
EventCallbackListPtr
* Internal function to add a callback from a vir
Object
EventCallbackListPtr
*/
*/
static
int
static
int
virDomainEventCallbackListAddID
(
virConnectPtr
conn
,
virObjectEventCallbackListAddID
(
virConnectPtr
conn
,
virDomainEventCallbackListPtr
cbList
,
virObjectEventCallbackListPtr
cbList
,
virDomainPtr
dom
,
unsigned
char
uuid
[
VIR_UUID_BUFLEN
],
const
char
*
name
,
int
id
,
int
eventID
,
int
eventID
,
virConnectDomainEventGenericCallback
callback
,
virConnectDomainEventGenericCallback
callback
,
void
*
opaque
,
void
*
opaque
,
...
@@ -372,10 +379,10 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
...
@@ -372,10 +379,10 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
if
(
cbList
->
callbacks
[
i
]
->
cb
==
VIR_DOMAIN_EVENT_CALLBACK
(
callback
)
&&
if
(
cbList
->
callbacks
[
i
]
->
cb
==
VIR_DOMAIN_EVENT_CALLBACK
(
callback
)
&&
cbList
->
callbacks
[
i
]
->
eventID
==
eventID
&&
cbList
->
callbacks
[
i
]
->
eventID
==
eventID
&&
cbList
->
callbacks
[
i
]
->
conn
==
conn
&&
cbList
->
callbacks
[
i
]
->
conn
==
conn
&&
((
dom
&&
cbList
->
callbacks
[
i
]
->
meta
&&
((
uuid
&&
cbList
->
callbacks
[
i
]
->
meta
&&
memcmp
(
cbList
->
callbacks
[
i
]
->
meta
->
uuid
,
memcmp
(
cbList
->
callbacks
[
i
]
->
meta
->
uuid
,
dom
->
uuid
,
VIR_UUID_BUFLEN
)
==
0
)
||
uuid
,
VIR_UUID_BUFLEN
)
==
0
)
||
(
!
dom
&&
!
cbList
->
callbacks
[
i
]
->
meta
)))
{
(
!
uuid
&&
!
cbList
->
callbacks
[
i
]
->
meta
)))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"event callback already tracked"
));
_
(
"event callback already tracked"
));
return
-
1
;
return
-
1
;
...
@@ -390,13 +397,13 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
...
@@ -390,13 +397,13 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
event
->
opaque
=
opaque
;
event
->
opaque
=
opaque
;
event
->
freecb
=
freecb
;
event
->
freecb
=
freecb
;
if
(
dom
)
{
if
(
name
&&
uuid
&&
id
>
0
)
{
if
(
VIR_ALLOC
(
event
->
meta
)
<
0
)
if
(
VIR_ALLOC
(
event
->
meta
)
<
0
)
goto
error
;
goto
error
;
if
(
VIR_STRDUP
(
event
->
meta
->
name
,
dom
->
name
)
<
0
)
if
(
VIR_STRDUP
(
event
->
meta
->
name
,
name
)
<
0
)
goto
error
;
goto
error
;
memcpy
(
event
->
meta
->
uuid
,
dom
->
uuid
,
VIR_UUID_BUFLEN
);
memcpy
(
event
->
meta
->
uuid
,
uuid
,
VIR_UUID_BUFLEN
);
event
->
meta
->
id
=
dom
->
id
;
event
->
meta
->
id
=
id
;
}
}
/* Make space on list */
/* Make space on list */
...
@@ -440,16 +447,16 @@ error:
...
@@ -440,16 +447,16 @@ error:
* @callback: the callback to add
* @callback: the callback to add
* @opaque: opaque data tio pass to callback
* @opaque: opaque data tio pass to callback
*
*
* Internal function to add a callback from a vir
Domain
EventCallbackListPtr
* Internal function to add a callback from a vir
Object
EventCallbackListPtr
*/
*/
static
int
static
int
virDomainEventCallbackListAdd
(
virConnectPtr
conn
,
virDomainEventCallbackListAdd
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
virConnectDomainEventCallback
callback
,
virConnectDomainEventCallback
callback
,
void
*
opaque
,
void
*
opaque
,
virFreeCallback
freecb
)
virFreeCallback
freecb
)
{
{
return
vir
DomainEventCallbackListAddID
(
conn
,
cbList
,
NULL
,
return
vir
ObjectEventCallbackListAddID
(
conn
,
cbList
,
NULL
,
NULL
,
0
,
VIR_DOMAIN_EVENT_ID_LIFECYCLE
,
VIR_DOMAIN_EVENT_ID_LIFECYCLE
,
VIR_DOMAIN_EVENT_CALLBACK
(
callback
),
VIR_DOMAIN_EVENT_CALLBACK
(
callback
),
opaque
,
freecb
,
NULL
);
opaque
,
freecb
,
NULL
);
...
@@ -458,8 +465,8 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
...
@@ -458,8 +465,8 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
static
int
static
int
vir
Domain
EventCallbackListEventID
(
virConnectPtr
conn
,
vir
Object
EventCallbackListEventID
(
virConnectPtr
conn
,
vir
Domain
EventCallbackListPtr
cbList
,
vir
Object
EventCallbackListPtr
cbList
,
int
callbackID
)
int
callbackID
)
{
{
size_t
i
;
size_t
i
;
...
@@ -602,7 +609,7 @@ virObjectEventStateFree(virObjectEventStatePtr state)
...
@@ -602,7 +609,7 @@ virObjectEventStateFree(virObjectEventStatePtr state)
if
(
!
state
)
if
(
!
state
)
return
;
return
;
vir
Domain
EventCallbackListFree
(
state
->
callbacks
);
vir
Object
EventCallbackListFree
(
state
->
callbacks
);
virObjectEventQueueFree
(
state
->
queue
);
virObjectEventQueueFree
(
state
->
queue
);
if
(
state
->
timer
!=
-
1
)
if
(
state
->
timer
!=
-
1
)
...
@@ -1397,7 +1404,7 @@ static int virDomainEventDispatchMatchCallback(virDomainEventPtr event,
...
@@ -1397,7 +1404,7 @@ static int virDomainEventDispatchMatchCallback(virDomainEventPtr event,
static
void
static
void
virDomainEventDispatch
(
virDomainEventPtr
event
,
virDomainEventDispatch
(
virDomainEventPtr
event
,
vir
Domain
EventCallbackListPtr
callbacks
,
vir
Object
EventCallbackListPtr
callbacks
,
virDomainEventDispatchFunc
dispatch
,
virDomainEventDispatchFunc
dispatch
,
void
*
opaque
)
void
*
opaque
)
{
{
...
@@ -1422,7 +1429,7 @@ virDomainEventDispatch(virDomainEventPtr event,
...
@@ -1422,7 +1429,7 @@ virDomainEventDispatch(virDomainEventPtr event,
static
void
static
void
virObjectEventQueueDispatch
(
virObjectEventQueuePtr
queue
,
virObjectEventQueueDispatch
(
virObjectEventQueuePtr
queue
,
vir
Domain
EventCallbackListPtr
callbacks
,
vir
Object
EventCallbackListPtr
callbacks
,
virDomainEventDispatchFunc
dispatch
,
virDomainEventDispatchFunc
dispatch
,
void
*
opaque
)
void
*
opaque
)
{
{
...
@@ -1496,7 +1503,7 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
...
@@ -1496,7 +1503,7 @@ virObjectEventStateFlush(virObjectEventStatePtr state)
state
);
state
);
/* Purge any deleted callbacks */
/* Purge any deleted callbacks */
vir
Domain
EventCallbackListPurgeMarked
(
state
->
callbacks
);
vir
Object
EventCallbackListPurgeMarked
(
state
->
callbacks
);
state
->
isDispatching
=
false
;
state
->
isDispatching
=
false
;
virObjectEventStateUnlock
(
state
);
virObjectEventStateUnlock
(
state
);
...
@@ -1594,9 +1601,14 @@ virDomainEventStateRegisterID(virConnectPtr conn,
...
@@ -1594,9 +1601,14 @@ virDomainEventStateRegisterID(virConnectPtr conn,
goto
cleanup
;
goto
cleanup
;
}
}
ret
=
virDomainEventCallbackListAddID
(
conn
,
state
->
callbacks
,
if
(
dom
==
NULL
)
dom
,
eventID
,
cb
,
opaque
,
freecb
,
ret
=
virObjectEventCallbackListAddID
(
conn
,
state
->
callbacks
,
NULL
,
callbackID
);
NULL
,
0
,
eventID
,
cb
,
opaque
,
freecb
,
callbackID
);
else
ret
=
virObjectEventCallbackListAddID
(
conn
,
state
->
callbacks
,
dom
->
uuid
,
dom
->
name
,
dom
->
id
,
eventID
,
cb
,
opaque
,
freecb
,
callbackID
);
if
(
ret
==
-
1
&&
if
(
ret
==
-
1
&&
state
->
callbacks
->
count
==
0
&&
state
->
callbacks
->
count
==
0
&&
...
@@ -1668,10 +1680,10 @@ virObjectEventStateDeregisterID(virConnectPtr conn,
...
@@ -1668,10 +1680,10 @@ virObjectEventStateDeregisterID(virConnectPtr conn,
virObjectEventStateLock
(
state
);
virObjectEventStateLock
(
state
);
if
(
state
->
isDispatching
)
if
(
state
->
isDispatching
)
ret
=
vir
Domain
EventCallbackListMarkDeleteID
(
conn
,
ret
=
vir
Object
EventCallbackListMarkDeleteID
(
conn
,
state
->
callbacks
,
callbackID
);
state
->
callbacks
,
callbackID
);
else
else
ret
=
vir
Domain
EventCallbackListRemoveID
(
conn
,
ret
=
vir
Object
EventCallbackListRemoveID
(
conn
,
state
->
callbacks
,
callbackID
);
state
->
callbacks
,
callbackID
);
if
(
state
->
callbacks
->
count
==
0
&&
if
(
state
->
callbacks
->
count
==
0
&&
...
@@ -1705,7 +1717,7 @@ virObjectEventStateEventID(virConnectPtr conn,
...
@@ -1705,7 +1717,7 @@ virObjectEventStateEventID(virConnectPtr conn,
int
ret
;
int
ret
;
virObjectEventStateLock
(
state
);
virObjectEventStateLock
(
state
);
ret
=
vir
Domain
EventCallbackListEventID
(
conn
,
ret
=
vir
Object
EventCallbackListEventID
(
conn
,
state
->
callbacks
,
callbackID
);
state
->
callbacks
,
callbackID
);
virObjectEventStateUnlock
(
state
);
virObjectEventStateUnlock
(
state
);
return
ret
;
return
ret
;
...
...
src/conf/domain_event.h
浏览文件 @
1ee803e5
...
@@ -31,9 +31,6 @@
...
@@ -31,9 +31,6 @@
typedef
struct
_virObjectEventCallback
virObjectEventCallback
;
typedef
struct
_virObjectEventCallback
virObjectEventCallback
;
typedef
virObjectEventCallback
*
virObjectEventCallbackPtr
;
typedef
virObjectEventCallback
*
virObjectEventCallbackPtr
;
typedef
struct
_virDomainEventCallbackList
virDomainEventCallbackList
;
typedef
virDomainEventCallbackList
*
virDomainEventCallbackListPtr
;
/**
/**
* Dispatching domain events that come in while
* Dispatching domain events that come in while
* in a call / response rpc
* in a call / response rpc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录