Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
759fbdd0
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,发现更多精彩内容 >>
提交
759fbdd0
编写于
7月 26, 2017
作者:
J
John Ferlan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
storage: Use virStoragePoolObjGetDef accessor for FS backend
In preparation for privatizing the object, use the accessor.
上级
2bbb66c4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
50 addition
and
40 deletion
+50
-40
src/storage/storage_backend_fs.c
src/storage/storage_backend_fs.c
+50
-40
未找到文件。
src/storage/storage_backend_fs.c
浏览文件 @
759fbdd0
...
...
@@ -222,25 +222,27 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
static
int
virStorageBackendFileSystemIsValid
(
virStoragePoolObjPtr
pool
)
{
if
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
{
if
(
pool
->
def
->
source
.
nhost
!=
1
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
if
(
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
{
if
(
def
->
source
.
nhost
!=
1
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"expected exactly 1 host for the storage pool"
));
return
-
1
;
}
if
(
pool
->
def
->
source
.
hosts
[
0
].
name
==
NULL
)
{
if
(
def
->
source
.
hosts
[
0
].
name
==
NULL
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing source host"
));
return
-
1
;
}
if
(
pool
->
def
->
source
.
dir
==
NULL
)
{
if
(
def
->
source
.
dir
==
NULL
)
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing source path"
));
return
-
1
;
}
}
else
{
if
(
pool
->
def
->
source
.
ndevice
!=
1
)
{
if
(
pool
->
def
->
source
.
ndevice
==
0
)
if
(
def
->
source
.
ndevice
!=
1
)
{
if
(
def
->
source
.
ndevice
==
0
)
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"missing source device"
));
else
...
...
@@ -264,22 +266,23 @@ virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool)
static
char
*
virStorageBackendFileSystemGetPoolSource
(
virStoragePoolObjPtr
pool
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
char
*
src
=
NULL
;
if
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
{
if
(
pool
->
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_CIFS
)
{
if
(
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
{
if
(
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_CIFS
)
{
if
(
virAsprintf
(
&
src
,
"//%s/%s"
,
pool
->
def
->
source
.
hosts
[
0
].
name
,
pool
->
def
->
source
.
dir
)
<
0
)
def
->
source
.
hosts
[
0
].
name
,
def
->
source
.
dir
)
<
0
)
return
NULL
;
}
else
{
if
(
virAsprintf
(
&
src
,
"%s:%s"
,
pool
->
def
->
source
.
hosts
[
0
].
name
,
pool
->
def
->
source
.
dir
)
<
0
)
def
->
source
.
hosts
[
0
].
name
,
def
->
source
.
dir
)
<
0
)
return
NULL
;
}
}
else
{
if
(
VIR_STRDUP
(
src
,
pool
->
def
->
source
.
devices
[
0
].
path
)
<
0
)
if
(
VIR_STRDUP
(
src
,
def
->
source
.
devices
[
0
].
path
)
<
0
)
return
NULL
;
}
return
src
;
...
...
@@ -297,6 +300,7 @@ static int
virStorageBackendFileSystemIsMounted
(
virStoragePoolObjPtr
pool
)
{
int
ret
=
-
1
;
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
char
*
src
=
NULL
;
FILE
*
mtab
;
struct
mntent
ent
;
...
...
@@ -317,8 +321,7 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
/* compare both mount destinations and sources to be sure the mounted
* FS pool is really the one we're looking for
*/
if
((
rc1
=
virFileComparePaths
(
ent
.
mnt_dir
,
pool
->
def
->
target
.
path
))
<
0
||
if
((
rc1
=
virFileComparePaths
(
ent
.
mnt_dir
,
def
->
target
.
path
))
<
0
||
(
rc2
=
virFileComparePaths
(
ent
.
mnt_fsname
,
src
))
<
0
)
goto
cleanup
;
...
...
@@ -349,16 +352,17 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
static
int
virStorageBackendFileSystemMount
(
virStoragePoolObjPtr
pool
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
char
*
src
=
NULL
;
/* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
* while plain 'mount' does. We have to craft separate argvs to
* accommodate this */
bool
netauto
=
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
pool
->
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_AUTO
);
bool
glusterfs
=
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
pool
->
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_GLUSTERFS
);
bool
cifsfs
=
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
pool
->
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_CIFS
);
bool
netauto
=
(
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_AUTO
);
bool
glusterfs
=
(
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_GLUSTERFS
);
bool
cifsfs
=
(
def
->
type
==
VIR_STORAGE_POOL_NETFS
&&
def
->
source
.
format
==
VIR_STORAGE_POOL_NETFS_CIFS
);
virCommandPtr
cmd
=
NULL
;
int
ret
=
-
1
;
int
rc
;
...
...
@@ -371,7 +375,7 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
/* Short-circuit if already mounted */
if
(
rc
==
1
)
{
VIR_INFO
(
"Target '%s' is already mounted"
,
pool
->
def
->
target
.
path
);
VIR_INFO
(
"Target '%s' is already mounted"
,
def
->
target
.
path
);
return
0
;
}
...
...
@@ -381,34 +385,34 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
if
(
netauto
)
cmd
=
virCommandNewArgList
(
MOUNT
,
src
,
pool
->
def
->
target
.
path
,
def
->
target
.
path
,
NULL
);
else
if
(
glusterfs
)
cmd
=
virCommandNewArgList
(
MOUNT
,
"-t"
,
virStoragePoolFormatFileSystemNetTypeToString
(
pool
->
def
->
source
.
format
),
virStoragePoolFormatFileSystemNetTypeToString
(
def
->
source
.
format
),
src
,
"-o"
,
"direct-io-mode=1"
,
pool
->
def
->
target
.
path
,
def
->
target
.
path
,
NULL
);
else
if
(
cifsfs
)
cmd
=
virCommandNewArgList
(
MOUNT
,
"-t"
,
virStoragePoolFormatFileSystemNetTypeToString
(
pool
->
def
->
source
.
format
),
virStoragePoolFormatFileSystemNetTypeToString
(
def
->
source
.
format
),
src
,
pool
->
def
->
target
.
path
,
def
->
target
.
path
,
"-o"
,
"guest"
,
NULL
);
else
cmd
=
virCommandNewArgList
(
MOUNT
,
"-t"
,
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_FS
?
virStoragePoolFormatFileSystemTypeToString
(
pool
->
def
->
source
.
format
)
:
virStoragePoolFormatFileSystemNetTypeToString
(
pool
->
def
->
source
.
format
)),
(
def
->
type
==
VIR_STORAGE_POOL_FS
?
virStoragePoolFormatFileSystemTypeToString
(
def
->
source
.
format
)
:
virStoragePoolFormatFileSystemNetTypeToString
(
def
->
source
.
format
)),
src
,
pool
->
def
->
target
.
path
,
def
->
target
.
path
,
NULL
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
...
...
@@ -435,7 +439,9 @@ static int
virStorageBackendFileSystemStart
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
)
{
if
(
pool
->
def
->
type
!=
VIR_STORAGE_POOL_DIR
&&
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
if
(
def
->
type
!=
VIR_STORAGE_POOL_DIR
&&
virStorageBackendFileSystemMount
(
pool
)
<
0
)
return
-
1
;
...
...
@@ -459,6 +465,7 @@ static int
virStorageBackendFileSystemStop
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
virCommandPtr
cmd
=
NULL
;
int
ret
=
-
1
;
int
rc
;
...
...
@@ -470,7 +477,7 @@ virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
if
((
rc
=
virStorageBackendFileSystemIsMounted
(
pool
))
!=
1
)
return
rc
;
cmd
=
virCommandNewArgList
(
UMOUNT
,
pool
->
def
->
target
.
path
,
NULL
);
cmd
=
virCommandNewArgList
(
UMOUNT
,
def
->
target
.
path
,
NULL
);
if
(
virCommandRun
(
cmd
,
NULL
)
<
0
)
goto
cleanup
;
...
...
@@ -486,8 +493,10 @@ static int
virStorageBackendFileSystemCheck
(
virStoragePoolObjPtr
pool
,
bool
*
isActive
)
{
if
(
pool
->
def
->
type
==
VIR_STORAGE_POOL_DIR
)
{
*
isActive
=
virFileExists
(
pool
->
def
->
target
.
path
);
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
if
(
def
->
type
==
VIR_STORAGE_POOL_DIR
)
{
*
isActive
=
virFileExists
(
def
->
target
.
path
);
#if WITH_STORAGE_FS
}
else
{
int
ret
;
...
...
@@ -561,25 +570,26 @@ static int
virStorageBackendMakeFileSystem
(
virStoragePoolObjPtr
pool
,
unsigned
int
flags
)
{
virStoragePoolDefPtr
def
=
virStoragePoolObjGetDef
(
pool
);
const
char
*
device
=
NULL
,
*
format
=
NULL
;
bool
ok_to_mkfs
=
false
;
int
ret
=
-
1
;
if
(
pool
->
def
->
source
.
devices
==
NULL
)
{
if
(
def
->
source
.
devices
==
NULL
)
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
_
(
"No source device specified when formatting pool '%s'"
),
pool
->
def
->
name
);
def
->
name
);
goto
error
;
}
device
=
pool
->
def
->
source
.
devices
[
0
].
path
;
format
=
virStoragePoolFormatFileSystemTypeToString
(
pool
->
def
->
source
.
format
);
device
=
def
->
source
.
devices
[
0
].
path
;
format
=
virStoragePoolFormatFileSystemTypeToString
(
def
->
source
.
format
);
VIR_DEBUG
(
"source device: '%s' format: '%s'"
,
device
,
format
);
if
(
!
virFileExists
(
device
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
_
(
"Source device does not exist when formatting pool '%s'"
),
pool
->
def
->
name
);
def
->
name
);
goto
error
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录