Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
1daa4ba3
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看板
提交
1daa4ba3
编写于
1月 18, 2013
作者:
P
Peter Krempa
3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh-volume: Update volume commands to use vshCommandOptStringReq
上级
98007c81
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
41 deletion
+28
-41
tools/virsh-volume.c
tools/virsh-volume.c
+28
-41
未找到文件。
tools/virsh-volume.c
浏览文件 @
1daa4ba3
...
@@ -52,13 +52,12 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
...
@@ -52,13 +52,12 @@ vshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
const
char
*
n
=
NULL
,
*
p
=
NULL
;
const
char
*
n
=
NULL
,
*
p
=
NULL
;
virCheckFlags
(
VSH_BYUUID
|
VSH_BYNAME
,
NULL
);
virCheckFlags
(
VSH_BYUUID
|
VSH_BYNAME
,
NULL
);
if
(
vshCommandOptString
(
cmd
,
optname
,
&
n
)
<=
0
)
if
(
vshCommandOptString
Req
(
ctl
,
cmd
,
optname
,
&
n
)
<
0
)
return
NULL
;
return
NULL
;
if
(
pooloptname
!=
NULL
&&
vshCommandOptString
(
cmd
,
pooloptname
,
&
p
)
<
0
)
{
if
(
pooloptname
!=
NULL
&&
vsh
Error
(
ctl
,
"%s"
,
_
(
"missing option"
));
vsh
CommandOptStringReq
(
ctl
,
cmd
,
pooloptname
,
&
p
)
<
0
)
return
NULL
;
return
NULL
;
}
if
(
p
)
if
(
p
)
pool
=
vshCommandOptPoolBy
(
ctl
,
cmd
,
pooloptname
,
name
,
flags
);
pool
=
vshCommandOptPoolBy
(
ctl
,
cmd
,
pooloptname
,
name
,
flags
);
...
@@ -182,10 +181,10 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
...
@@ -182,10 +181,10 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
VSH_BYNAME
)))
VSH_BYNAME
)))
return
false
;
return
false
;
if
(
vshCommandOptString
(
cmd
,
"name"
,
&
name
)
<=
0
)
if
(
vshCommandOptString
Req
(
ctl
,
cmd
,
"name"
,
&
name
)
<
0
)
goto
cleanup
;
goto
cleanup
;
if
(
vshCommandOptString
(
cmd
,
"capacity"
,
&
capacityStr
)
<=
0
)
if
(
vshCommandOptString
Req
(
ctl
,
cmd
,
"capacity"
,
&
capacityStr
)
<
0
)
goto
cleanup
;
goto
cleanup
;
if
(
vshVolSize
(
capacityStr
,
&
capacity
)
<
0
)
{
if
(
vshVolSize
(
capacityStr
,
&
capacity
)
<
0
)
{
...
@@ -199,14 +198,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
...
@@ -199,14 +198,11 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
goto
cleanup
;
}
}
if
(
vshCommandOptString
(
cmd
,
"format"
,
&
format
)
<
0
||
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"format"
,
&
format
)
<
0
||
vshCommandOptString
(
cmd
,
"backing-vol"
,
&
snapshotStrVol
)
<
0
||
vshCommandOptStringReq
(
ctl
,
cmd
,
"backing-vol"
,
&
snapshotStrVol
)
<
0
||
vshCommandOptString
(
cmd
,
"backing-vol-format"
,
vshCommandOptStringReq
(
ctl
,
cmd
,
"backing-vol-format"
,
&
snapshotStrFormat
)
<
0
)
{
&
snapshotStrFormat
)
<
0
)
vshError
(
ctl
,
"%s"
,
_
(
"missing argument"
));
goto
cleanup
;
goto
cleanup
;
}
virBufferAddLit
(
&
buf
,
"<volume>
\n
"
);
virBufferAddLit
(
&
buf
,
"<volume>
\n
"
);
virBufferAsprintf
(
&
buf
,
" <name>%s</name>
\n
"
,
name
);
virBufferAsprintf
(
&
buf
,
" <name>%s</name>
\n
"
,
name
);
...
@@ -340,9 +336,9 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
...
@@ -340,9 +336,9 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
virStoragePoolPtr
pool
;
virStoragePoolPtr
pool
;
virStorageVolPtr
vol
;
virStorageVolPtr
vol
;
const
char
*
from
=
NULL
;
const
char
*
from
=
NULL
;
bool
ret
=
tru
e
;
bool
ret
=
fals
e
;
unsigned
int
flags
=
0
;
unsigned
int
flags
=
0
;
char
*
buffer
;
char
*
buffer
=
NULL
;
if
(
vshCommandOptBool
(
cmd
,
"prealloc-metadata"
))
if
(
vshCommandOptBool
(
cmd
,
"prealloc-metadata"
))
flags
|=
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
;
flags
|=
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
;
...
@@ -350,29 +346,26 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
...
@@ -350,29 +346,26 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
VSH_BYNAME
)))
VSH_BYNAME
)))
return
false
;
return
false
;
if
(
vshCommandOptString
(
cmd
,
"file"
,
&
from
)
<=
0
)
{
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"file"
,
&
from
)
<
0
)
virStoragePoolFree
(
pool
);
goto
cleanup
;
return
false
;
}
if
(
virFileReadAll
(
from
,
VSH_MAX_XML_FILE
,
&
buffer
)
<
0
)
{
if
(
virFileReadAll
(
from
,
VSH_MAX_XML_FILE
,
&
buffer
)
<
0
)
{
vshReportError
(
ctl
);
vshSaveLibvirtError
();
virStoragePoolFree
(
pool
);
goto
cleanup
;
return
false
;
}
}
vol
=
virStorageVolCreateXML
(
pool
,
buffer
,
flags
);
if
((
vol
=
virStorageVolCreateXML
(
pool
,
buffer
,
flags
)))
{
VIR_FREE
(
buffer
);
virStoragePoolFree
(
pool
);
if
(
vol
!=
NULL
)
{
vshPrint
(
ctl
,
_
(
"Vol %s created from %s
\n
"
),
vshPrint
(
ctl
,
_
(
"Vol %s created from %s
\n
"
),
virStorageVolGetName
(
vol
),
from
);
virStorageVolGetName
(
vol
),
from
);
virStorageVolFree
(
vol
);
virStorageVolFree
(
vol
);
ret
=
true
;
}
else
{
}
else
{
vshError
(
ctl
,
_
(
"Failed to create vol from %s"
),
from
);
vshError
(
ctl
,
_
(
"Failed to create vol from %s"
),
from
);
ret
=
false
;
}
}
cleanup:
VIR_FREE
(
buffer
);
virStoragePoolFree
(
pool
);
return
ret
;
return
ret
;
}
}
...
@@ -429,9 +422,9 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
...
@@ -429,9 +422,9 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
if
(
vshCommandOptBool
(
cmd
,
"prealloc-metadata"
))
if
(
vshCommandOptBool
(
cmd
,
"prealloc-metadata"
))
flags
|=
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
;
flags
|=
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
;
if
(
vshCommandOptString
(
cmd
,
"file"
,
&
from
)
<=
0
)
{
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"file"
,
&
from
)
<
0
)
goto
cleanup
;
goto
cleanup
;
}
if
(
!
(
inputvol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"inputpool"
,
NULL
)))
if
(
!
(
inputvol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"inputpool"
,
NULL
)))
goto
cleanup
;
goto
cleanup
;
...
@@ -548,7 +541,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
...
@@ -548,7 +541,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
goto
cleanup
;
}
}
if
(
vshCommandOptString
(
cmd
,
"newname"
,
&
name
)
<=
0
)
if
(
vshCommandOptString
Req
(
ctl
,
cmd
,
"newname"
,
&
name
)
<
0
)
goto
cleanup
;
goto
cleanup
;
origxml
=
virStorageVolGetXMLDesc
(
origvol
,
0
);
origxml
=
virStorageVolGetXMLDesc
(
origvol
,
0
);
...
@@ -658,10 +651,8 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
...
@@ -658,10 +651,8 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
return
false
;
return
false
;
}
}
if
(
vshCommandOptString
(
cmd
,
"file"
,
&
file
)
<
0
)
{
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"file"
,
&
file
)
<
0
)
vshError
(
ctl
,
_
(
"file must not be empty"
));
goto
cleanup
;
goto
cleanup
;
}
if
((
fd
=
open
(
file
,
O_RDONLY
))
<
0
)
{
if
((
fd
=
open
(
file
,
O_RDONLY
))
<
0
)
{
vshError
(
ctl
,
_
(
"cannot read %s"
),
file
);
vshError
(
ctl
,
_
(
"cannot read %s"
),
file
);
...
@@ -764,10 +755,8 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
...
@@ -764,10 +755,8 @@ cmdVolDownload(vshControl *ctl, const vshCmd *cmd)
if
(
!
(
vol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"pool"
,
&
name
)))
if
(
!
(
vol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"pool"
,
&
name
)))
return
false
;
return
false
;
if
(
vshCommandOptString
(
cmd
,
"file"
,
&
file
)
<
0
)
{
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"file"
,
&
file
)
<
0
)
vshError
(
ctl
,
_
(
"file must not be empty"
));
goto
cleanup
;
goto
cleanup
;
}
if
((
fd
=
open
(
file
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0666
))
<
0
)
{
if
((
fd
=
open
(
file
,
O_WRONLY
|
O_CREAT
|
O_EXCL
,
0666
))
<
0
)
{
if
(
errno
!=
EEXIST
||
if
(
errno
!=
EEXIST
||
...
@@ -906,10 +895,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
...
@@ -906,10 +895,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd)
return
false
;
return
false
;
}
}
if
(
vshCommandOptString
(
cmd
,
"algorithm"
,
&
algorithm_str
)
<
0
)
{
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"algorithm"
,
&
algorithm_str
)
<
0
)
vshError
(
ctl
,
"%s"
,
_
(
"missing argument"
));
goto
out
;
goto
out
;
}
if
(
algorithm_str
&&
if
(
algorithm_str
&&
(
algorithm
=
virStorageVolWipeAlgorithmTypeFromString
(
algorithm_str
))
<
0
)
{
(
algorithm
=
virStorageVolWipeAlgorithmTypeFromString
(
algorithm_str
))
<
0
)
{
...
@@ -1072,7 +1059,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
...
@@ -1072,7 +1059,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
if
(
!
(
vol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"pool"
,
NULL
)))
if
(
!
(
vol
=
vshCommandOptVol
(
ctl
,
cmd
,
"vol"
,
"pool"
,
NULL
)))
return
false
;
return
false
;
if
(
vshCommandOptString
(
cmd
,
"capacity"
,
&
capacityStr
)
<=
0
)
if
(
vshCommandOptString
Req
(
ctl
,
cmd
,
"capacity"
,
&
capacityStr
)
<=
0
)
goto
cleanup
;
goto
cleanup
;
virSkipSpaces
(
&
capacityStr
);
virSkipSpaces
(
&
capacityStr
);
if
(
*
capacityStr
==
'-'
)
{
if
(
*
capacityStr
==
'-'
)
{
...
...
tester丶
🤺
@ssszwink
mentioned in commit
8a7dbdc3
·
9月 10, 2020
mentioned in commit
8a7dbdc3
mentioned in commit 8a7dbdc34435301be520f4a5fd4a7e416fc1d20d
开关提交列表
tester丶
🤺
@ssszwink
mentioned in commit
692474e6
·
9月 10, 2020
mentioned in commit
692474e6
mentioned in commit 692474e6085d05a49c6b842de99f453c54c71902
开关提交列表
tester丶
🤺
@ssszwink
mentioned in commit
729bd0a3
·
9月 10, 2020
mentioned in commit
729bd0a3
mentioned in commit 729bd0a37adbb20472500ab090c99ac684697fa0
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录