Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
25314fa6
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看板
提交
25314fa6
编写于
8月 06, 2013
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: Wire up managed save APIs
Also add a <test:hasmanagedsave> element to set this data when starting the connection.
上级
d82ea6ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
135 addition
and
2 deletion
+135
-2
src/test/test_driver.c
src/test/test_driver.c
+134
-1
tests/virshtest.c
tests/virshtest.c
+1
-1
未找到文件。
src/test/test_driver.c
浏览文件 @
25314fa6
...
...
@@ -160,6 +160,7 @@ typedef testDomainNamespaceDef *testDomainNamespaceDefPtr;
struct
_testDomainNamespaceDef
{
int
runstate
;
bool
transient
;
bool
hasManagedSave
;
};
static
void
...
...
@@ -197,6 +198,13 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
}
nsdata
->
transient
=
tmp
;
tmp
=
virXPathBoolean
(
"boolean(./test:hasmanagedsave)"
,
ctxt
);
if
(
tmp
==
-
1
)
{
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"invalid hasmanagedsave"
));
goto
error
;
}
nsdata
->
hasManagedSave
=
tmp
;
tmp
=
virXPathUInt
(
"string(./test:runstate)"
,
ctxt
,
&
tmpuint
);
if
(
tmp
==
0
)
{
if
(
tmpuint
>=
VIR_DOMAIN_LAST
)
{
...
...
@@ -218,6 +226,11 @@ testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
_
(
"transient domain cannot have runstate 'shutoff'"
));
goto
error
;
}
if
(
nsdata
->
hasManagedSave
&&
nsdata
->
runstate
!=
VIR_DOMAIN_SHUTOFF
)
{
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"domain with managedsave data can only have runstate 'shutoff'"
));
goto
error
;
}
*
data
=
nsdata
;
return
0
;
...
...
@@ -588,6 +601,7 @@ testDomainStartState(testConnPtr privconn,
goto
cleanup
;
}
dom
->
hasManagedSave
=
false
;
ret
=
0
;
cleanup:
if
(
ret
<
0
)
...
...
@@ -937,6 +951,7 @@ testParseDomains(testConnPtr privconn,
nsdata
=
def
->
namespaceData
;
obj
->
persistent
=
!
nsdata
->
transient
;
obj
->
hasManagedSave
=
nsdata
->
hasManagedSave
;
if
(
nsdata
->
runstate
!=
VIR_DOMAIN_SHUTOFF
)
{
if
(
testDomainStartState
(
privconn
,
obj
,
...
...
@@ -2825,7 +2840,7 @@ static int testDomainUndefineFlags(virDomainPtr domain,
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
virCheckFlags
(
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE
,
-
1
);
testDriverLock
(
privconn
);
privdom
=
virDomainObjListFindByName
(
privconn
->
domains
,
...
...
@@ -2836,9 +2851,19 @@ static int testDomainUndefineFlags(virDomainPtr domain,
goto
cleanup
;
}
if
(
privdom
->
hasManagedSave
&&
!
(
flags
&
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"Refusing to undefine while domain managed "
"save image exists"
));
goto
cleanup
;
}
event
=
virDomainEventNewFromObj
(
privdom
,
VIR_DOMAIN_EVENT_UNDEFINED
,
VIR_DOMAIN_EVENT_UNDEFINED_REMOVED
);
privdom
->
hasManagedSave
=
false
;
if
(
virDomainObjIsActive
(
privdom
))
{
privdom
->
persistent
=
0
;
}
else
{
...
...
@@ -5969,6 +5994,111 @@ testConnectGetCPUModelNames(virConnectPtr conn ATTRIBUTE_UNUSED,
return
cpuGetModels
(
arch
,
models
);
}
static
int
testDomainManagedSave
(
virDomainPtr
dom
,
unsigned
int
flags
)
{
testConnPtr
privconn
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
=
NULL
;
virDomainEventPtr
event
=
NULL
;
int
ret
=
-
1
;
virCheckFlags
(
VIR_DOMAIN_SAVE_BYPASS_CACHE
|
VIR_DOMAIN_SAVE_RUNNING
|
VIR_DOMAIN_SAVE_PAUSED
,
-
1
);
testDriverLock
(
privconn
);
vm
=
virDomainObjListFindByName
(
privconn
->
domains
,
dom
->
name
);
testDriverUnlock
(
privconn
);
if
(
vm
==
NULL
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
cleanup
;
}
if
(
!
virDomainObjIsActive
(
vm
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"domain is not running"
));
goto
cleanup
;
}
if
(
!
vm
->
persistent
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot do managed save for transient domain"
));
goto
cleanup
;
}
testDomainShutdownState
(
dom
,
vm
,
VIR_DOMAIN_SHUTOFF_SAVED
);
event
=
virDomainEventNewFromObj
(
vm
,
VIR_DOMAIN_EVENT_STOPPED
,
VIR_DOMAIN_EVENT_STOPPED_SAVED
);
vm
->
hasManagedSave
=
true
;
ret
=
0
;
cleanup:
if
(
vm
)
virObjectUnlock
(
vm
);
if
(
event
)
{
testDriverLock
(
privconn
);
testDomainEventQueue
(
privconn
,
event
);
testDriverUnlock
(
privconn
);
}
return
ret
;
}
static
int
testDomainHasManagedSaveImage
(
virDomainPtr
dom
,
unsigned
int
flags
)
{
testConnPtr
privconn
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
testDriverLock
(
privconn
);
vm
=
virDomainObjListFindByName
(
privconn
->
domains
,
dom
->
name
);
if
(
vm
==
NULL
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
cleanup
;
}
ret
=
vm
->
hasManagedSave
;
cleanup:
if
(
vm
)
virObjectUnlock
(
vm
);
testDriverUnlock
(
privconn
);
return
ret
;
}
static
int
testDomainManagedSaveRemove
(
virDomainPtr
dom
,
unsigned
int
flags
)
{
testConnPtr
privconn
=
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
testDriverLock
(
privconn
);
vm
=
virDomainObjListFindByName
(
privconn
->
domains
,
dom
->
name
);
if
(
vm
==
NULL
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
__FUNCTION__
);
goto
cleanup
;
}
vm
->
hasManagedSave
=
false
;
ret
=
0
;
cleanup:
if
(
vm
)
virObjectUnlock
(
vm
);
testDriverUnlock
(
privconn
);
return
ret
;
}
static
virDriver
testDriver
=
{
.
no
=
VIR_DRV_TEST
,
.
name
=
"Test"
,
...
...
@@ -6042,6 +6172,9 @@ static virDriver testDriver = {
.
domainGetMetadata
=
testDomainGetMetadata
,
/* 1.1.3 */
.
domainSetMetadata
=
testDomainSetMetadata
,
/* 1.1.3 */
.
connectGetCPUModelNames
=
testConnectGetCPUModelNames
,
/* 1.1.3 */
.
domainManagedSave
=
testDomainManagedSave
,
/* 1.1.3 */
.
domainHasManagedSaveImage
=
testDomainHasManagedSaveImage
,
/* 1.1.3 */
.
domainManagedSaveRemove
=
testDomainManagedSaveRemove
,
/* 1.1.3 */
};
static
virNetworkDriver
testNetworkDriver
=
{
...
...
tests/virshtest.c
浏览文件 @
25314fa6
...
...
@@ -34,7 +34,7 @@ Max memory: 261072 KiB\n\
Used memory: 131072 KiB
\n
\
Persistent: yes
\n
\
Autostart: disable
\n
\
Managed save:
unknown
\n
\
Managed save:
no
\n
\
\n
"
;
static
const
char
*
domuuid_fc4
=
DOM_UUID
"
\n\n
"
;
static
const
char
*
domid_fc4
=
"2
\n\n
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录