Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4d7297f8
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,发现更多精彩内容 >>
提交
4d7297f8
编写于
5月 12, 2011
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: Use virDomainEventState helpers
v3: Adjust for new virDomainEventStateNew argument
上级
1ded8942
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
73 deletion
+32
-73
src/test/test_driver.c
src/test/test_driver.c
+32
-73
未找到文件。
src/test/test_driver.c
浏览文件 @
4d7297f8
...
@@ -90,12 +90,7 @@ struct _testConn {
...
@@ -90,12 +90,7 @@ struct _testConn {
int
numCells
;
int
numCells
;
testCell
cells
[
MAX_CELLS
];
testCell
cells
[
MAX_CELLS
];
virDomainEventStatePtr
domainEventState
;
/* An array of callbacks */
virDomainEventCallbackListPtr
domainEventCallbacks
;
virDomainEventQueuePtr
domainEventQueue
;
int
domainEventTimer
;
int
domainEventDispatching
;
};
};
typedef
struct
_testConn
testConn
;
typedef
struct
_testConn
testConn
;
typedef
struct
_testConn
*
testConnPtr
;
typedef
struct
_testConn
*
testConnPtr
;
...
@@ -1104,6 +1099,7 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
...
@@ -1104,6 +1099,7 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
int
flags
ATTRIBUTE_UNUSED
)
int
flags
ATTRIBUTE_UNUSED
)
{
{
int
ret
;
int
ret
;
testConnPtr
privconn
;
if
(
!
conn
->
uri
)
if
(
!
conn
->
uri
)
return
VIR_DRV_OPEN_DECLINED
;
return
VIR_DRV_OPEN_DECLINED
;
...
@@ -1130,26 +1126,25 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
...
@@ -1130,26 +1126,25 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
ret
=
testOpenFromFile
(
conn
,
ret
=
testOpenFromFile
(
conn
,
conn
->
uri
->
path
);
conn
->
uri
->
path
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
{
if
(
ret
!=
VIR_DRV_OPEN_SUCCESS
)
testConnPtr
privconn
=
conn
->
privateData
;
return
ret
;
testDriverLock
(
privconn
);
/* Init callback list */
privconn
=
conn
->
privateData
;
if
(
VIR_ALLOC
(
privconn
->
domainEventCallbacks
)
<
0
||
testDriverLock
(
privconn
);
!
(
privconn
->
domainEventQueue
=
virDomainEventQueueNew
()))
{
virReportOOMError
();
testDriverUnlock
(
privconn
);
testClose
(
conn
);
return
VIR_DRV_OPEN_ERROR
;
}
if
((
privconn
->
domainEventTimer
=
privconn
->
domainEventState
=
virDomainEventStateNew
(
testDomainEventFlush
,
virEventAddTimeout
(
-
1
,
testDomainEventFlush
,
privconn
,
NULL
))
<
0
)
privconn
,
VIR_DEBUG
(
"virEventAddTimeout failed: No addTimeoutImpl defined. "
NULL
,
"continuing without events."
);
false
);
if
(
!
privconn
->
domainEventState
)
{
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
testClose
(
conn
);
return
VIR_DRV_OPEN_ERROR
;
}
}
return
(
ret
);
testDriverUnlock
(
privconn
);
return
VIR_DRV_OPEN_SUCCESS
;
}
}
static
int
testClose
(
virConnectPtr
conn
)
static
int
testClose
(
virConnectPtr
conn
)
...
@@ -1162,12 +1157,7 @@ static int testClose(virConnectPtr conn)
...
@@ -1162,12 +1157,7 @@ static int testClose(virConnectPtr conn)
virNetworkObjListFree
(
&
privconn
->
networks
);
virNetworkObjListFree
(
&
privconn
->
networks
);
virInterfaceObjListFree
(
&
privconn
->
ifaces
);
virInterfaceObjListFree
(
&
privconn
->
ifaces
);
virStoragePoolObjListFree
(
&
privconn
->
pools
);
virStoragePoolObjListFree
(
&
privconn
->
pools
);
virDomainEventStateFree
(
privconn
->
domainEventState
);
virDomainEventCallbackListFree
(
privconn
->
domainEventCallbacks
);
virDomainEventQueueFree
(
privconn
->
domainEventQueue
);
if
(
privconn
->
domainEventTimer
!=
-
1
)
virEventRemoveTimeout
(
privconn
->
domainEventTimer
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
virMutexDestroy
(
&
privconn
->
lock
);
virMutexDestroy
(
&
privconn
->
lock
);
...
@@ -5157,7 +5147,8 @@ testDomainEventRegister(virConnectPtr conn,
...
@@ -5157,7 +5147,8 @@ testDomainEventRegister(virConnectPtr conn,
int
ret
;
int
ret
;
testDriverLock
(
driver
);
testDriverLock
(
driver
);
ret
=
virDomainEventCallbackListAdd
(
conn
,
driver
->
domainEventCallbacks
,
ret
=
virDomainEventCallbackListAdd
(
conn
,
driver
->
domainEventState
->
callbacks
,
callback
,
opaque
,
freecb
);
callback
,
opaque
,
freecb
);
testDriverUnlock
(
driver
);
testDriverUnlock
(
driver
);
...
@@ -5173,12 +5164,9 @@ testDomainEventDeregister(virConnectPtr conn,
...
@@ -5173,12 +5164,9 @@ testDomainEventDeregister(virConnectPtr conn,
int
ret
;
int
ret
;
testDriverLock
(
driver
);
testDriverLock
(
driver
);
if
(
driver
->
domainEventDispatching
)
ret
=
virDomainEventStateDeregister
(
conn
,
ret
=
virDomainEventCallbackListMarkDelete
(
conn
,
driver
->
domainEventCallbacks
,
driver
->
domainEventState
,
callback
);
callback
);
else
ret
=
virDomainEventCallbackListRemove
(
conn
,
driver
->
domainEventCallbacks
,
callback
);
testDriverUnlock
(
driver
);
testDriverUnlock
(
driver
);
return
ret
;
return
ret
;
...
@@ -5197,7 +5185,8 @@ testDomainEventRegisterAny(virConnectPtr conn,
...
@@ -5197,7 +5185,8 @@ testDomainEventRegisterAny(virConnectPtr conn,
int
ret
;
int
ret
;
testDriverLock
(
driver
);
testDriverLock
(
driver
);
ret
=
virDomainEventCallbackListAddID
(
conn
,
driver
->
domainEventCallbacks
,
ret
=
virDomainEventCallbackListAddID
(
conn
,
driver
->
domainEventState
->
callbacks
,
dom
,
eventID
,
dom
,
eventID
,
callback
,
opaque
,
freecb
);
callback
,
opaque
,
freecb
);
testDriverUnlock
(
driver
);
testDriverUnlock
(
driver
);
...
@@ -5213,12 +5202,9 @@ testDomainEventDeregisterAny(virConnectPtr conn,
...
@@ -5213,12 +5202,9 @@ testDomainEventDeregisterAny(virConnectPtr conn,
int
ret
;
int
ret
;
testDriverLock
(
driver
);
testDriverLock
(
driver
);
if
(
driver
->
domainEventDispatching
)
ret
=
virDomainEventStateDeregisterAny
(
conn
,
ret
=
virDomainEventCallbackListMarkDeleteID
(
conn
,
driver
->
domainEventCallbacks
,
driver
->
domainEventState
,
callbackID
);
callbackID
);
else
ret
=
virDomainEventCallbackListRemoveID
(
conn
,
driver
->
domainEventCallbacks
,
callbackID
);
testDriverUnlock
(
driver
);
testDriverUnlock
(
driver
);
return
ret
;
return
ret
;
...
@@ -5242,28 +5228,11 @@ static void testDomainEventDispatchFunc(virConnectPtr conn,
...
@@ -5242,28 +5228,11 @@ static void testDomainEventDispatchFunc(virConnectPtr conn,
static
void
testDomainEventFlush
(
int
timer
ATTRIBUTE_UNUSED
,
void
*
opaque
)
static
void
testDomainEventFlush
(
int
timer
ATTRIBUTE_UNUSED
,
void
*
opaque
)
{
{
testConnPtr
driver
=
opaque
;
testConnPtr
driver
=
opaque
;
virDomainEventQueue
tempQueue
;
testDriverLock
(
driver
);
testDriverLock
(
driver
);
virDomainEventStateFlush
(
driver
->
domainEventState
,
driver
->
domainEventDispatching
=
1
;
testDomainEventDispatchFunc
,
driver
);
/* Copy the queue, so we're reentrant safe */
tempQueue
.
count
=
driver
->
domainEventQueue
->
count
;
tempQueue
.
events
=
driver
->
domainEventQueue
->
events
;
driver
->
domainEventQueue
->
count
=
0
;
driver
->
domainEventQueue
->
events
=
NULL
;
virEventUpdateTimeout
(
driver
->
domainEventTimer
,
-
1
);
virDomainEventQueueDispatch
(
&
tempQueue
,
driver
->
domainEventCallbacks
,
testDomainEventDispatchFunc
,
driver
);
/* Purge any deleted callbacks */
virDomainEventCallbackListPurgeMarked
(
driver
->
domainEventCallbacks
);
driver
->
domainEventDispatching
=
0
;
testDriverUnlock
(
driver
);
testDriverUnlock
(
driver
);
}
}
...
@@ -5272,17 +5241,7 @@ static void testDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
...
@@ -5272,17 +5241,7 @@ static void testDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
static
void
testDomainEventQueue
(
testConnPtr
driver
,
static
void
testDomainEventQueue
(
testConnPtr
driver
,
virDomainEventPtr
event
)
virDomainEventPtr
event
)
{
{
if
(
driver
->
domainEventTimer
<
0
)
{
virDomainEventStateQueue
(
driver
->
domainEventState
,
event
);
virDomainEventFree
(
event
);
return
;
}
if
(
virDomainEventQueuePush
(
driver
->
domainEventQueue
,
event
)
<
0
)
virDomainEventFree
(
event
);
if
(
driver
->
domainEventQueue
->
count
==
1
)
virEventUpdateTimeout
(
driver
->
domainEventTimer
,
0
);
}
}
static
virDrvOpenStatus
testSecretOpen
(
virConnectPtr
conn
,
static
virDrvOpenStatus
testSecretOpen
(
virConnectPtr
conn
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录