Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
2ef412bd
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,发现更多精彩内容 >>
提交
2ef412bd
编写于
12月 11, 2013
作者:
C
Cédric Bosdonnat
提交者:
Daniel P. Berrange
12月 11, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test driver: implemented network events
上级
9ff38c54
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
71 addition
and
0 deletion
+71
-0
src/test/test_driver.c
src/test/test_driver.c
+71
-0
未找到文件。
src/test/test_driver.c
浏览文件 @
2ef412bd
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
#include "interface_conf.h"
#include "interface_conf.h"
#include "domain_conf.h"
#include "domain_conf.h"
#include "domain_event.h"
#include "domain_event.h"
#include "network_event.h"
#include "snapshot_conf.h"
#include "snapshot_conf.h"
#include "fdstream.h"
#include "fdstream.h"
#include "storage_conf.h"
#include "storage_conf.h"
...
@@ -3529,6 +3530,7 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml) {
...
@@ -3529,6 +3530,7 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml) {
virNetworkDefPtr
def
;
virNetworkDefPtr
def
;
virNetworkObjPtr
net
=
NULL
;
virNetworkObjPtr
net
=
NULL
;
virNetworkPtr
ret
=
NULL
;
virNetworkPtr
ret
=
NULL
;
virObjectEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
if
((
def
=
virNetworkDefParseString
(
xml
))
==
NULL
)
if
((
def
=
virNetworkDefParseString
(
xml
))
==
NULL
)
...
@@ -3539,10 +3541,15 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml) {
...
@@ -3539,10 +3541,15 @@ static virNetworkPtr testNetworkCreateXML(virConnectPtr conn, const char *xml) {
def
=
NULL
;
def
=
NULL
;
net
->
active
=
1
;
net
->
active
=
1
;
event
=
virNetworkEventLifecycleNew
(
net
->
def
->
name
,
net
->
def
->
uuid
,
VIR_NETWORK_EVENT_STARTED
);
ret
=
virGetNetwork
(
conn
,
net
->
def
->
name
,
net
->
def
->
uuid
);
ret
=
virGetNetwork
(
conn
,
net
->
def
->
name
,
net
->
def
->
uuid
);
cleanup:
cleanup:
virNetworkDefFree
(
def
);
virNetworkDefFree
(
def
);
if
(
event
)
testObjectEventQueue
(
privconn
,
event
);
if
(
net
)
if
(
net
)
virNetworkObjUnlock
(
net
);
virNetworkObjUnlock
(
net
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
...
@@ -3556,6 +3563,7 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
...
@@ -3556,6 +3563,7 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
virNetworkDefPtr
def
;
virNetworkDefPtr
def
;
virNetworkObjPtr
net
=
NULL
;
virNetworkObjPtr
net
=
NULL
;
virNetworkPtr
ret
=
NULL
;
virNetworkPtr
ret
=
NULL
;
virObjectEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
if
((
def
=
virNetworkDefParseString
(
xml
))
==
NULL
)
if
((
def
=
virNetworkDefParseString
(
xml
))
==
NULL
)
...
@@ -3566,10 +3574,15 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
...
@@ -3566,10 +3574,15 @@ virNetworkPtr testNetworkDefineXML(virConnectPtr conn, const char *xml)
def
=
NULL
;
def
=
NULL
;
net
->
persistent
=
1
;
net
->
persistent
=
1
;
event
=
virNetworkEventLifecycleNew
(
net
->
def
->
name
,
net
->
def
->
uuid
,
VIR_NETWORK_EVENT_DEFINED
);
ret
=
virGetNetwork
(
conn
,
net
->
def
->
name
,
net
->
def
->
uuid
);
ret
=
virGetNetwork
(
conn
,
net
->
def
->
name
,
net
->
def
->
uuid
);
cleanup:
cleanup:
virNetworkDefFree
(
def
);
virNetworkDefFree
(
def
);
if
(
event
)
testObjectEventQueue
(
privconn
,
event
);
if
(
net
)
if
(
net
)
virNetworkObjUnlock
(
net
);
virNetworkObjUnlock
(
net
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
...
@@ -3580,6 +3593,7 @@ static int testNetworkUndefine(virNetworkPtr network) {
...
@@ -3580,6 +3593,7 @@ static int testNetworkUndefine(virNetworkPtr network) {
testConnPtr
privconn
=
network
->
conn
->
privateData
;
testConnPtr
privconn
=
network
->
conn
->
privateData
;
virNetworkObjPtr
privnet
;
virNetworkObjPtr
privnet
;
int
ret
=
-
1
;
int
ret
=
-
1
;
virObjectEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
...
@@ -3596,12 +3610,17 @@ static int testNetworkUndefine(virNetworkPtr network) {
...
@@ -3596,12 +3610,17 @@ static int testNetworkUndefine(virNetworkPtr network) {
goto
cleanup
;
goto
cleanup
;
}
}
event
=
virNetworkEventLifecycleNew
(
network
->
name
,
network
->
uuid
,
VIR_NETWORK_EVENT_UNDEFINED
);
virNetworkRemoveInactive
(
&
privconn
->
networks
,
virNetworkRemoveInactive
(
&
privconn
->
networks
,
privnet
);
privnet
);
privnet
=
NULL
;
privnet
=
NULL
;
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
event
)
testObjectEventQueue
(
privconn
,
event
);
if
(
privnet
)
if
(
privnet
)
virNetworkObjUnlock
(
privnet
);
virNetworkObjUnlock
(
privnet
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
...
@@ -3660,6 +3679,7 @@ static int testNetworkCreate(virNetworkPtr network) {
...
@@ -3660,6 +3679,7 @@ static int testNetworkCreate(virNetworkPtr network) {
testConnPtr
privconn
=
network
->
conn
->
privateData
;
testConnPtr
privconn
=
network
->
conn
->
privateData
;
virNetworkObjPtr
privnet
;
virNetworkObjPtr
privnet
;
int
ret
=
-
1
;
int
ret
=
-
1
;
virObjectEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
...
@@ -3678,9 +3698,13 @@ static int testNetworkCreate(virNetworkPtr network) {
...
@@ -3678,9 +3698,13 @@ static int testNetworkCreate(virNetworkPtr network) {
}
}
privnet
->
active
=
1
;
privnet
->
active
=
1
;
event
=
virNetworkEventLifecycleNew
(
privnet
->
def
->
name
,
privnet
->
def
->
uuid
,
VIR_NETWORK_EVENT_STARTED
);
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
event
)
testObjectEventQueue
(
privconn
,
event
);
if
(
privnet
)
if
(
privnet
)
virNetworkObjUnlock
(
privnet
);
virNetworkObjUnlock
(
privnet
);
return
ret
;
return
ret
;
...
@@ -3690,6 +3714,7 @@ static int testNetworkDestroy(virNetworkPtr network) {
...
@@ -3690,6 +3714,7 @@ static int testNetworkDestroy(virNetworkPtr network) {
testConnPtr
privconn
=
network
->
conn
->
privateData
;
testConnPtr
privconn
=
network
->
conn
->
privateData
;
virNetworkObjPtr
privnet
;
virNetworkObjPtr
privnet
;
int
ret
=
-
1
;
int
ret
=
-
1
;
virObjectEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
privnet
=
virNetworkFindByName
(
&
privconn
->
networks
,
...
@@ -3701,6 +3726,8 @@ static int testNetworkDestroy(virNetworkPtr network) {
...
@@ -3701,6 +3726,8 @@ static int testNetworkDestroy(virNetworkPtr network) {
}
}
privnet
->
active
=
0
;
privnet
->
active
=
0
;
event
=
virNetworkEventLifecycleNew
(
privnet
->
def
->
name
,
privnet
->
def
->
uuid
,
VIR_NETWORK_EVENT_STOPPED
);
if
(
!
privnet
->
persistent
)
{
if
(
!
privnet
->
persistent
)
{
virNetworkRemoveInactive
(
&
privconn
->
networks
,
virNetworkRemoveInactive
(
&
privconn
->
networks
,
privnet
);
privnet
);
...
@@ -3709,6 +3736,8 @@ static int testNetworkDestroy(virNetworkPtr network) {
...
@@ -3709,6 +3736,8 @@ static int testNetworkDestroy(virNetworkPtr network) {
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
event
)
testObjectEventQueue
(
privconn
,
event
);
if
(
privnet
)
if
(
privnet
)
virNetworkObjUnlock
(
privnet
);
virNetworkObjUnlock
(
privnet
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
...
@@ -6027,6 +6056,46 @@ testConnectDomainEventDeregisterAny(virConnectPtr conn,
...
@@ -6027,6 +6056,46 @@ testConnectDomainEventDeregisterAny(virConnectPtr conn,
}
}
static
int
testConnectNetworkEventRegisterAny
(
virConnectPtr
conn
,
virNetworkPtr
net
,
int
eventID
,
virConnectNetworkEventGenericCallback
callback
,
void
*
opaque
,
virFreeCallback
freecb
)
{
testConnPtr
driver
=
conn
->
privateData
;
int
ret
;
testDriverLock
(
driver
);
if
(
virNetworkEventStateRegisterID
(
conn
,
driver
->
domainEventState
,
net
,
eventID
,
VIR_OBJECT_EVENT_CALLBACK
(
callback
),
opaque
,
freecb
,
&
ret
)
<
0
)
ret
=
-
1
;
testDriverUnlock
(
driver
);
return
ret
;
}
static
int
testConnectNetworkEventDeregisterAny
(
virConnectPtr
conn
,
int
callbackID
)
{
testConnPtr
driver
=
conn
->
privateData
;
int
ret
;
testDriverLock
(
driver
);
ret
=
virObjectEventStateDeregisterID
(
conn
,
driver
->
domainEventState
,
callbackID
);
testDriverUnlock
(
driver
);
return
ret
;
}
/* driver must be locked before calling */
/* driver must be locked before calling */
static
void
testObjectEventQueue
(
testConnPtr
driver
,
static
void
testObjectEventQueue
(
testConnPtr
driver
,
virObjectEventPtr
event
)
virObjectEventPtr
event
)
...
@@ -7205,6 +7274,8 @@ static virNetworkDriver testNetworkDriver = {
...
@@ -7205,6 +7274,8 @@ static virNetworkDriver testNetworkDriver = {
.
connectNumOfDefinedNetworks
=
testConnectNumOfDefinedNetworks
,
/* 0.3.2 */
.
connectNumOfDefinedNetworks
=
testConnectNumOfDefinedNetworks
,
/* 0.3.2 */
.
connectListDefinedNetworks
=
testConnectListDefinedNetworks
,
/* 0.3.2 */
.
connectListDefinedNetworks
=
testConnectListDefinedNetworks
,
/* 0.3.2 */
.
connectListAllNetworks
=
testConnectListAllNetworks
,
/* 0.10.2 */
.
connectListAllNetworks
=
testConnectListAllNetworks
,
/* 0.10.2 */
.
connectNetworkEventRegisterAny
=
testConnectNetworkEventRegisterAny
,
/* 1.2.1 */
.
connectNetworkEventDeregisterAny
=
testConnectNetworkEventDeregisterAny
,
/* 1.2.1 */
.
networkLookupByUUID
=
testNetworkLookupByUUID
,
/* 0.3.2 */
.
networkLookupByUUID
=
testNetworkLookupByUUID
,
/* 0.3.2 */
.
networkLookupByName
=
testNetworkLookupByName
,
/* 0.3.2 */
.
networkLookupByName
=
testNetworkLookupByName
,
/* 0.3.2 */
.
networkCreateXML
=
testNetworkCreateXML
,
/* 0.3.2 */
.
networkCreateXML
=
testNetworkCreateXML
,
/* 0.3.2 */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录