Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
a9725126
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,发现更多精彩内容 >>
提交
a9725126
编写于
8月 11, 2014
作者:
T
Taowei
提交者:
Michal Privoznik
8月 15, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vbox: Rewrite vboxDomainRevertToSnapshot
上级
410b2183
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
77 deletion
+74
-77
src/vbox/vbox_common.c
src/vbox/vbox_common.c
+68
-0
src/vbox/vbox_tmpl.c
src/vbox/vbox_tmpl.c
+3
-77
src/vbox/vbox_uniformed_api.h
src/vbox/vbox_uniformed_api.h
+3
-0
未找到文件。
src/vbox/vbox_common.c
浏览文件 @
a9725126
...
...
@@ -6444,3 +6444,71 @@ int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
vboxIIDUnalloc
(
&
iid
);
return
ret
;
}
int
vboxDomainRevertToSnapshot
(
virDomainSnapshotPtr
snapshot
,
unsigned
int
flags
)
{
virDomainPtr
dom
=
snapshot
->
domain
;
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
vboxIIDUnion
domiid
;
IMachine
*
machine
=
NULL
;
ISnapshot
*
newSnapshot
=
NULL
;
ISnapshot
*
prevSnapshot
=
NULL
;
PRBool
online
=
PR_FALSE
;
PRUint32
state
;
nsresult
rc
;
virCheckFlags
(
0
,
-
1
);
if
(
openSessionForMachine
(
data
,
dom
->
uuid
,
&
domiid
,
&
machine
,
false
)
<
0
)
goto
cleanup
;
newSnapshot
=
vboxDomainSnapshotGet
(
data
,
dom
,
machine
,
snapshot
->
name
);
if
(
!
newSnapshot
)
goto
cleanup
;
rc
=
gVBoxAPI
.
UISnapshot
.
GetOnline
(
newSnapshot
,
&
online
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not get online state of snapshot %s"
),
snapshot
->
name
);
goto
cleanup
;
}
rc
=
gVBoxAPI
.
UIMachine
.
GetCurrentSnapshot
(
machine
,
&
prevSnapshot
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not get current snapshot of domain %s"
),
dom
->
name
);
goto
cleanup
;
}
rc
=
gVBoxAPI
.
UIMachine
.
GetState
(
machine
,
&
state
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"could not get domain state"
));
goto
cleanup
;
}
if
(
gVBoxAPI
.
machineStateChecker
.
Online
(
state
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot revert snapshot of running domain"
));
goto
cleanup
;
}
if
(
gVBoxAPI
.
snapshotRestore
(
dom
,
machine
,
newSnapshot
))
goto
cleanup
;
if
(
online
)
{
ret
=
vboxDomainCreate
(
dom
);
if
(
!
ret
)
gVBoxAPI
.
snapshotRestore
(
dom
,
machine
,
prevSnapshot
);
}
else
ret
=
0
;
cleanup:
VBOX_RELEASE
(
prevSnapshot
);
VBOX_RELEASE
(
newSnapshot
);
vboxIIDUnalloc
(
&
domiid
);
return
ret
;
}
src/vbox/vbox_tmpl.c
浏览文件 @
a9725126
...
...
@@ -1525,7 +1525,7 @@ vboxDomainSnapshotGet(vboxGlobalData *data,
#if VBOX_API_VERSION < 3001000
static
int
vboxDomainSnapshotRestore
(
virDomainPtr
dom
,
_
vboxDomainSnapshotRestore
(
virDomainPtr
dom
,
IMachine
*
machine
,
ISnapshot
*
snapshot
)
{
...
...
@@ -1555,7 +1555,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
}
#else
static
int
vboxDomainSnapshotRestore
(
virDomainPtr
dom
,
_
vboxDomainSnapshotRestore
(
virDomainPtr
dom
,
IMachine
*
machine
,
ISnapshot
*
snapshot
)
{
...
...
@@ -1630,81 +1630,6 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
}
#endif
static
int
vboxDomainRevertToSnapshot
(
virDomainSnapshotPtr
snapshot
,
unsigned
int
flags
)
{
virDomainPtr
dom
=
snapshot
->
domain
;
VBOX_OBJECT_CHECK
(
dom
->
conn
,
int
,
-
1
);
vboxIID
domiid
=
VBOX_IID_INITIALIZER
;
IMachine
*
machine
=
NULL
;
ISnapshot
*
newSnapshot
=
NULL
;
ISnapshot
*
prevSnapshot
=
NULL
;
PRBool
online
=
PR_FALSE
;
PRUint32
state
;
nsresult
rc
;
virCheckFlags
(
0
,
-
1
);
vboxIIDFromUUID
(
&
domiid
,
dom
->
uuid
);
rc
=
VBOX_OBJECT_GET_MACHINE
(
domiid
.
value
,
&
machine
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_NO_DOMAIN
,
"%s"
,
_
(
"no domain with matching UUID"
));
goto
cleanup
;
}
newSnapshot
=
vboxDomainSnapshotGet
(
data
,
dom
,
machine
,
snapshot
->
name
);
if
(
!
newSnapshot
)
goto
cleanup
;
rc
=
newSnapshot
->
vtbl
->
GetOnline
(
newSnapshot
,
&
online
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not get online state of snapshot %s"
),
snapshot
->
name
);
goto
cleanup
;
}
rc
=
machine
->
vtbl
->
GetCurrentSnapshot
(
machine
,
&
prevSnapshot
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"could not get current snapshot of domain %s"
),
dom
->
name
);
goto
cleanup
;
}
rc
=
machine
->
vtbl
->
GetState
(
machine
,
&
state
);
if
(
NS_FAILED
(
rc
))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"could not get domain state"
));
goto
cleanup
;
}
if
(
state
>=
MachineState_FirstOnline
&&
state
<=
MachineState_LastOnline
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
_
(
"cannot revert snapshot of running domain"
));
goto
cleanup
;
}
if
(
vboxDomainSnapshotRestore
(
dom
,
machine
,
newSnapshot
))
goto
cleanup
;
if
(
online
)
{
ret
=
vboxDomainCreate
(
dom
);
if
(
!
ret
)
vboxDomainSnapshotRestore
(
dom
,
machine
,
prevSnapshot
);
}
else
ret
=
0
;
cleanup:
VBOX_RELEASE
(
prevSnapshot
);
VBOX_RELEASE
(
newSnapshot
);
vboxIIDUnalloc
(
&
domiid
);
return
ret
;
}
static
int
vboxDomainSnapshotDeleteSingle
(
vboxGlobalData
*
data
,
IConsole
*
console
,
...
...
@@ -7493,6 +7418,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
pVBoxAPI
->
dumpFloppy
=
_dumpFloppy
;
pVBoxAPI
->
attachFloppy
=
_attachFloppy
;
pVBoxAPI
->
detachFloppy
=
_detachFloppy
;
pVBoxAPI
->
snapshotRestore
=
_vboxDomainSnapshotRestore
;
pVBoxAPI
->
UPFN
=
_UPFN
;
pVBoxAPI
->
UIID
=
_UIID
;
pVBoxAPI
->
UArray
=
_UArray
;
...
...
src/vbox/vbox_uniformed_api.h
浏览文件 @
a9725126
...
...
@@ -473,6 +473,7 @@ typedef struct {
void
(
*
dumpFloppy
)(
virDomainDefPtr
def
,
vboxGlobalData
*
data
,
IMachine
*
machine
);
int
(
*
attachFloppy
)(
vboxGlobalData
*
data
,
IMachine
*
machine
,
const
char
*
src
);
int
(
*
detachFloppy
)(
IMachine
*
machine
);
int
(
*
snapshotRestore
)(
virDomainPtr
dom
,
IMachine
*
machine
,
ISnapshot
*
snapshot
);
vboxUniformedPFN
UPFN
;
vboxUniformedIID
UIID
;
vboxUniformedArray
UArray
;
...
...
@@ -593,6 +594,8 @@ int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
unsigned
int
flags
);
int
vboxDomainSnapshotHasMetadata
(
virDomainSnapshotPtr
snapshot
,
unsigned
int
flags
);
int
vboxDomainRevertToSnapshot
(
virDomainSnapshotPtr
snapshot
,
unsigned
int
flags
);
/* Version specified functions for installing uniformed API */
void
vbox22InstallUniformedAPI
(
vboxUniformedAPI
*
pVBoxAPI
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录