Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
42b4a37d
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看板
提交
42b4a37d
编写于
6月 21, 2016
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use virDirOpenIfExists
Use it instead of opendir everywhere we need to check for ENOENT.
上级
941ccbc1
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
35 addition
and
83 deletion
+35
-83
src/conf/network_conf.c
src/conf/network_conf.c
+6
-15
src/conf/nwfilter_conf.c
src/conf/nwfilter_conf.c
+3
-7
src/conf/storage_conf.c
src/conf/storage_conf.c
+6
-14
src/conf/virdomainobjlist.c
src/conf/virdomainobjlist.c
+3
-8
src/conf/virsecretobj.c
src/conf/virsecretobj.c
+3
-6
src/network/bridge_driver.c
src/network/bridge_driver.c
+3
-8
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+1
-7
src/util/vircgroup.c
src/util/vircgroup.c
+6
-8
src/util/virnuma.c
src/util/virnuma.c
+4
-10
未找到文件。
src/conf/network_conf.c
浏览文件 @
42b4a37d
...
...
@@ -3236,14 +3236,10 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
=
-
1
;
int
rc
;
if
(
!
(
dir
=
opendir
(
stateDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
stateDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
stateDir
))
<=
0
)
return
rc
;
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
stateDir
))
>
0
)
{
virNetworkObjPtr
net
;
...
...
@@ -3267,15 +3263,10 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
=
-
1
;
int
rc
;
if
(
!
(
dir
=
opendir
(
configDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
configDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
configDir
))
<=
0
)
return
rc
;
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
configDir
))
>
0
)
{
virNetworkObjPtr
net
;
...
...
src/conf/nwfilter_conf.c
浏览文件 @
42b4a37d
...
...
@@ -3204,14 +3204,10 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
=
-
1
;
int
rc
;
if
(
!
(
dir
=
opendir
(
configDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
configDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
configDir
))
<=
0
)
return
rc
;
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
configDir
))
>
0
)
{
virNWFilterObjPtr
nwfilter
;
...
...
src/conf/storage_conf.c
浏览文件 @
42b4a37d
...
...
@@ -1941,14 +1941,10 @@ virStoragePoolLoadAllState(virStoragePoolObjListPtr pools,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
=
-
1
;
int
rc
;
if
(
!
(
dir
=
opendir
(
stateDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
stateDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
stateDir
))
<=
0
)
return
rc
;
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
stateDir
))
>
0
)
{
virStoragePoolObjPtr
pool
;
...
...
@@ -1974,14 +1970,10 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
;
int
rc
;
if
(
!
(
dir
=
opendir
(
configDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
configDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
configDir
))
<=
0
)
return
rc
;
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
configDir
))
>
0
)
{
char
*
path
;
...
...
src/conf/virdomainobjlist.c
浏览文件 @
42b4a37d
...
...
@@ -566,17 +566,12 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
DIR
*
dir
;
struct
dirent
*
entry
;
int
ret
=
-
1
;
int
rc
;
VIR_INFO
(
"Scanning for configs in %s"
,
configDir
);
if
(
!
(
dir
=
opendir
(
configDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"Failed to open dir '%s'"
),
configDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
configDir
))
<=
0
)
return
rc
;
virObjectLock
(
doms
);
...
...
src/conf/virsecretobj.c
浏览文件 @
42b4a37d
...
...
@@ -966,13 +966,10 @@ virSecretLoadAllConfigs(virSecretObjListPtr secrets,
{
DIR
*
dir
=
NULL
;
struct
dirent
*
de
;
int
rc
;
if
(
!
(
dir
=
opendir
(
configDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"cannot open '%s'"
),
configDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
configDir
))
<=
0
)
return
rc
;
/* Ignore errors reported by readdir or other calls within the
* loop (if any). It's better to keep the secrets we managed to find. */
...
...
src/network/bridge_driver.c
浏览文件 @
42b4a37d
...
...
@@ -509,15 +509,10 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver)
struct
dirent
*
entry
;
char
*
oldPath
=
NULL
,
*
newPath
=
NULL
;
char
*
contents
=
NULL
;
int
rc
;
if
(
!
(
dir
=
opendir
(
oldStateDir
)))
{
if
(
errno
==
ENOENT
)
return
0
;
virReportSystemError
(
errno
,
_
(
"failed to open directory '%s'"
),
oldStateDir
);
return
-
1
;
}
if
((
rc
=
virDirOpenIfExists
(
&
dir
,
oldStateDir
))
<=
0
)
return
rc
;
if
(
virFileMakePath
(
driver
->
stateDir
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create directory %s"
),
...
...
src/qemu/qemu_driver.c
浏览文件 @
42b4a37d
...
...
@@ -500,14 +500,8 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
VIR_INFO("Scanning for snapshots for domain %s in %s", vm->def->name,
snapDir);
if (!(dir = opendir(snapDir))) {
if (errno != ENOENT)
virReportSystemError(errno,
_("Failed to open snapshot directory %s "
"for domain %s"),
snapDir, vm->def->name);
if (virDirOpenIfExists(&dir, snapDir) <= 0)
goto cleanup;
}
while ((direrr = virDirRead(dir, &entry, NULL)) > 0) {
/* NB: ignoring errors, so one malformed config doesn't
...
...
src/util/vircgroup.c
浏览文件 @
42b4a37d
...
...
@@ -3624,15 +3624,13 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
killedAny
=
true
;
VIR_DEBUG
(
"Iterate over children of %s (killedAny=%d)"
,
keypath
,
killedAny
);
if
(
!
(
dp
=
opendir
(
keypath
)))
{
if
(
errno
==
ENOENT
)
{
VIR_DEBUG
(
"Path %s does not exist, assuming done"
,
keypath
);
killedAny
=
false
;
goto
done
;
}
virReportSystemError
(
errno
,
_
(
"Cannot open %s"
),
keypath
);
if
((
rc
=
virDirOpenIfExists
(
&
dp
,
keypath
))
<
0
)
goto
cleanup
;
if
(
rc
==
0
)
{
VIR_DEBUG
(
"Path %s does not exist, assuming done"
,
keypath
);
killedAny
=
false
;
goto
done
;
}
while
((
direrr
=
virDirRead
(
dp
,
&
ent
,
keypath
))
>
0
)
{
...
...
src/util/virnuma.c
浏览文件 @
42b4a37d
...
...
@@ -737,16 +737,10 @@ virNumaGetPages(int node,
if
(
virNumaGetHugePageInfoDir
(
&
path
,
node
)
<
0
)
goto
cleanup
;
if
(
!
(
dir
=
opendir
(
path
)))
{
/* It's okay if the @path doesn't exist. Maybe we are running on
* system without huge pages support where the path may not exist. */
if
(
errno
!=
ENOENT
)
{
virReportSystemError
(
errno
,
_
(
"unable to open path: %s"
),
path
);
goto
cleanup
;
}
}
/* It's okay if the @path doesn't exist. Maybe we are running on
* system without huge pages support where the path may not exist. */
if
(
virDirOpenIfExists
(
&
dir
,
path
)
<
0
)
goto
cleanup
;
while
(
dir
&&
(
direrr
=
virDirRead
(
dir
,
&
entry
,
path
))
>
0
)
{
const
char
*
page_name
=
entry
->
d_name
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录