Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
544f087e
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看板
提交
544f087e
编写于
7月 08, 2016
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sanlock: convert to typesafe virConf accessors
Signed-off-by:
N
Daniel P. Berrange
<
berrange@redhat.com
>
上级
b474952e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
66 deletion
+31
-66
src/locking/lock_driver_sanlock.c
src/locking/lock_driver_sanlock.c
+31
-66
未找到文件。
src/locking/lock_driver_sanlock.c
浏览文件 @
544f087e
...
...
@@ -70,7 +70,7 @@ typedef virLockManagerSanlockPrivate *virLockManagerSanlockPrivatePtr;
struct
_virLockManagerSanlockDriver
{
bool
requireLeaseForDisks
;
int
hostID
;
unsigned
int
hostID
;
bool
autoDiskLease
;
char
*
autoDiskLeasePath
;
unsigned
int
io_timeout
;
...
...
@@ -103,8 +103,9 @@ struct _virLockManagerSanlockPrivate {
static
int
virLockManagerSanlockLoadConfig
(
const
char
*
configFile
)
{
virConfPtr
conf
;
virConfValuePtr
p
;
char
*
tmp
;
int
ret
=
-
1
;
char
*
user
=
NULL
;
char
*
group
=
NULL
;
if
(
access
(
configFile
,
R_OK
)
==
-
1
)
{
if
(
errno
!=
ENOENT
)
{
...
...
@@ -119,76 +120,40 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
if
(
!
(
conf
=
virConfReadFile
(
configFile
,
0
)))
return
-
1
;
#define CHECK_TYPE(name, typ) if (p && p->type != (typ)) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \
"%s: %s: expected type " #typ, \
configFile, (name)); \
virConfFree(conf); \
return -1; \
}
if
(
virConfGetValueBool
(
conf
,
"auto_disk_leases"
,
&
driver
->
autoDiskLease
)
<
0
)
goto
cleanup
;
p
=
virConfGetValue
(
conf
,
"auto_disk_leases"
);
CHECK_TYPE
(
"auto_disk_leases"
,
VIR_CONF_ULONG
);
if
(
p
)
driver
->
autoDiskLease
=
p
->
l
;
if
(
virConfGetValueString
(
conf
,
"disk_lease_dir"
,
&
driver
->
autoDiskLeasePath
)
<
0
)
goto
cleanup
;
p
=
virConfGetValue
(
conf
,
"disk_lease_dir"
);
CHECK_TYPE
(
"disk_lease_dir"
,
VIR_CONF_STRING
);
if
(
p
&&
p
->
str
)
{
VIR_FREE
(
driver
->
autoDiskLeasePath
);
if
(
VIR_STRDUP
(
driver
->
autoDiskLeasePath
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
}
if
(
virConfGetValueUInt
(
conf
,
"host_id"
,
&
driver
->
hostID
)
<
0
)
goto
cleanup
;
p
=
virConfGetValue
(
conf
,
"host_id"
);
CHECK_TYPE
(
"host_id"
,
VIR_CONF_ULONG
);
if
(
p
)
driver
->
hostID
=
p
->
l
;
p
=
virConfGetValue
(
conf
,
"require_lease_for_disks"
);
CHECK_TYPE
(
"require_lease_for_disks"
,
VIR_CONF_ULONG
);
if
(
p
)
driver
->
requireLeaseForDisks
=
p
->
l
;
else
driver
->
requireLeaseForDisks
=
!
driver
->
autoDiskLease
;
p
=
virConfGetValue
(
conf
,
"io_timeout"
);
CHECK_TYPE
(
"io_timeout"
,
VIR_CONF_ULONG
);
if
(
p
)
driver
->
io_timeout
=
p
->
l
;
p
=
virConfGetValue
(
conf
,
"user"
);
CHECK_TYPE
(
"user"
,
VIR_CONF_STRING
);
if
(
p
)
{
if
(
VIR_STRDUP
(
tmp
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
driver
->
requireLeaseForDisks
=
!
driver
->
autoDiskLease
;
if
(
virConfGetValueBool
(
conf
,
"require_lease_for_disks"
,
&
driver
->
requireLeaseForDisks
)
<
0
)
goto
cleanup
;
if
(
virGetUserID
(
tmp
,
&
driver
->
user
)
<
0
)
{
VIR_FREE
(
tmp
);
virConfFree
(
conf
);
return
-
1
;
}
VIR_FREE
(
tmp
);
}
if
(
virConfGetValueUInt
(
conf
,
"io_timeout"
,
&
driver
->
io_timeout
)
<
0
)
goto
cleanup
;
p
=
virConfGetValue
(
conf
,
"group"
);
CHECK_TYPE
(
"group"
,
VIR_CONF_STRING
);
if
(
p
)
{
if
(
VIR_STRDUP
(
tmp
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
if
(
virGetGroupID
(
tmp
,
&
driver
->
group
)
<
0
)
{
VIR_FREE
(
tmp
);
virConfFree
(
conf
);
return
-
1
;
}
VIR_FREE
(
tmp
);
}
if
(
virConfGetValueString
(
conf
,
"user"
,
&
user
)
<
0
)
goto
cleanup
;
if
(
user
&&
virGetUserID
(
user
,
&
driver
->
user
)
<
0
)
goto
cleanup
;
if
(
virConfGetValueString
(
conf
,
"group"
,
&
group
)
<
0
)
goto
cleanup
;
if
(
group
&&
virGetGroupID
(
group
,
&
driver
->
group
)
<
0
)
goto
cleanup
;
ret
=
0
;
cleanup:
virConfFree
(
conf
);
return
0
;
VIR_FREE
(
user
);
VIR_FREE
(
group
);
return
ret
;
}
/* How much ms sleep before retrying to add a lockspace? */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录