Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
121cf746
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看板
提交
121cf746
编写于
7月 26, 2017
作者:
J
John Ferlan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage: Use virStoragePoolObjGetDef accessor for ZFS backend
In preparation for privatizing the object, use the accessor.
上级
159f691f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
16 deletion
+23
-16
src/storage/storage_backend_zfs.c
src/storage/storage_backend_zfs.c
+23
-16
未找到文件。
src/storage/storage_backend_zfs.c
浏览文件 @
121cf746
...
...
@@ -86,10 +86,11 @@ static int
virStorageBackendZFSCheckPool
(
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
,
bool
*
isActive
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
char
*
devpath
;
if
(
virAsprintf
(
&
devpath
,
"/dev/zvol/%s"
,
pool
->
def
->
source
.
name
)
<
0
)
def
->
source
.
name
)
<
0
)
return
-
1
;
*
isActive
=
virFileIsDir
(
devpath
);
VIR_FREE
(
devpath
);
...
...
@@ -109,6 +110,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
char
*
vol_name
;
bool
is_new_vol
=
false
;
virStorageVolDefPtr
volume
=
NULL
;
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
if
(
!
(
tokens
=
virStringSplitCount
(
volume_string
,
"
\t
"
,
0
,
&
count
)))
return
-
1
;
...
...
@@ -142,7 +144,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool,
if
(
volume
->
target
.
path
==
NULL
)
{
if
(
virAsprintf
(
&
volume
->
target
.
path
,
"%s/%s"
,
pool
->
def
->
target
.
path
,
volume
->
name
)
<
0
)
def
->
target
.
path
,
volume
->
name
)
<
0
)
goto
cleanup
;
}
...
...
@@ -178,6 +180,7 @@ static int
virStorageBackendZFSFindVols
(
virStoragePoolObjPtr
pool
,
virStorageVolDefPtr
vol
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
char
*
volumes_list
=
NULL
;
char
**
lines
=
NULL
;
...
...
@@ -199,7 +202,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool,
"list"
,
"-Hp"
,
"-t"
,
"volume"
,
"-r"
,
"-o"
,
"name,volsize,refreservation"
,
pool
->
def
->
source
.
name
,
def
->
source
.
name
,
NULL
);
virCommandSetOutputBuffer
(
cmd
,
&
volumes_list
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
...
...
@@ -228,6 +231,7 @@ static int
virStorageBackendZFSRefreshPool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
char
*
zpool_props
=
NULL
;
char
**
lines
=
NULL
;
...
...
@@ -247,7 +251,7 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
cmd
=
virCommandNewArgList
(
ZPOOL
,
"get"
,
"-Hp"
,
"health,size,free,allocated"
,
pool
->
def
->
source
.
name
,
def
->
source
.
name
,
NULL
);
virCommandSetOutputBuffer
(
cmd
,
&
zpool_props
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
...
...
@@ -279,11 +283,11 @@ virStorageBackendZFSRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
goto
cleanup
;
if
(
STREQ
(
prop_name
,
"free"
))
pool
->
def
->
available
=
value
;
def
->
available
=
value
;
else
if
(
STREQ
(
prop_name
,
"size"
))
pool
->
def
->
capacity
=
value
;
def
->
capacity
=
value
;
else
if
(
STREQ
(
prop_name
,
"allocated"
))
pool
->
def
->
allocation
=
value
;
def
->
allocation
=
value
;
}
}
...
...
@@ -305,6 +309,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr
pool
,
virStorageVolDefPtr
vol
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
int
ret
=
-
1
;
int
volmode_needed
=
-
1
;
...
...
@@ -320,7 +325,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
VIR_FREE
(
vol
->
target
.
path
);
if
(
virAsprintf
(
&
vol
->
target
.
path
,
"%s/%s"
,
pool
->
def
->
target
.
path
,
vol
->
name
)
<
0
)
def
->
target
.
path
,
vol
->
name
)
<
0
)
return
-
1
;
if
(
VIR_STRDUP
(
vol
->
key
,
vol
->
target
.
path
)
<
0
)
...
...
@@ -356,8 +361,7 @@ virStorageBackendZFSCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED,
virCommandAddArg
(
cmd
,
"-V"
);
virCommandAddArgFormat
(
cmd
,
"%lluK"
,
VIR_DIV_UP
(
vol
->
target
.
capacity
,
1024
));
virCommandAddArgFormat
(
cmd
,
"%s/%s"
,
pool
->
def
->
source
.
name
,
vol
->
name
);
virCommandAddArgFormat
(
cmd
,
"%s/%s"
,
def
->
source
.
name
,
vol
->
name
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
goto
cleanup
;
...
...
@@ -379,6 +383,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned
int
flags
)
{
int
ret
=
-
1
;
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
destroy_cmd
=
NULL
;
virCheckFlags
(
0
,
-
1
);
...
...
@@ -386,7 +391,7 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
destroy_cmd
=
virCommandNewArgList
(
ZFS
,
"destroy"
,
NULL
);
virCommandAddArgFormat
(
destroy_cmd
,
"%s/%s"
,
pool
->
def
->
source
.
name
,
vol
->
name
);
def
->
source
.
name
,
vol
->
name
);
if
(
virCommandRun
(
destroy_cmd
,
NULL
)
<
0
)
goto
cleanup
;
...
...
@@ -402,23 +407,24 @@ virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr
pool
,
unsigned
int
flags
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
size_t
i
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
if
(
pool
->
def
->
source
.
ndevice
==
0
)
{
if
(
def
->
source
.
ndevice
==
0
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"missing source devices"
));
return
-
1
;
}
cmd
=
virCommandNewArgList
(
ZPOOL
,
"create"
,
pool
->
def
->
source
.
name
,
NULL
);
def
->
source
.
name
,
NULL
);
for
(
i
=
0
;
i
<
pool
->
def
->
source
.
ndevice
;
i
++
)
virCommandAddArg
(
cmd
,
pool
->
def
->
source
.
devices
[
i
].
path
);
for
(
i
=
0
;
i
<
def
->
source
.
ndevice
;
i
++
)
virCommandAddArg
(
cmd
,
def
->
source
.
devices
[
i
].
path
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
goto
cleanup
;
...
...
@@ -435,13 +441,14 @@ virStorageBackendZFSDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr
pool
,
unsigned
int
flags
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
int
ret
=
-
1
;
virCheckFlags
(
0
,
-
1
);
cmd
=
virCommandNewArgList
(
ZPOOL
,
"destroy"
,
pool
->
def
->
source
.
name
,
NULL
);
def
->
source
.
name
,
NULL
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
goto
cleanup
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录