Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f75ed996
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,发现更多精彩内容 >>
提交
f75ed996
编写于
5月 03, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_STRDUP and VIR_STRNDUP in src/locking/*
上级
08152a69
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
63 deletion
+46
-63
src/locking/lock_daemon.c
src/locking/lock_daemon.c
+17
-17
src/locking/lock_daemon_config.c
src/locking/lock_daemon_config.c
+5
-7
src/locking/lock_daemon_dispatch.c
src/locking/lock_daemon_dispatch.c
+2
-4
src/locking/lock_driver_lockd.c
src/locking/lock_driver_lockd.c
+17
-24
src/locking/lock_driver_sanlock.c
src/locking/lock_driver_sanlock.c
+4
-8
src/locking/lock_manager.c
src/locking/lock_manager.c
+1
-3
未找到文件。
src/locking/lock_daemon.c
浏览文件 @
f75ed996
...
...
@@ -370,8 +370,8 @@ virLockDaemonPidFilePath(bool privileged,
char
**
pidfile
)
{
if
(
privileged
)
{
if
(
!
(
*
pidfile
=
strdup
(
LOCALSTATEDIR
"/run/virtlockd.pid"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
*
pidfile
,
LOCALSTATEDIR
"/run/virtlockd.pid"
)
<
0
)
goto
error
;
}
else
{
char
*
rundir
=
NULL
;
mode_t
old_umask
;
...
...
@@ -388,7 +388,8 @@ virLockDaemonPidFilePath(bool privileged,
if
(
virAsprintf
(
pidfile
,
"%s/virtlockd.pid"
,
rundir
)
<
0
)
{
VIR_FREE
(
rundir
);
goto
no_memory
;
virReportOOMError
();
goto
error
;
}
VIR_FREE
(
rundir
);
...
...
@@ -396,8 +397,6 @@ virLockDaemonPidFilePath(bool privileged,
return
0
;
no_memory:
virReportOOMError
();
error:
return
-
1
;
}
...
...
@@ -408,8 +407,8 @@ virLockDaemonUnixSocketPaths(bool privileged,
char
**
sockfile
)
{
if
(
privileged
)
{
if
(
!
(
*
sockfile
=
strdup
(
LOCALSTATEDIR
"/run/libvirt/virtlockd-sock"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
*
sockfile
,
LOCALSTATEDIR
"/run/libvirt/virtlockd-sock"
)
<
0
)
goto
error
;
}
else
{
char
*
rundir
=
NULL
;
mode_t
old_umask
;
...
...
@@ -426,15 +425,14 @@ virLockDaemonUnixSocketPaths(bool privileged,
if
(
virAsprintf
(
sockfile
,
"%s/virtlockd-sock"
,
rundir
)
<
0
)
{
VIR_FREE
(
rundir
);
goto
no_memory
;
virReportOOMError
();
goto
error
;
}
VIR_FREE
(
rundir
);
}
return
0
;
no_memory:
virReportOOMError
();
error:
return
-
1
;
}
...
...
@@ -869,10 +867,8 @@ virLockDaemonClientNewPostExecRestart(virNetServerClientPtr client,
_
(
"Missing ownerName data in JSON document"
));
goto
error
;
}
if
(
!
(
priv
->
ownerName
=
strdup
(
ownerName
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
priv
->
ownerName
,
ownerName
)
<
0
)
goto
error
;
}
if
(
!
(
ownerUUID
=
virJSONValueObjectGetString
(
object
,
"ownerUUID"
)))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Missing ownerUUID data in JSON document"
));
...
...
@@ -1223,14 +1219,18 @@ int main(int argc, char **argv) {
case
'p'
:
VIR_FREE
(
pid_file
);
if
(
!
(
pid_file
=
strdup
(
optarg
)))
if
(
VIR_STRDUP_QUIET
(
pid_file
,
optarg
)
<
0
)
{
VIR_ERROR
(
_
(
"Can't allocate memory"
));
exit
(
EXIT_FAILURE
);
}
break
;
case
'f'
:
VIR_FREE
(
remote_config_file
);
if
(
!
(
remote_config_file
=
strdup
(
optarg
)))
if
(
VIR_STRDUP_QUIET
(
remote_config_file
,
optarg
)
<
0
)
{
VIR_ERROR
(
_
(
"Can't allocate memory"
));
exit
(
EXIT_FAILURE
);
}
break
;
case
OPT_VERSION
:
...
...
@@ -1314,8 +1314,8 @@ int main(int argc, char **argv) {
/* Ensure the rundir exists (on tmpfs on some systems) */
if
(
privileged
)
{
if
(
!
(
run_dir
=
strdup
(
LOCALSTATEDIR
"/run/libvirt"
))
)
{
virReportOOMError
(
);
if
(
VIR_STRDUP_QUIET
(
run_dir
,
LOCALSTATEDIR
"/run/libvirt"
)
<
0
)
{
VIR_ERROR
(
_
(
"Can't allocate memory"
)
);
goto
cleanup
;
}
}
else
{
...
...
src/locking/lock_daemon_config.c
浏览文件 @
f75ed996
...
...
@@ -53,8 +53,8 @@ checkType(virConfValuePtr p, const char *filename,
}
/* 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
strdup
succeeds,
store the result in var_name. Otherwise, (i.e. invalid type, or
strdup
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 { \
...
...
@@ -63,10 +63,8 @@ checkType(virConfValuePtr p, const char *filename,
if (checkType(p, filename, #var_name, VIR_CONF_STRING) < 0) \
goto error; \
VIR_FREE(data->var_name); \
if (!(data->var_name = strdup(p->str))) { \
virReportOOMError(); \
if (VIR_STRDUP(data->var_name, p->str) < 0) \
goto error; \
} \
} \
} while (0)
...
...
@@ -85,8 +83,8 @@ int
virLockDaemonConfigFilePath
(
bool
privileged
,
char
**
configfile
)
{
if
(
privileged
)
{
if
(
!
(
*
configfile
=
strdup
(
SYSCONFDIR
"/libvirt/virtlockd.conf"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
*
configfile
,
SYSCONFDIR
"/libvirt/virtlockd.conf"
)
<
0
)
goto
error
;
}
else
{
char
*
configdir
=
NULL
;
...
...
src/locking/lock_daemon_dispatch.c
浏览文件 @
f75ed996
...
...
@@ -25,7 +25,7 @@
#include "rpc/virnetserver.h"
#include "rpc/virnetserverclient.h"
#include "virlog.h"
#include "virstring.h"
#include "lock_daemon.h"
#include "lock_protocol.h"
#include "lock_daemon_dispatch_stubs.h"
...
...
@@ -275,10 +275,8 @@ virLockSpaceProtocolDispatchRegister(virNetServerPtr server ATTRIBUTE_UNUSED,
goto
cleanup
;
}
if
(
!
(
priv
->
ownerName
=
strdup
(
args
->
owner
.
name
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
priv
->
ownerName
,
args
->
owner
.
name
)
<
0
)
goto
cleanup
;
}
memcpy
(
priv
->
ownerUUID
,
args
->
owner
.
uuid
,
VIR_UUID_BUFLEN
);
priv
->
ownerId
=
args
->
owner
.
id
;
priv
->
ownerPid
=
args
->
owner
.
pid
;
...
...
src/locking/lock_driver_lockd.c
浏览文件 @
f75ed996
...
...
@@ -129,8 +129,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
CHECK_TYPE
(
"file_lockspace_dir"
,
VIR_CONF_STRING
);
if
(
p
&&
p
->
str
)
{
VIR_FREE
(
driver
->
fileLockSpaceDir
);
if
(
!
(
driver
->
fileLockSpaceDir
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
driver
->
fileLockSpaceDir
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -140,8 +139,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
CHECK_TYPE
(
"lvm_lockspace_dir"
,
VIR_CONF_STRING
);
if
(
p
&&
p
->
str
)
{
VIR_FREE
(
driver
->
lvmLockSpaceDir
);
if
(
!
(
driver
->
lvmLockSpaceDir
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
driver
->
lvmLockSpaceDir
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -151,8 +149,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
CHECK_TYPE
(
"scsi_lockspace_dir"
,
VIR_CONF_STRING
);
if
(
p
&&
p
->
str
)
{
VIR_FREE
(
driver
->
scsiLockSpaceDir
);
if
(
!
(
driver
->
scsiLockSpaceDir
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
driver
->
scsiLockSpaceDir
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -174,10 +171,8 @@ static char *virLockManagerLockDaemonPath(bool privileged)
{
char
*
path
;
if
(
privileged
)
{
if
(
!
(
path
=
strdup
(
LOCALSTATEDIR
"/run/libvirt/virtlockd-sock"
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
path
,
LOCALSTATEDIR
"/run/libvirt/virtlockd-sock"
)
<
0
)
return
NULL
;
}
}
else
{
char
*
rundir
=
NULL
;
...
...
@@ -468,10 +463,8 @@ static int virLockManagerLockDaemonNew(virLockManagerPtr lock,
if
(
STREQ
(
params
[
i
].
key
,
"uuid"
))
{
memcpy
(
priv
->
uuid
,
params
[
i
].
value
.
uuid
,
VIR_UUID_BUFLEN
);
}
else
if
(
STREQ
(
params
[
i
].
key
,
"name"
))
{
if
(
!
(
priv
->
name
=
strdup
(
params
[
i
].
value
.
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
priv
->
name
,
params
[
i
].
value
.
str
)
<
0
)
return
-
1
;
}
}
else
if
(
STREQ
(
params
[
i
].
key
,
"id"
))
{
priv
->
id
=
params
[
i
].
value
.
i
;
}
else
if
(
STREQ
(
params
[
i
].
key
,
"pid"
))
{
...
...
@@ -590,8 +583,8 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
if
(
newName
)
{
VIR_DEBUG
(
"Got an LVM UUID %s for %s"
,
newName
,
name
);
if
(
!
(
newLockspace
=
strdup
(
driver
->
lvmLockSpaceDir
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
newLockspace
,
driver
->
lvmLockSpaceDir
)
<
0
)
goto
error
;
autoCreate
=
true
;
break
;
}
...
...
@@ -607,8 +600,8 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
if
(
newName
)
{
VIR_DEBUG
(
"Got an SCSI ID %s for %s"
,
newName
,
name
);
if
(
!
(
newLockspace
=
strdup
(
driver
->
scsiLockSpaceDir
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
newLockspace
,
driver
->
scsiLockSpaceDir
)
<
0
)
goto
error
;
autoCreate
=
true
;
break
;
}
...
...
@@ -617,17 +610,17 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
}
if
(
driver
->
fileLockSpaceDir
)
{
if
(
!
(
newLockspace
=
strdup
(
driver
->
fileLockSpaceDir
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
newLockspace
,
driver
->
fileLockSpaceDir
)
<
0
)
goto
error
;
if
(
!
(
newName
=
virLockManagerLockDaemonDiskLeaseName
(
name
)))
goto
no_memory
;
autoCreate
=
true
;
VIR_DEBUG
(
"Using indirect lease %s for %s"
,
newName
,
name
);
}
else
{
if
(
!
(
newLockspace
=
strdup
(
""
))
)
goto
no_memory
;
if
(
!
(
newName
=
strdup
(
name
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
newLockspace
,
""
)
<
0
)
goto
error
;
if
(
VIR_STRDUP
(
newName
,
name
)
<
0
)
goto
error
;
VIR_DEBUG
(
"Using direct lease for %s"
,
name
);
}
...
...
@@ -664,8 +657,8 @@ static int virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
virReportOOMError
();
return
-
1
;
}
if
(
!
(
newName
=
strdup
(
name
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
newName
,
name
)
<
0
)
goto
error
;
}
break
;
default:
...
...
src/locking/lock_driver_sanlock.c
浏览文件 @
f75ed996
...
...
@@ -129,8 +129,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
CHECK_TYPE
(
"disk_lease_dir"
,
VIR_CONF_STRING
);
if
(
p
&&
p
->
str
)
{
VIR_FREE
(
driver
->
autoDiskLeasePath
);
if
(
!
(
driver
->
autoDiskLeasePath
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
driver
->
autoDiskLeasePath
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -150,8 +149,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
p
=
virConfGetValue
(
conf
,
"user"
);
CHECK_TYPE
(
"user"
,
VIR_CONF_STRING
);
if
(
p
)
{
if
(
!
(
tmp
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
tmp
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -167,8 +165,7 @@ static int virLockManagerSanlockLoadConfig(const char *configFile)
p
=
virConfGetValue
(
conf
,
"group"
);
CHECK_TYPE
(
"group"
,
VIR_CONF_STRING
);
if
(
p
)
{
if
(
!
(
tmp
=
strdup
(
p
->
str
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
tmp
,
p
->
str
)
<
0
)
{
virConfFree
(
conf
);
return
-
1
;
}
...
...
@@ -408,9 +405,8 @@ static int virLockManagerSanlockInit(unsigned int version,
driver
->
autoDiskLease
=
false
;
driver
->
user
=
(
uid_t
)
-
1
;
driver
->
group
=
(
gid_t
)
-
1
;
if
(
!
(
driver
->
autoDiskLeasePath
=
strdup
(
LOCALSTATEDIR
"/lib/libvirt/sanlock"
))
)
{
if
(
VIR_STRDUP
(
driver
->
autoDiskLeasePath
,
LOCALSTATEDIR
"/lib/libvirt/sanlock"
)
<
0
)
{
VIR_FREE
(
driver
);
virReportOOMError
();
goto
error
;
}
...
...
src/locking/lock_manager.c
浏览文件 @
f75ed996
...
...
@@ -194,10 +194,8 @@ virLockManagerPluginPtr virLockManagerPluginNew(const char *name,
plugin
->
driver
=
driver
;
plugin
->
handle
=
handle
;
plugin
->
refs
=
1
;
if
(
!
(
plugin
->
name
=
strdup
(
name
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
plugin
->
name
,
name
)
<
0
)
goto
cleanup
;
}
VIR_FREE
(
configFile
);
VIR_FREE
(
modfile
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录