Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
670e86bf
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,体验更适合开发者的 AI 搜索 >>
提交
670e86bf
编写于
8月 21, 2013
作者:
C
Cole Robinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: snapshot: Break out redefine preparation to shared function
上级
390c06b6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
160 addition
and
129 deletion
+160
-129
src/conf/snapshot_conf.c
src/conf/snapshot_conf.c
+150
-0
src/conf/snapshot_conf.h
src/conf/snapshot_conf.h
+7
-0
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+2
-129
未找到文件。
src/conf/snapshot_conf.c
浏览文件 @
670e86bf
...
...
@@ -1099,3 +1099,153 @@ virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap)
{
return
virDomainSnapshotDefIsExternal
(
snap
->
def
);
}
int
virDomainSnapshotRedefinePrep
(
virDomainPtr
domain
,
virDomainObjPtr
vm
,
virDomainSnapshotDefPtr
*
defptr
,
virDomainSnapshotObjPtr
*
snap
,
bool
*
update_current
,
unsigned
int
flags
)
{
virDomainSnapshotDefPtr
def
=
*
defptr
;
int
ret
=
-
1
;
int
align_location
=
VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL
;
int
align_match
=
true
;
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
virDomainSnapshotObjPtr
other
;
virUUIDFormat
(
domain
->
uuid
,
uuidstr
);
/* Prevent circular chains */
if
(
def
->
parent
)
{
if
(
STREQ
(
def
->
name
,
def
->
parent
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot set snapshot %s as its own parent"
),
def
->
name
);
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
def
->
parent
);
if
(
!
other
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"parent %s for snapshot %s not found"
),
def
->
parent
,
def
->
name
);
goto
cleanup
;
}
while
(
other
->
def
->
parent
)
{
if
(
STREQ
(
other
->
def
->
parent
,
def
->
name
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"parent %s would create cycle to %s"
),
other
->
def
->
name
,
def
->
name
);
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
other
->
def
->
parent
);
if
(
!
other
)
{
VIR_WARN
(
"snapshots are inconsistent for %s"
,
vm
->
def
->
name
);
break
;
}
}
}
/* Check that any replacement is compatible */
if
((
flags
&
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
)
&&
def
->
state
!=
VIR_DOMAIN_DISK_SNAPSHOT
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"disk-only flag for snapshot %s requires "
"disk-snapshot state"
),
def
->
name
);
goto
cleanup
;
}
if
(
def
->
dom
&&
memcmp
(
def
->
dom
->
uuid
,
domain
->
uuid
,
VIR_UUID_BUFLEN
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"definition for snapshot %s must use uuid %s"
),
def
->
name
,
uuidstr
);
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
def
->
name
);
if
(
other
)
{
if
((
other
->
def
->
state
==
VIR_DOMAIN_RUNNING
||
other
->
def
->
state
==
VIR_DOMAIN_PAUSED
)
!=
(
def
->
state
==
VIR_DOMAIN_RUNNING
||
def
->
state
==
VIR_DOMAIN_PAUSED
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot change between online and offline "
"snapshot state in snapshot %s"
),
def
->
name
);
goto
cleanup
;
}
if
((
other
->
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
)
!=
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot change between disk snapshot and "
"system checkpoint in snapshot %s"
),
def
->
name
);
goto
cleanup
;
}
if
(
other
->
def
->
dom
)
{
if
(
def
->
dom
)
{
if
(
!
virDomainDefCheckABIStability
(
other
->
def
->
dom
,
def
->
dom
))
goto
cleanup
;
}
else
{
/* Transfer the domain def */
def
->
dom
=
other
->
def
->
dom
;
other
->
def
->
dom
=
NULL
;
}
}
if
(
def
->
dom
)
{
if
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
||
virDomainSnapshotDefIsExternal
(
def
))
{
align_location
=
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
;
align_match
=
false
;
}
if
(
virDomainSnapshotAlignDisks
(
def
,
align_location
,
align_match
)
<
0
)
{
/* revert stealing of the snapshot domain definition */
if
(
def
->
dom
&&
!
other
->
def
->
dom
)
{
other
->
def
->
dom
=
def
->
dom
;
def
->
dom
=
NULL
;
}
goto
cleanup
;
}
}
if
(
other
==
vm
->
current_snapshot
)
{
*
update_current
=
true
;
vm
->
current_snapshot
=
NULL
;
}
/* Drop and rebuild the parent relationship, but keep all
* child relations by reusing snap. */
virDomainSnapshotDropParent
(
other
);
virDomainSnapshotDefFree
(
other
->
def
);
other
->
def
=
def
;
*
defptr
=
NULL
;
*
snap
=
other
;
}
else
{
if
(
def
->
dom
)
{
if
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
||
def
->
memory
==
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
)
{
align_location
=
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
;
align_match
=
false
;
}
if
(
virDomainSnapshotAlignDisks
(
def
,
align_location
,
align_match
)
<
0
)
goto
cleanup
;
}
}
ret
=
0
;
cleanup:
return
ret
;
}
src/conf/snapshot_conf.h
浏览文件 @
670e86bf
...
...
@@ -176,6 +176,13 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots,
bool
virDomainSnapshotDefIsExternal
(
virDomainSnapshotDefPtr
def
);
bool
virDomainSnapshotIsExternal
(
virDomainSnapshotObjPtr
snap
);
int
virDomainSnapshotRedefinePrep
(
virDomainPtr
domain
,
virDomainObjPtr
vm
,
virDomainSnapshotDefPtr
*
def
,
virDomainSnapshotObjPtr
*
snap
,
bool
*
update_current
,
unsigned
int
flags
);
VIR_ENUM_DECL
(
virDomainSnapshotLocation
)
VIR_ENUM_DECL
(
virDomainSnapshotState
)
...
...
src/libvirt_private.syms
浏览文件 @
670e86bf
...
...
@@ -652,6 +652,7 @@ virDomainSnapshotLocationTypeToString;
virDomainSnapshotObjListGetNames;
virDomainSnapshotObjListNum;
virDomainSnapshotObjListRemove;
virDomainSnapshotRedefinePrep;
virDomainSnapshotStateTypeFromString;
virDomainSnapshotStateTypeToString;
virDomainSnapshotUpdateRelations;
...
...
src/qemu/qemu_driver.c
浏览文件 @
670e86bf
...
...
@@ -12272,7 +12272,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
char
*
xml
=
NULL
;
virDomainSnapshotObjPtr
snap
=
NULL
;
virDomainSnapshotPtr
snapshot
=
NULL
;
char
uuidstr
[
VIR_UUID_STRING_BUFLEN
];
virDomainSnapshotDefPtr
def
=
NULL
;
bool
update_current
=
true
;
bool
redefine
=
flags
&
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
;
...
...
@@ -12306,8 +12305,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
if
(
redefine
)
parse_flags
|=
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE
;
virUUIDFormat
(
domain
->
uuid
,
uuidstr
);
if
(
!
(
vm
=
qemuDomObjFromDomain
(
domain
)))
goto
cleanup
;
...
...
@@ -12376,133 +12373,9 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
}
if
(
redefine
)
{
/* Prevent circular chains */
if
(
def
->
parent
)
{
if
(
STREQ
(
def
->
name
,
def
->
parent
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot set snapshot %s as its own parent"
),
def
->
name
);
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
def
->
parent
);
if
(
!
other
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"parent %s for snapshot %s not found"
),
def
->
parent
,
def
->
name
);
goto
cleanup
;
}
while
(
other
->
def
->
parent
)
{
if
(
STREQ
(
other
->
def
->
parent
,
def
->
name
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"parent %s would create cycle to %s"
),
other
->
def
->
name
,
def
->
name
);
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
other
->
def
->
parent
);
if
(
!
other
)
{
VIR_WARN
(
"snapshots are inconsistent for %s"
,
vm
->
def
->
name
);
break
;
}
}
}
/* Check that any replacement is compatible */
if
((
flags
&
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
)
&&
def
->
state
!=
VIR_DOMAIN_DISK_SNAPSHOT
)
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"disk-only flag for snapshot %s requires "
"disk-snapshot state"
),
def
->
name
);
goto
cleanup
;
}
if
(
def
->
dom
&&
memcmp
(
def
->
dom
->
uuid
,
domain
->
uuid
,
VIR_UUID_BUFLEN
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"definition for snapshot %s must use uuid %s"
),
def
->
name
,
uuidstr
);
if
(
!
virDomainSnapshotRedefinePrep
(
domain
,
vm
,
&
def
,
&
snap
,
&
update_current
,
flags
)
<
0
)
goto
cleanup
;
}
other
=
virDomainSnapshotFindByName
(
vm
->
snapshots
,
def
->
name
);
if
(
other
)
{
if
((
other
->
def
->
state
==
VIR_DOMAIN_RUNNING
||
other
->
def
->
state
==
VIR_DOMAIN_PAUSED
)
!=
(
def
->
state
==
VIR_DOMAIN_RUNNING
||
def
->
state
==
VIR_DOMAIN_PAUSED
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot change between online and offline "
"snapshot state in snapshot %s"
),
def
->
name
);
goto
cleanup
;
}
if
((
other
->
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
)
!=
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
))
{
virReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"cannot change between disk snapshot and "
"system checkpoint in snapshot %s"
),
def
->
name
);
goto
cleanup
;
}
if
(
other
->
def
->
dom
)
{
if
(
def
->
dom
)
{
if
(
!
virDomainDefCheckABIStability
(
other
->
def
->
dom
,
def
->
dom
))
goto
cleanup
;
}
else
{
/* Transfer the domain def */
def
->
dom
=
other
->
def
->
dom
;
other
->
def
->
dom
=
NULL
;
}
}
if
(
def
->
dom
)
{
if
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
||
virDomainSnapshotDefIsExternal
(
def
))
{
align_location
=
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
;
align_match
=
false
;
}
if
(
virDomainSnapshotAlignDisks
(
def
,
align_location
,
align_match
)
<
0
)
{
/* revert stealing of the snapshot domain definition */
if
(
def
->
dom
&&
!
other
->
def
->
dom
)
{
other
->
def
->
dom
=
def
->
dom
;
def
->
dom
=
NULL
;
}
goto
cleanup
;
}
}
if
(
other
==
vm
->
current_snapshot
)
{
update_current
=
true
;
vm
->
current_snapshot
=
NULL
;
}
/* Drop and rebuild the parent relationship, but keep all
* child relations by reusing snap. */
virDomainSnapshotDropParent
(
other
);
virDomainSnapshotDefFree
(
other
->
def
);
other
->
def
=
def
;
def
=
NULL
;
snap
=
other
;
}
else
{
if
(
def
->
dom
)
{
if
(
def
->
state
==
VIR_DOMAIN_DISK_SNAPSHOT
||
def
->
memory
==
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
)
{
align_location
=
VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL
;
align_match
=
false
;
}
if
(
virDomainSnapshotAlignDisks
(
def
,
align_location
,
align_match
)
<
0
)
goto
cleanup
;
}
}
}
else
{
/* Easiest way to clone inactive portion of vm->def is via
* conversion in and back out of xml. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录