Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
2666b290
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看板
提交
2666b290
编写于
7月 08, 2016
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virtlockd: convert to typesafe virConf accessors
Signed-off-by:
N
Daniel P. Berrange
<
berrange@redhat.com
>
上级
f5da0d18
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
88 deletion
+12
-88
po/POTFILES.in
po/POTFILES.in
+0
-1
src/locking/lock_daemon_config.c
src/locking/lock_daemon_config.c
+9
-81
src/locking/lock_daemon_config.h
src/locking/lock_daemon_config.h
+3
-6
未找到文件。
po/POTFILES.in
浏览文件 @
2666b290
...
...
@@ -82,7 +82,6 @@ src/libxl/libxl_domain.c
src/libxl/libxl_driver.c
src/libxl/libxl_migration.c
src/locking/lock_daemon.c
src/locking/lock_daemon_config.c
src/locking/lock_daemon_dispatch.c
src/locking/lock_driver_lockd.c
src/locking/lock_driver_sanlock.c
...
...
src/locking/lock_daemon_config.c
浏览文件 @
2666b290
...
...
@@ -37,62 +37,6 @@
VIR_LOG_INIT
(
"locking.lock_daemon_config"
);
/* A helper function used by each of the following macros. */
static
int
checkType
(
virConfValuePtr
p
,
const
char
*
filename
,
const
char
*
key
,
virConfType
required_type
)
{
if
(
p
->
type
!=
required_type
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"remoteReadConfigFile: %s: %s: invalid type:"
" got %s; expected %s"
),
filename
,
key
,
virConfTypeToString
(
p
->
type
),
virConfTypeToString
(
required_type
));
return
-
1
;
}
return
0
;
}
/* If there is no config data for the key, #var_name, then do nothing.
If there is valid data of type VIR_CONF_STRING, and VIR_STRDUP succeeds,
store the result in var_name. Otherwise, (i.e. invalid type, or VIR_STRDUP
failure), give a diagnostic and "goto" the cleanup-and-fail label. */
#define GET_CONF_STR(conf, filename, var_name) \
do { \
virConfValuePtr p = virConfGetValue(conf, #var_name); \
if (p) { \
if (checkType(p, filename, #var_name, VIR_CONF_STRING) < 0) \
goto error; \
VIR_FREE(data->var_name); \
if (VIR_STRDUP(data->var_name, p->str) < 0) \
goto error; \
} \
} while (0)
/* Like GET_CONF_STR, but for signed integer values. */
#define GET_CONF_INT(conf, filename, var_name) \
do { \
virConfValuePtr p = virConfGetValue(conf, #var_name); \
if (p) { \
if (p->type != VIR_CONF_ULONG && \
checkType(p, filename, #var_name, VIR_CONF_LONG) < 0) \
goto error; \
data->var_name = p->l; \
} \
} while (0)
/* Like GET_CONF_STR, but for unsigned integer values. */
#define GET_CONF_UINT(conf, filename, var_name) \
do { \
virConfValuePtr p = virConfGetValue(conf, #var_name); \
if (p) { \
if (checkType(p, filename, #var_name, VIR_CONF_ULONG) < 0) \
goto error; \
data->var_name = p->l; \
} \
} while (0)
int
virLockDaemonConfigFilePath
(
bool
privileged
,
char
**
configfile
)
{
...
...
@@ -146,18 +90,18 @@ virLockDaemonConfigFree(virLockDaemonConfigPtr data)
static
int
virLockDaemonConfigLoadOptions
(
virLockDaemonConfigPtr
data
,
const
char
*
filename
,
virConfPtr
conf
)
{
GET_CONF_UINT
(
conf
,
filename
,
log_level
);
GET_CONF_STR
(
conf
,
filename
,
log_filters
);
GET_CONF_STR
(
conf
,
filename
,
log_outputs
);
GET_CONF_UINT
(
conf
,
filename
,
max_clients
);
if
(
virConfGetValueUInt
(
conf
,
"log_level"
,
&
data
->
log_level
)
<
0
)
return
-
1
;
if
(
virConfGetValueString
(
conf
,
"log_filters"
,
&
data
->
log_filters
)
<
0
)
return
-
1
;
if
(
virConfGetValueString
(
conf
,
"log_outputs"
,
&
data
->
log_filters
)
<
0
)
return
-
1
;
if
(
virConfGetValueUInt
(
conf
,
"max_clients"
,
&
data
->
max_clients
)
<
0
)
return
-
1
;
return
0
;
error:
return
-
1
;
}
...
...
@@ -181,23 +125,7 @@ virLockDaemonConfigLoadFile(virLockDaemonConfigPtr data,
if
(
!
conf
)
return
-
1
;
ret
=
virLockDaemonConfigLoadOptions
(
data
,
filename
,
conf
);
virConfFree
(
conf
);
return
ret
;
}
int
virLockDaemonConfigLoadData
(
virLockDaemonConfigPtr
data
,
const
char
*
filename
,
const
char
*
filedata
)
{
virConfPtr
conf
;
int
ret
;
conf
=
virConfReadMem
(
filedata
,
strlen
(
filedata
),
0
);
if
(
!
conf
)
return
-
1
;
ret
=
virLockDaemonConfigLoadOptions
(
data
,
filename
,
conf
);
ret
=
virLockDaemonConfigLoadOptions
(
data
,
conf
);
virConfFree
(
conf
);
return
ret
;
}
src/locking/lock_daemon_config.h
浏览文件 @
2666b290
...
...
@@ -30,10 +30,10 @@ typedef struct _virLockDaemonConfig virLockDaemonConfig;
typedef
virLockDaemonConfig
*
virLockDaemonConfigPtr
;
struct
_virLockDaemonConfig
{
int
log_level
;
unsigned
int
log_level
;
char
*
log_filters
;
char
*
log_outputs
;
int
max_clients
;
unsigned
int
max_clients
;
};
...
...
@@ -42,9 +42,6 @@ virLockDaemonConfigPtr virLockDaemonConfigNew(bool privileged);
void
virLockDaemonConfigFree
(
virLockDaemonConfigPtr
data
);
int
virLockDaemonConfigLoadFile
(
virLockDaemonConfigPtr
data
,
const
char
*
filename
,
bool
allow_missing
);
int
virLockDaemonConfigLoadData
(
virLockDaemonConfigPtr
data
,
const
char
*
filename
,
const
char
*
filedata
);
bool
allow_missing
);
#endif
/* __LIBVIRTD_CONFIG_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录