Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a888b22c
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看板
提交
a888b22c
编写于
1月 20, 2009
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support domain events in test driver
上级
071be080
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
234 addition
and
6 deletion
+234
-6
ChangeLog
ChangeLog
+6
-0
src/test.c
src/test.c
+225
-6
tests/read-bufsiz
tests/read-bufsiz
+3
-0
未找到文件。
ChangeLog
浏览文件 @
a888b22c
Tue Jan 20 20:22:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* src/test.c: Support domain events in test driver
* tests/read-bufsiz: Set $srcdir & $abs_srcdir if running
standalone
Tue Jan 20 19:49:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Tue Jan 20 19:49:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* .x-sc_prohibit_nonreentrant: Blacklist some places where
* .x-sc_prohibit_nonreentrant: Blacklist some places where
...
...
src/test.c
浏览文件 @
a888b22c
...
@@ -42,9 +42,12 @@
...
@@ -42,9 +42,12 @@
#include "memory.h"
#include "memory.h"
#include "network_conf.h"
#include "network_conf.h"
#include "domain_conf.h"
#include "domain_conf.h"
#include "domain_event.h"
#include "event.h"
#include "storage_conf.h"
#include "storage_conf.h"
#include "xml.h"
#include "xml.h"
#include "threads.h"
#include "threads.h"
#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_TEST
#define VIR_FROM_THIS VIR_FROM_TEST
...
@@ -72,6 +75,13 @@ struct _testConn {
...
@@ -72,6 +75,13 @@ struct _testConn {
virStoragePoolObjList
pools
;
virStoragePoolObjList
pools
;
int
numCells
;
int
numCells
;
testCell
cells
[
MAX_CELLS
];
testCell
cells
[
MAX_CELLS
];
/* 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
;
...
@@ -96,6 +106,12 @@ static const virNodeInfo defaultNodeInfo = {
...
@@ -96,6 +106,12 @@ static const virNodeInfo defaultNodeInfo = {
virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \
virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
__FUNCTION__, __LINE__, fmt)
static
int
testClose
(
virConnectPtr
conn
);
static
void
testDomainEventFlush
(
int
timer
,
void
*
opaque
);
static
void
testDomainEventQueue
(
testConnPtr
driver
,
virDomainEventPtr
event
);
static
void
testDriverLock
(
testConnPtr
driver
)
static
void
testDriverLock
(
testConnPtr
driver
)
{
{
virMutexLock
(
&
driver
->
lock
);
virMutexLock
(
&
driver
->
lock
);
...
@@ -644,6 +660,22 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
...
@@ -644,6 +660,22 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
ret
=
testOpenFromFile
(
conn
,
ret
=
testOpenFromFile
(
conn
,
conn
->
uri
->
path
);
conn
->
uri
->
path
);
if
(
ret
==
VIR_DRV_OPEN_SUCCESS
)
{
testConnPtr
privconn
=
conn
->
privateData
;
/* Init callback list */
if
(
VIR_ALLOC
(
privconn
->
domainEventCallbacks
)
<
0
||
!
(
privconn
->
domainEventQueue
=
virDomainEventQueueNew
()))
{
virReportOOMError
(
NULL
);
testClose
(
conn
);
return
VIR_DRV_OPEN_ERROR
;
}
if
((
privconn
->
domainEventTimer
=
virEventAddTimeout
(
-
1
,
testDomainEventFlush
,
privconn
,
NULL
))
<
0
)
DEBUG0
(
"virEventAddTimeout failed: No addTimeoutImpl defined. "
"continuing without events."
);
}
return
(
ret
);
return
(
ret
);
}
}
...
@@ -655,6 +687,13 @@ static int testClose(virConnectPtr conn)
...
@@ -655,6 +687,13 @@ static int testClose(virConnectPtr conn)
virDomainObjListFree
(
&
privconn
->
domains
);
virDomainObjListFree
(
&
privconn
->
domains
);
virNetworkObjListFree
(
&
privconn
->
networks
);
virNetworkObjListFree
(
&
privconn
->
networks
);
virStoragePoolObjListFree
(
&
privconn
->
pools
);
virStoragePoolObjListFree
(
&
privconn
->
pools
);
virDomainEventCallbackListFree
(
privconn
->
domainEventCallbacks
);
virDomainEventQueueFree
(
privconn
->
domainEventQueue
);
if
(
privconn
->
domainEventTimer
!=
-
1
)
virEventRemoveTimeout
(
privconn
->
domainEventTimer
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
virMutexDestroy
(
&
privconn
->
lock
);
virMutexDestroy
(
&
privconn
->
lock
);
...
@@ -733,6 +772,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
...
@@ -733,6 +772,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
virDomainPtr
ret
=
NULL
;
virDomainPtr
ret
=
NULL
;
virDomainDefPtr
def
;
virDomainDefPtr
def
;
virDomainObjPtr
dom
=
NULL
;
virDomainObjPtr
dom
=
NULL
;
virDomainEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
if
((
def
=
virDomainDefParseString
(
conn
,
privconn
->
caps
,
xml
,
if
((
def
=
virDomainDefParseString
(
conn
,
privconn
->
caps
,
xml
,
...
@@ -747,6 +787,10 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
...
@@ -747,6 +787,10 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
dom
->
state
=
VIR_DOMAIN_RUNNING
;
dom
->
state
=
VIR_DOMAIN_RUNNING
;
dom
->
def
->
id
=
privconn
->
nextDomID
++
;
dom
->
def
->
id
=
privconn
->
nextDomID
++
;
event
=
virDomainEventNewFromObj
(
dom
,
VIR_DOMAIN_EVENT_STARTED
,
VIR_DOMAIN_EVENT_STARTED_BOOTED
);
ret
=
virGetDomain
(
conn
,
def
->
name
,
def
->
uuid
);
ret
=
virGetDomain
(
conn
,
def
->
name
,
def
->
uuid
);
if
(
ret
)
if
(
ret
)
ret
->
id
=
def
->
id
;
ret
->
id
=
def
->
id
;
...
@@ -754,6 +798,8 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
...
@@ -754,6 +798,8 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
cleanup:
cleanup:
if
(
dom
)
if
(
dom
)
virDomainObjUnlock
(
dom
);
virDomainObjUnlock
(
dom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -860,6 +906,7 @@ static int testDestroyDomain (virDomainPtr domain)
...
@@ -860,6 +906,7 @@ static int testDestroyDomain (virDomainPtr domain)
{
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -874,16 +921,22 @@ static int testDestroyDomain (virDomainPtr domain)
...
@@ -874,16 +921,22 @@ static int testDestroyDomain (virDomainPtr domain)
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
def
->
id
=
-
1
;
privdom
->
def
->
id
=
-
1
;
domain
->
id
=
-
1
;
domain
->
id
=
-
1
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED
);
if
(
!
privdom
->
persistent
)
{
if
(
!
privdom
->
persistent
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
);
privdom
=
NULL
;
privdom
=
NULL
;
}
}
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -892,6 +945,7 @@ static int testResumeDomain (virDomainPtr domain)
...
@@ -892,6 +945,7 @@ static int testResumeDomain (virDomainPtr domain)
{
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -912,11 +966,19 @@ static int testResumeDomain (virDomainPtr domain)
...
@@ -912,11 +966,19 @@ static int testResumeDomain (virDomainPtr domain)
}
}
privdom
->
state
=
VIR_DOMAIN_RUNNING
;
privdom
->
state
=
VIR_DOMAIN_RUNNING
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_RESUMED
,
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED
);
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
{
testDriverLock
(
privconn
);
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
}
return
ret
;
return
ret
;
}
}
...
@@ -924,6 +986,7 @@ static int testPauseDomain (virDomainPtr domain)
...
@@ -924,6 +986,7 @@ static int testPauseDomain (virDomainPtr domain)
{
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -945,11 +1008,20 @@ static int testPauseDomain (virDomainPtr domain)
...
@@ -945,11 +1008,20 @@ static int testPauseDomain (virDomainPtr domain)
}
}
privdom
->
state
=
VIR_DOMAIN_PAUSED
;
privdom
->
state
=
VIR_DOMAIN_PAUSED
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_SUSPENDED
,
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED
);
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
{
testDriverLock
(
privconn
);
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
}
return
ret
;
return
ret
;
}
}
...
@@ -957,6 +1029,7 @@ static int testShutdownDomain (virDomainPtr domain)
...
@@ -957,6 +1029,7 @@ static int testShutdownDomain (virDomainPtr domain)
{
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -977,6 +1050,9 @@ static int testShutdownDomain (virDomainPtr domain)
...
@@ -977,6 +1050,9 @@ static int testShutdownDomain (virDomainPtr domain)
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
domain
->
id
=
-
1
;
domain
->
id
=
-
1
;
privdom
->
def
->
id
=
-
1
;
privdom
->
def
->
id
=
-
1
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN
);
if
(
!
privdom
->
persistent
)
{
if
(
!
privdom
->
persistent
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
);
...
@@ -987,6 +1063,8 @@ static int testShutdownDomain (virDomainPtr domain)
...
@@ -987,6 +1063,8 @@ static int testShutdownDomain (virDomainPtr domain)
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -997,6 +1075,7 @@ static int testRebootDomain (virDomainPtr domain,
...
@@ -997,6 +1075,7 @@ static int testRebootDomain (virDomainPtr domain,
{
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -1037,10 +1116,15 @@ static int testRebootDomain (virDomainPtr domain,
...
@@ -1037,10 +1116,15 @@ static int testRebootDomain (virDomainPtr domain,
break
;
break
;
}
}
if
(
privdom
->
state
==
VIR_DOMAIN_SHUTOFF
&&
!
privdom
->
persistent
)
{
if
(
privdom
->
state
==
VIR_DOMAIN_SHUTOFF
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
event
=
virDomainEventNewFromObj
(
privdom
,
privdom
);
VIR_DOMAIN_EVENT_STOPPED
,
privdom
=
NULL
;
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN
);
if
(
!
privdom
->
persistent
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
=
NULL
;
}
}
}
ret
=
0
;
ret
=
0
;
...
@@ -1048,6 +1132,8 @@ static int testRebootDomain (virDomainPtr domain,
...
@@ -1048,6 +1132,8 @@ static int testRebootDomain (virDomainPtr domain,
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1101,6 +1187,7 @@ static int testDomainSave(virDomainPtr domain,
...
@@ -1101,6 +1187,7 @@ static int testDomainSave(virDomainPtr domain,
int
fd
=
-
1
;
int
fd
=
-
1
;
int
len
;
int
len
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -1155,6 +1242,9 @@ static int testDomainSave(virDomainPtr domain,
...
@@ -1155,6 +1242,9 @@ static int testDomainSave(virDomainPtr domain,
fd
=
-
1
;
fd
=
-
1
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_SAVED
);
if
(
!
privdom
->
persistent
)
{
if
(
!
privdom
->
persistent
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
);
...
@@ -1175,6 +1265,8 @@ cleanup:
...
@@ -1175,6 +1265,8 @@ cleanup:
}
}
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1189,6 +1281,7 @@ static int testDomainRestore(virConnectPtr conn,
...
@@ -1189,6 +1281,7 @@ static int testDomainRestore(virConnectPtr conn,
int
len
;
int
len
;
virDomainDefPtr
def
=
NULL
;
virDomainDefPtr
def
=
NULL
;
virDomainObjPtr
dom
=
NULL
;
virDomainObjPtr
dom
=
NULL
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
if
((
fd
=
open
(
path
,
O_RDONLY
))
<
0
)
{
if
((
fd
=
open
(
path
,
O_RDONLY
))
<
0
)
{
...
@@ -1243,6 +1336,9 @@ static int testDomainRestore(virConnectPtr conn,
...
@@ -1243,6 +1336,9 @@ static int testDomainRestore(virConnectPtr conn,
dom
->
state
=
VIR_DOMAIN_RUNNING
;
dom
->
state
=
VIR_DOMAIN_RUNNING
;
dom
->
def
->
id
=
privconn
->
nextDomID
++
;
dom
->
def
->
id
=
privconn
->
nextDomID
++
;
def
=
NULL
;
def
=
NULL
;
event
=
virDomainEventNewFromObj
(
dom
,
VIR_DOMAIN_EVENT_STARTED
,
VIR_DOMAIN_EVENT_STARTED_RESTORED
);
ret
=
dom
->
def
->
id
;
ret
=
dom
->
def
->
id
;
cleanup:
cleanup:
...
@@ -1252,6 +1348,8 @@ cleanup:
...
@@ -1252,6 +1348,8 @@ cleanup:
close
(
fd
);
close
(
fd
);
if
(
dom
)
if
(
dom
)
virDomainObjUnlock
(
dom
);
virDomainObjUnlock
(
dom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1263,6 +1361,7 @@ static int testDomainCoreDump(virDomainPtr domain,
...
@@ -1263,6 +1361,7 @@ static int testDomainCoreDump(virDomainPtr domain,
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
int
fd
=
-
1
;
int
fd
=
-
1
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -1293,6 +1392,9 @@ static int testDomainCoreDump(virDomainPtr domain,
...
@@ -1293,6 +1392,9 @@ static int testDomainCoreDump(virDomainPtr domain,
goto
cleanup
;
goto
cleanup
;
}
}
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_CRASHED
);
if
(
!
privdom
->
persistent
)
{
if
(
!
privdom
->
persistent
)
{
virDomainRemoveInactive
(
&
privconn
->
domains
,
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
);
...
@@ -1305,6 +1407,8 @@ cleanup:
...
@@ -1305,6 +1407,8 @@ cleanup:
close
(
fd
);
close
(
fd
);
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1510,6 +1614,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
...
@@ -1510,6 +1614,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
virDomainPtr
ret
=
NULL
;
virDomainPtr
ret
=
NULL
;
virDomainDefPtr
def
;
virDomainDefPtr
def
;
virDomainObjPtr
dom
=
NULL
;
virDomainObjPtr
dom
=
NULL
;
virDomainEventPtr
event
=
NULL
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
if
((
def
=
virDomainDefParseString
(
conn
,
privconn
->
caps
,
xml
,
if
((
def
=
virDomainDefParseString
(
conn
,
privconn
->
caps
,
xml
,
...
@@ -1522,6 +1627,9 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
...
@@ -1522,6 +1627,9 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
}
}
dom
->
persistent
=
1
;
dom
->
persistent
=
1
;
dom
->
def
->
id
=
-
1
;
dom
->
def
->
id
=
-
1
;
event
=
virDomainEventNewFromObj
(
dom
,
VIR_DOMAIN_EVENT_DEFINED
,
VIR_DOMAIN_EVENT_DEFINED_ADDED
);
ret
=
virGetDomain
(
conn
,
def
->
name
,
def
->
uuid
);
ret
=
virGetDomain
(
conn
,
def
->
name
,
def
->
uuid
);
def
=
NULL
;
def
=
NULL
;
...
@@ -1532,6 +1640,8 @@ cleanup:
...
@@ -1532,6 +1640,8 @@ cleanup:
virDomainDefFree
(
def
);
virDomainDefFree
(
def
);
if
(
dom
)
if
(
dom
)
virDomainObjUnlock
(
dom
);
virDomainObjUnlock
(
dom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1566,6 +1676,7 @@ cleanup:
...
@@ -1566,6 +1676,7 @@ cleanup:
static
int
testDomainCreate
(
virDomainPtr
domain
)
{
static
int
testDomainCreate
(
virDomainPtr
domain
)
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -1585,11 +1696,16 @@ static int testDomainCreate(virDomainPtr domain) {
...
@@ -1585,11 +1696,16 @@ static int testDomainCreate(virDomainPtr domain) {
domain
->
id
=
privdom
->
def
->
id
=
privconn
->
nextDomID
++
;
domain
->
id
=
privdom
->
def
->
id
=
privconn
->
nextDomID
++
;
privdom
->
state
=
VIR_DOMAIN_RUNNING
;
privdom
->
state
=
VIR_DOMAIN_RUNNING
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_STARTED
,
VIR_DOMAIN_EVENT_STARTED_BOOTED
);
ret
=
0
;
ret
=
0
;
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -1597,6 +1713,7 @@ cleanup:
...
@@ -1597,6 +1713,7 @@ cleanup:
static
int
testDomainUndefine
(
virDomainPtr
domain
)
{
static
int
testDomainUndefine
(
virDomainPtr
domain
)
{
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
testConnPtr
privconn
=
domain
->
conn
->
privateData
;
virDomainObjPtr
privdom
;
virDomainObjPtr
privdom
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
int
ret
=
-
1
;
testDriverLock
(
privconn
);
testDriverLock
(
privconn
);
...
@@ -1615,6 +1732,9 @@ static int testDomainUndefine(virDomainPtr domain) {
...
@@ -1615,6 +1732,9 @@ static int testDomainUndefine(virDomainPtr domain) {
}
}
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
privdom
->
state
=
VIR_DOMAIN_SHUTOFF
;
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_UNDEFINED
,
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED
);
virDomainRemoveInactive
(
&
privconn
->
domains
,
virDomainRemoveInactive
(
&
privconn
->
domains
,
privdom
);
privdom
);
privdom
=
NULL
;
privdom
=
NULL
;
...
@@ -1623,6 +1743,8 @@ static int testDomainUndefine(virDomainPtr domain) {
...
@@ -1623,6 +1743,8 @@ static int testDomainUndefine(virDomainPtr domain) {
cleanup:
cleanup:
if
(
privdom
)
if
(
privdom
)
virDomainObjUnlock
(
privdom
);
virDomainObjUnlock
(
privdom
);
if
(
event
)
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
testDriverUnlock
(
privconn
);
return
ret
;
return
ret
;
}
}
...
@@ -3255,6 +3377,103 @@ static int testDevMonClose(virConnectPtr conn) {
...
@@ -3255,6 +3377,103 @@ static int testDevMonClose(virConnectPtr conn) {
}
}
static
int
testDomainEventRegister
(
virConnectPtr
conn
,
virConnectDomainEventCallback
callback
,
void
*
opaque
,
virFreeCallback
freecb
)
{
testConnPtr
driver
=
conn
->
privateData
;
int
ret
;
testDriverLock
(
driver
);
ret
=
virDomainEventCallbackListAdd
(
conn
,
driver
->
domainEventCallbacks
,
callback
,
opaque
,
freecb
);
testDriverUnlock
(
driver
);
return
ret
;
}
static
int
testDomainEventDeregister
(
virConnectPtr
conn
,
virConnectDomainEventCallback
callback
)
{
testConnPtr
driver
=
conn
->
privateData
;
int
ret
;
testDriverLock
(
driver
);
if
(
driver
->
domainEventDispatching
)
ret
=
virDomainEventCallbackListMarkDelete
(
conn
,
driver
->
domainEventCallbacks
,
callback
);
else
ret
=
virDomainEventCallbackListRemove
(
conn
,
driver
->
domainEventCallbacks
,
callback
);
testDriverUnlock
(
driver
);
return
ret
;
}
static
void
testDomainEventDispatchFunc
(
virConnectPtr
conn
,
virDomainEventPtr
event
,
virConnectDomainEventCallback
cb
,
void
*
cbopaque
,
void
*
opaque
)
{
testConnPtr
driver
=
opaque
;
/* Drop the lock whle dispatching, for sake of re-entrancy */
testDriverUnlock
(
driver
);
virDomainEventDispatchDefaultFunc
(
conn
,
event
,
cb
,
cbopaque
,
NULL
);
testDriverLock
(
driver
);
}
static
void
testDomainEventFlush
(
int
timer
ATTRIBUTE_UNUSED
,
void
*
opaque
)
{
testConnPtr
driver
=
opaque
;
virDomainEventQueue
tempQueue
;
testDriverLock
(
driver
);
driver
->
domainEventDispatching
=
1
;
/* 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
);
}
/* driver must be locked before calling */
static
void
testDomainEventQueue
(
testConnPtr
driver
,
virDomainEventPtr
event
)
{
if
(
driver
->
domainEventTimer
<
0
)
{
virDomainEventFree
(
event
);
return
;
}
if
(
virDomainEventQueuePush
(
driver
->
domainEventQueue
,
event
)
<
0
)
virDomainEventFree
(
event
);
if
(
driver
->
domainEventQueue
->
count
==
1
)
virEventUpdateTimeout
(
driver
->
domainEventTimer
,
0
);
}
static
virDriver
testDriver
=
{
static
virDriver
testDriver
=
{
VIR_DRV_TEST
,
VIR_DRV_TEST
,
"Test"
,
"Test"
,
...
@@ -3313,8 +3532,8 @@ static virDriver testDriver = {
...
@@ -3313,8 +3532,8 @@ static virDriver testDriver = {
NULL
,
/* domainMemoryPeek */
NULL
,
/* domainMemoryPeek */
testNodeGetCellsFreeMemory
,
/* nodeGetCellsFreeMemory */
testNodeGetCellsFreeMemory
,
/* nodeGetCellsFreeMemory */
NULL
,
/* getFreeMemory */
NULL
,
/* getFreeMemory */
NULL
,
/* domainEventRegister */
testDomainEventRegister
,
/* domainEventRegister */
NULL
,
/* domainEventDeregister */
testDomainEventDeregister
,
/* domainEventDeregister */
NULL
,
/* domainMigratePrepare2 */
NULL
,
/* domainMigratePrepare2 */
NULL
,
/* domainMigrateFinish2 */
NULL
,
/* domainMigrateFinish2 */
};
};
...
...
tests/read-bufsiz
浏览文件 @
a888b22c
...
@@ -21,6 +21,9 @@ if test "$VERBOSE" = yes; then
...
@@ -21,6 +21,9 @@ if test "$VERBOSE" = yes; then
virsh
--version
virsh
--version
fi
fi
test
-z
"
$srcdir
"
&&
srcdir
=
`
pwd
`
test
-z
"
$abs_top_srcdir
"
&&
abs_top_srcdir
=
`
pwd
`
/..
.
$srcdir
/test-lib.sh
.
$srcdir
/test-lib.sh
fail
=
0
fail
=
0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录