Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4baf00fc
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看板
提交
4baf00fc
编写于
3月 07, 2013
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh-snapshot: Refactor cmdSnapshotCurrent
Use the exclusive parameter checker and touch up some parts to simplify code.
上级
020e2103
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
25 deletion
+21
-25
tools/virsh-snapshot.c
tools/virsh-snapshot.c
+21
-25
未找到文件。
tools/virsh-snapshot.c
浏览文件 @
4baf00fc
...
...
@@ -686,9 +686,10 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
if
(
vshCommandOptBool
(
cmd
,
"security-info"
))
flags
|=
VIR_DOMAIN_XML_SECURE
;
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
&
domname
);
if
(
dom
==
NULL
)
goto
cleanup
;
VSH_EXCLUSIVE_OPTIONS
(
"name"
,
"snapshotname"
);
if
(
!
(
dom
=
vshCommandOptDomain
(
ctl
,
cmd
,
&
domname
)))
return
false
;
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"snapshotname"
,
&
snapshotname
)
<
0
)
goto
cleanup
;
...
...
@@ -698,52 +699,48 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd)
flags
=
(
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
|
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT
);
if
(
vshCommandOptBool
(
cmd
,
"name"
))
{
vshError
(
ctl
,
"%s"
,
_
(
"--name and snapshotname are mutually exclusive"
));
goto
cleanup
;
}
snapshot
=
virDomainSnapshotLookupByName
(
dom
,
snapshotname
,
0
);
if
(
snapshot
==
NULL
)
if
(
!
(
snapshot
=
virDomainSnapshotLookupByName
(
dom
,
snapshotname
,
0
)))
goto
cleanup
;
xml
=
virDomainSnapshotGetXMLDesc
(
snapshot
,
VIR_DOMAIN_XML_SECURE
);
if
(
!
xml
)
goto
cleanup
;
/* strstr is safe here, since xml came from libvirt API and not user */
if
(
strstr
(
xml
,
"<state>disk-snapshot</state>"
))
flags
|=
VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY
;
snapshot2
=
virDomainSnapshotCreateXML
(
dom
,
xml
,
flags
);
if
(
snapshot2
==
NULL
)
if
(
!
(
snapshot2
=
virDomainSnapshotCreateXML
(
dom
,
xml
,
flags
))
)
goto
cleanup
;
virDomainSnapshotFree
(
snapshot2
);
vshPrint
(
ctl
,
_
(
"Snapshot %s set as current"
),
snapshotname
);
ret
=
true
;
goto
cleanup
;
}
current
=
virDomainHasCurrentSnapshot
(
dom
,
0
);
if
(
current
<
0
)
{
if
((
current
=
virDomainHasCurrentSnapshot
(
dom
,
0
))
<
0
)
goto
cleanup
;
}
else
if
(
!
current
)
{
if
(
!
current
)
{
vshError
(
ctl
,
_
(
"domain '%s' has no current snapshot"
),
domname
);
goto
cleanup
;
}
else
{
const
char
*
name
=
NULL
;
if
(
!
(
snapshot
=
virDomainSnapshotCurrent
(
dom
,
0
)))
goto
cleanup
;
if
(
vshCommandOptBool
(
cmd
,
"name"
))
{
name
=
virDomainSnapshotGetName
(
snapshot
)
;
if
(
!
name
)
const
char
*
name
;
if
(
!
(
name
=
virDomainSnapshotGetName
(
snapshot
))
)
goto
cleanup
;
vshPrint
(
ctl
,
"%s"
,
name
);
}
else
{
xml
=
virDomainSnapshotGetXMLDesc
(
snapshot
,
flags
);
if
(
!
xml
)
if
(
!
(
xml
=
virDomainSnapshotGetXMLDesc
(
snapshot
,
flags
)))
goto
cleanup
;
}
vshPrint
(
ctl
,
"%s"
,
name
?
name
:
xml
);
vshPrint
(
ctl
,
"%s"
,
xml
);
}
}
ret
=
true
;
...
...
@@ -754,8 +751,7 @@ cleanup:
VIR_FREE
(
xml
);
if
(
snapshot
)
virDomainSnapshotFree
(
snapshot
);
if
(
dom
)
virDomainFree
(
dom
);
virDomainFree
(
dom
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录