Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
1f5deed9
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看板
提交
1f5deed9
编写于
5月 03, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_STRDUP and VIR_STRNDUP in src/openvz/*
上级
bf1fe848
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
45 deletion
+33
-45
src/openvz/openvz_conf.c
src/openvz/openvz_conf.c
+22
-23
src/openvz/openvz_driver.c
src/openvz/openvz_driver.c
+11
-22
未找到文件。
src/openvz/openvz_conf.c
浏览文件 @
1f5deed9
...
...
@@ -135,12 +135,10 @@ openvzParseBarrierLimit(const char* value,
{
char
*
token
;
char
*
saveptr
=
NULL
;
char
*
str
=
strdup
(
value
)
;
char
*
str
;
if
(
str
==
NULL
)
{
virReportOOMError
();
if
(
VIR_STRDUP
(
str
,
value
)
<
0
)
goto
error
;
}
token
=
strtok_r
(
str
,
":"
,
&
saveptr
);
if
(
token
==
NULL
)
{
...
...
@@ -230,10 +228,8 @@ openvzReadNetworkConf(virDomainDefPtr def,
goto
no_memory
;
net
->
type
=
VIR_DOMAIN_NET_TYPE_ETHERNET
;
net
->
data
.
ethernet
.
ipaddr
=
strdup
(
token
);
if
(
net
->
data
.
ethernet
.
ipaddr
==
NULL
)
goto
no_memory
;
if
(
VIR_STRDUP
(
net
->
data
.
ethernet
.
ipaddr
,
token
)
<
0
)
goto
error
;
if
(
VIR_REALLOC_N
(
def
->
nets
,
def
->
nnets
+
1
)
<
0
)
goto
no_memory
;
...
...
@@ -405,7 +401,8 @@ openvzReadFSConf(virDomainDefPtr def,
goto
no_memory
;
fs
->
type
=
VIR_DOMAIN_FS_TYPE_TEMPLATE
;
fs
->
src
=
strdup
(
temp
);
if
(
VIR_STRDUP
(
fs
->
src
,
temp
)
<
0
)
goto
error
;
}
else
{
/* OSTEMPLATE was not found, VE was booted from a private dir directly */
ret
=
openvzReadVPSConfigParam
(
veid
,
"VE_PRIVATE"
,
&
temp
);
...
...
@@ -423,12 +420,14 @@ openvzReadFSConf(virDomainDefPtr def,
goto
no_memory
;
fs
->
type
=
VIR_DOMAIN_FS_TYPE_MOUNT
;
fs
->
src
=
openvz_replace
(
temp
,
"$VEID"
,
veid_str
);
if
(
!
(
fs
->
src
=
openvz_replace
(
temp
,
"$VEID"
,
veid_str
)))
goto
no_memory
;
VIR_FREE
(
veid_str
);
}
fs
->
dst
=
strdup
(
"/"
);
if
(
VIR_STRDUP
(
fs
->
dst
,
"/"
)
<
0
)
goto
error
;
param
=
"DISKSPACE"
;
ret
=
openvzReadVPSConfigParam
(
veid
,
param
,
&
temp
);
...
...
@@ -451,9 +450,6 @@ openvzReadFSConf(virDomainDefPtr def,
}
}
if
(
fs
->
src
==
NULL
||
fs
->
dst
==
NULL
)
goto
no_memory
;
if
(
VIR_REALLOC_N
(
def
->
fss
,
def
->
nfss
+
1
)
<
0
)
goto
no_memory
;
def
->
fss
[
def
->
nfss
++
]
=
fs
;
...
...
@@ -607,10 +603,10 @@ int openvzLoadDomains(struct openvz_driver *driver) {
goto
cleanup
;
}
if
(
!
(
def
->
os
.
type
=
strdup
(
"exe"
))
)
goto
no_memory
;
if
(
!
(
def
->
os
.
init
=
strdup
(
"/sbin/init"
))
)
goto
no_memory
;
if
(
VIR_STRDUP
(
def
->
os
.
type
,
"exe"
)
<
0
)
goto
cleanup
;
if
(
VIR_STRDUP
(
def
->
os
.
init
,
"/sbin/init"
)
<
0
)
goto
cleanup
;
ret
=
openvzReadVPSConfigParam
(
veid
,
"CPUS"
,
&
temp
);
if
(
ret
<
0
)
{
...
...
@@ -800,8 +796,7 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
saveptr
=
NULL
;
if
((
token
=
strtok_r
(
sf
,
"
\"\t\n
"
,
&
saveptr
))
!=
NULL
)
{
VIR_FREE
(
*
value
);
*
value
=
strdup
(
token
);
if
(
*
value
==
NULL
)
{
if
(
VIR_STRDUP
(
*
value
,
token
)
<
0
)
{
err
=
1
;
break
;
}
...
...
@@ -952,14 +947,18 @@ openvzLocateConfDir(void)
{
const
char
*
conf_dir_list
[]
=
{
"/etc/vz/conf"
,
"/usr/local/etc/conf"
,
NULL
};
int
i
=
0
;
char
*
ret
=
NULL
;
while
(
conf_dir_list
[
i
])
{
if
(
!
access
(
conf_dir_list
[
i
],
F_OK
))
return
strdup
(
conf_dir_list
[
i
]);
if
(
!
access
(
conf_dir_list
[
i
],
F_OK
))
{
ignore_value
(
VIR_STRDUP
(
ret
,
conf_dir_list
[
i
]));
goto
cleanup
;
}
i
++
;
}
return
NULL
;
cleanup:
return
ret
;
}
/* Richard Steven's classic readline() function */
...
...
src/openvz/openvz_driver.c
浏览文件 @
1f5deed9
...
...
@@ -94,13 +94,8 @@ openvzDomainDefPostParse(virDomainDefPtr def,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
/* fill the init path */
if
(
STREQ
(
def
->
os
.
type
,
"exe"
)
&&
!
def
->
os
.
init
)
{
if
(
!
(
def
->
os
.
init
=
strdup
(
"/sbin/init"
)))
{
virReportOOMError
();
return
-
1
;
}
}
if
(
STREQ
(
def
->
os
.
type
,
"exe"
)
&&
!
def
->
os
.
init
)
return
VIR_STRDUP
(
def
->
os
.
init
,
"/sbin/init"
)
<
0
?
-
1
:
0
;
return
0
;
}
...
...
@@ -356,8 +351,7 @@ static char *openvzDomainGetOSType(virDomainPtr dom)
goto
cleanup
;
}
if
(
!
(
ret
=
strdup
(
vm
->
def
->
os
.
type
)))
virReportOOMError
();
ignore_value
(
VIR_STRDUP
(
ret
,
vm
->
def
->
os
.
type
));
cleanup:
if
(
vm
)
...
...
@@ -768,14 +762,14 @@ cleanup:
static
char
*
openvzGenerateVethName
(
int
veid
,
char
*
dev_name_ve
)
{
char
dev_name
[
32
];
int
ifNo
=
0
;
char
*
ret
;
if
(
sscanf
(
dev_name_ve
,
"%*[^0-9]%d"
,
&
ifNo
)
!=
1
)
return
NULL
;
if
(
snprintf
(
dev_name
,
sizeof
(
dev_name
),
"veth%d.%d"
,
veid
,
ifNo
)
<
7
)
return
NULL
;
return
strdup
(
dev_name
)
;
if
(
virAsprintf
(
&
ret
,
"veth%d.%d."
,
veid
,
ifNo
)
<
0
)
virReportOOMError
()
;
return
ret
;
}
static
char
*
...
...
@@ -786,7 +780,7 @@ openvzGenerateContainerVethName(int veid)
/* try to get line "^NETIF=..." from config */
if
(
openvzReadVPSConfigParam
(
veid
,
"NETIF"
,
&
temp
)
<=
0
)
{
name
=
strdup
(
"eth0"
);
ignore_value
(
VIR_STRDUP
(
name
,
"eth0"
)
);
}
else
{
char
*
saveptr
=
NULL
;
char
*
s
;
...
...
@@ -801,15 +795,12 @@ openvzGenerateContainerVethName(int veid)
}
/* set new name */
ignore_value
(
virAsprintf
(
&
name
,
"eth%d"
,
max
+
1
));
if
(
virAsprintf
(
&
name
,
"eth%d"
,
max
+
1
)
<
0
)
virReportOOMError
();
}
VIR_FREE
(
temp
);
if
(
name
==
NULL
)
{
virReportOOMError
();
}
return
name
;
}
...
...
@@ -1601,10 +1592,8 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
continue
;
}
snprintf
(
vpsname
,
sizeof
(
vpsname
),
"%d"
,
veid
);
if
(
!
(
names
[
got
]
=
strdup
(
vpsname
)))
{
virReportOOMError
();
if
(
VIR_STRDUP
(
names
[
got
],
vpsname
)
<
0
)
goto
out
;
}
got
++
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录