Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
c6e8e26e
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看板
提交
c6e8e26e
编写于
8月 31, 2010
作者:
E
Eric Blake
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
openvz: formatting cleanups
* src/openvz/openvz_conf.c: Whitespace fixes. * src/openvz/openvz_driver.c: Likewise.
上级
ff829416
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
46 deletion
+47
-46
src/openvz/openvz_conf.c
src/openvz/openvz_conf.c
+35
-35
src/openvz/openvz_driver.c
src/openvz/openvz_driver.c
+12
-11
未找到文件。
src/openvz/openvz_conf.c
浏览文件 @
c6e8e26e
...
...
@@ -64,7 +64,7 @@ strtoI(const char *str)
int
val
;
if
(
virStrToLong_i
(
str
,
NULL
,
10
,
&
val
)
<
0
)
return
0
;
return
0
;
return
val
;
}
...
...
@@ -338,7 +338,7 @@ openvz_replace(const char* str,
from_len
=
strlen
(
from
);
to_len
=
strlen
(
to
);
while
((
offset
=
strstr
(
str_start
,
from
)))
while
((
offset
=
strstr
(
str_start
,
from
)))
{
virBufferAdd
(
&
buf
,
str_start
,
offset
-
str_start
);
virBufferAdd
(
&
buf
,
to
,
to_len
);
...
...
@@ -447,7 +447,7 @@ int openvzLoadDomains(struct openvz_driver *driver) {
return
-
1
;
}
while
(
!
feof
(
fp
))
{
while
(
!
feof
(
fp
))
{
if
(
fscanf
(
fp
,
"%d %s
\n
"
,
&
veid
,
status
)
!=
2
)
{
if
(
feof
(
fp
))
break
;
...
...
@@ -556,7 +556,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
{
char
*
temp_file
=
NULL
;
int
fd
=
-
1
,
temp_fd
=
-
1
;
char
line
[
PATH_MAX
]
;
char
line
[
PATH_MAX
];
if
(
virAsprintf
(
&
temp_file
,
"%s.tmp"
,
conf_file
)
<
0
)
{
virReportOOMError
();
...
...
@@ -572,7 +572,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
goto
error
;
}
while
(
1
)
{
while
(
1
)
{
if
(
openvz_readline
(
fd
,
line
,
sizeof
(
line
))
<=
0
)
break
;
...
...
@@ -606,7 +606,7 @@ error:
close
(
fd
);
if
(
temp_fd
!=
-
1
)
close
(
temp_fd
);
if
(
temp_file
)
if
(
temp_file
)
unlink
(
temp_file
);
VIR_FREE
(
temp_file
);
return
-
1
;
...
...
@@ -626,9 +626,9 @@ openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value)
static
int
openvzReadConfigParam
(
const
char
*
conf_file
,
const
char
*
param
,
char
*
value
,
int
maxlen
)
{
char
line
[
PATH_MAX
]
;
char
line
[
PATH_MAX
];
int
ret
,
found
=
0
;
int
fd
;
int
fd
;
char
*
sf
,
*
token
;
char
*
saveptr
=
NULL
;
...
...
@@ -638,16 +638,16 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
if
(
fd
==
-
1
)
return
-
1
;
while
(
1
)
{
while
(
1
)
{
ret
=
openvz_readline
(
fd
,
line
,
sizeof
(
line
));
if
(
ret
<=
0
)
if
(
ret
<=
0
)
break
;
saveptr
=
NULL
;
if
(
STREQLEN
(
line
,
param
,
strlen
(
param
)))
{
sf
=
line
;
sf
+=
strlen
(
param
);
if
(
sf
[
0
]
==
'='
&&
sf
[
1
]
!=
'\0'
)
{
sf
++
;
sf
++
;
if
((
token
=
strtok_r
(
sf
,
"
\"\t\n
"
,
&
saveptr
))
!=
NULL
)
{
if
(
virStrcpy
(
value
,
token
,
maxlen
)
==
NULL
)
{
ret
=
-
1
;
...
...
@@ -663,7 +663,7 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
if
(
ret
==
0
&&
found
)
ret
=
1
;
return
ret
;
return
ret
;
}
/*
...
...
@@ -676,7 +676,7 @@ openvzReadConfigParam(const char * conf_file ,const char * param, char *value, i
int
openvzReadVPSConfigParam
(
int
vpsid
,
const
char
*
param
,
char
*
value
,
int
maxlen
)
{
char
conf_file
[
PATH_MAX
]
;
char
conf_file
[
PATH_MAX
];
if
(
openvzLocateConfFile
(
vpsid
,
conf_file
,
PATH_MAX
,
"conf"
)
<
0
)
return
-
1
;
...
...
@@ -700,7 +700,7 @@ openvz_copyfile(char* from_path, char* to_path)
return
-
1
;
}
while
(
1
)
{
while
(
1
)
{
if
(
openvz_readline
(
fd
,
line
,
sizeof
(
line
))
<=
0
)
break
;
...
...
@@ -739,7 +739,8 @@ openvzCopyDefaultConfig(int vpsid)
char
conf_file
[
PATH_MAX
];
int
ret
=
-
1
;
if
(
openvzReadConfigParam
(
VZ_CONF_FILE
,
"CONFIGFILE"
,
configfile_value
,
PATH_MAX
)
<
0
)
if
(
openvzReadConfigParam
(
VZ_CONF_FILE
,
"CONFIGFILE"
,
configfile_value
,
PATH_MAX
)
<
0
)
goto
cleanup
;
confdir
=
openvzLocateConfDir
();
...
...
@@ -792,10 +793,10 @@ static char
const
char
*
conf_dir_list
[]
=
{
"/etc/vz/conf"
,
"/usr/local/etc/conf"
,
NULL
};
int
i
=
0
;
while
(
conf_dir_list
[
i
])
{
if
(
!
access
(
conf_dir_list
[
i
],
F_OK
))
while
(
conf_dir_list
[
i
])
{
if
(
!
access
(
conf_dir_list
[
i
],
F_OK
))
return
strdup
(
conf_dir_list
[
i
]);
i
++
;
i
++
;
}
return
NULL
;
...
...
@@ -808,14 +809,13 @@ openvz_readline(int fd, char *ptr, int maxlen)
int
n
,
rc
;
char
c
;
for
(
n
=
1
;
n
<
maxlen
;
n
++
)
{
if
(
(
rc
=
read
(
fd
,
&
c
,
1
))
==
1
)
{
for
(
n
=
1
;
n
<
maxlen
;
n
++
)
{
if
(
(
rc
=
read
(
fd
,
&
c
,
1
))
==
1
)
{
*
ptr
++
=
c
;
if
(
c
==
'\n'
)
if
(
c
==
'\n'
)
break
;
}
else
if
(
rc
==
0
)
{
if
(
n
==
1
)
}
else
if
(
rc
==
0
)
{
if
(
n
==
1
)
return
0
;
/* EOF condition */
else
break
;
...
...
@@ -839,20 +839,20 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
int
retval
=
0
;
if
(
openvzLocateConfFile
(
vpsid
,
conf_file
,
PATH_MAX
,
"conf"
)
<
0
)
return
-
1
;
return
-
1
;
fd
=
open
(
conf_file
,
O_RDONLY
);
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
return
-
1
;
while
(
1
)
{
while
(
1
)
{
ret
=
openvz_readline
(
fd
,
line
,
sizeof
(
line
));
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
close
(
fd
);
return
-
1
;
}
if
(
ret
==
0
)
{
/* EoF, UUID was not found */
if
(
ret
==
0
)
{
/* EoF, UUID was not found */
uuidstr
[
0
]
=
0
;
break
;
}
...
...
@@ -884,7 +884,7 @@ openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
return
-
1
;
if
(
openvzLocateConfFile
(
vpsid
,
conf_file
,
PATH_MAX
,
"conf"
)
<
0
)
return
-
1
;
return
-
1
;
if
(
openvzGetVPSUUID
(
vpsid
,
uuidstr
,
sizeof
(
uuidstr
)))
return
-
1
;
...
...
@@ -892,7 +892,7 @@ openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
if
(
uuidstr
[
0
]
==
0
)
{
FILE
*
fp
=
fopen
(
conf_file
,
"a"
);
/* append */
if
(
fp
==
NULL
)
return
-
1
;
return
-
1
;
virUUIDFormat
(
uuid
,
uuidstr
);
...
...
@@ -939,16 +939,16 @@ static int openvzAssignUUIDs(void)
return
-
1
;
dp
=
opendir
(
conf_dir
);
if
(
dp
==
NULL
)
{
if
(
dp
==
NULL
)
{
VIR_FREE
(
conf_dir
);
return
0
;
}
while
((
dent
=
readdir
(
dp
)))
{
while
((
dent
=
readdir
(
dp
)))
{
res
=
sscanf
(
dent
->
d_name
,
"%d.%5s"
,
&
vpsid
,
ext
);
if
(
!
(
res
==
2
&&
STREQ
(
ext
,
"conf"
)))
if
(
!
(
res
==
2
&&
STREQ
(
ext
,
"conf"
)))
continue
;
if
(
vpsid
>
0
)
/* '0.conf' belongs to the host, ignore it */
if
(
vpsid
>
0
)
/* '0.conf' belongs to the host, ignore it */
openvzSetUUID
(
vpsid
);
}
closedir
(
dp
);
...
...
src/openvz/openvz_driver.c
浏览文件 @
c6e8e26e
...
...
@@ -88,8 +88,7 @@ struct openvz_driver ovz_driver;
static
void
cmdExecFree
(
const
char
*
cmdExec
[])
{
int
i
=-
1
;
while
(
cmdExec
[
++
i
])
{
while
(
cmdExec
[
++
i
])
{
VIR_FREE
(
cmdExec
[
i
]);
}
}
...
...
@@ -226,7 +225,7 @@ static int openvzSetInitialConfig(virDomainDefPtr vmdef)
vmdef
->
fss
[
0
]
->
type
==
VIR_DOMAIN_FS_TYPE_MOUNT
)
{
if
(
virStrToLong_i
(
vmdef
->
name
,
NULL
,
10
,
&
vpsid
)
<
0
)
{
if
(
virStrToLong_i
(
vmdef
->
name
,
NULL
,
10
,
&
vpsid
)
<
0
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Could not convert domain name to VEID"
));
goto
cleanup
;
...
...
@@ -802,7 +801,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
//TODO: processing NAT and physical device
if
(
prog
[
0
]
!=
NULL
){
if
(
prog
[
0
]
!=
NULL
)
{
ADD_ARG_LIT
(
"--save"
);
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -1397,15 +1396,16 @@ static int openvzListDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
ret
=
virExec
(
cmd
,
NULL
,
NULL
,
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZLIST
);
return
-
1
;
}
while
(
got
<
nids
)
{
while
(
got
<
nids
)
{
ret
=
openvz_readline
(
outfd
,
buf
,
32
);
if
(
!
ret
)
break
;
if
(
!
ret
)
break
;
if
(
virStrToLong_i
(
buf
,
&
endptr
,
10
,
&
veid
)
<
0
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not parse VPS ID %s"
),
buf
);
...
...
@@ -1443,15 +1443,16 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
/* the -S options lists only stopped domains */
ret
=
virExec
(
cmd
,
NULL
,
NULL
,
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZLIST
);
return
-
1
;
}
while
(
got
<
nnames
)
{
while
(
got
<
nnames
)
{
ret
=
openvz_readline
(
outfd
,
buf
,
32
);
if
(
!
ret
)
break
;
if
(
!
ret
)
break
;
if
(
virStrToLong_i
(
buf
,
&
endptr
,
10
,
&
veid
)
<
0
)
{
openvzError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not parse VPS ID %s"
),
buf
);
...
...
@@ -1491,7 +1492,7 @@ Version: 2.2
return
-
1
;
/*search line with VEID=vpsid*/
while
(
1
)
{
while
(
1
)
{
ret
=
openvz_readline
(
fd
,
line
,
sizeof
(
line
));
if
(
ret
<=
0
)
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录