Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
e81de04c
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,发现更多精彩内容 >>
提交
e81de04c
编写于
6月 21, 2016
作者:
J
Ján Tomko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use virDirOpen
Switch from opendir to virDirOpen everywhere we need to report an error.
上级
f0ced708
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
25 addition
and
108 deletion
+25
-108
src/storage/storage_backend_fs.c
src/storage/storage_backend_fs.c
+1
-5
src/storage/storage_backend_iscsi.c
src/storage/storage_backend_iscsi.c
+1
-3
src/storage/storage_backend_scsi.c
src/storage/storage_backend_scsi.c
+3
-16
src/util/vircgroup.c
src/util/vircgroup.c
+1
-4
src/util/virfile.c
src/util/virfile.c
+3
-13
src/util/virhostcpu.c
src/util/virhostcpu.c
+1
-3
src/util/virnetdev.c
src/util/virnetdev.c
+1
-5
src/util/virnetdevtap.c
src/util/virnetdevtap.c
+1
-6
src/util/virpci.c
src/util/virpci.c
+2
-8
src/util/virprocess.c
src/util/virprocess.c
+1
-1
src/util/virscsi.c
src/util/virscsi.c
+2
-8
src/util/virusb.c
src/util/virusb.c
+1
-6
src/util/virutil.c
src/util/virutil.c
+3
-15
src/xen/xen_inotify.c
src/xen/xen_inotify.c
+2
-5
src/xen/xm_internal.c
src/xen/xm_internal.c
+1
-5
tests/virschematest.c
tests/virschematest.c
+1
-5
未找到文件。
src/storage/storage_backend_fs.c
浏览文件 @
e81de04c
...
...
@@ -900,12 +900,8 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
int
direrr
;
int
fd
=
-
1
,
ret
=
-
1
;
if
(
!
(
dir
=
opendir
(
pool
->
def
->
target
.
path
)))
{
virReportSystemError
(
errno
,
_
(
"cannot open path '%s'"
),
pool
->
def
->
target
.
path
);
if
(
virDirOpen
(
&
dir
,
pool
->
def
->
target
.
path
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
dir
,
&
ent
,
pool
->
def
->
target
.
path
))
>
0
)
{
int
err
;
...
...
src/storage/storage_backend_iscsi.c
浏览文件 @
e81de04c
...
...
@@ -100,9 +100,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
virFileWaitForDevices
();
sysdir
=
opendir
(
sysfs_path
);
if
(
sysdir
==
NULL
)
{
if
(
virDirOpen
(
&
sysdir
,
sysfs_path
)
<
0
)
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
sysfs_path
);
retval
=
-
1
;
...
...
src/storage/storage_backend_scsi.c
浏览文件 @
e81de04c
...
...
@@ -265,12 +265,8 @@ getNewStyleBlockDevice(const char *lun_path,
VIR_DEBUG
(
"Looking for block device in '%s'"
,
block_path
);
if
(
!
(
block_dir
=
opendir
(
block_path
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir sysfs path '%s'"
),
block_path
);
if
(
virDirOpen
(
&
block_dir
,
block_path
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
block_dir
,
&
block_dirent
,
block_path
))
>
0
)
{
if
(
VIR_STRDUP
(
*
block_device
,
block_dirent
->
d_name
)
<
0
)
...
...
@@ -350,12 +346,8 @@ getBlockDevice(uint32_t host,
host
,
bus
,
target
,
lun
)
<
0
)
goto
cleanup
;
if
(
!
(
lun_dir
=
opendir
(
lun_path
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir sysfs path '%s'"
),
lun_path
);
if
(
virDirOpen
(
&
lun_dir
,
lun_path
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
lun_dir
,
&
lun_dirent
,
lun_path
))
>
0
)
{
if
(
STREQLEN
(
lun_dirent
->
d_name
,
"block"
,
5
))
{
...
...
@@ -467,13 +459,8 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
virFileWaitForDevices
();
devicedir
=
opendir
(
device_path
);
if
(
devicedir
==
NULL
)
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
device_path
);
if
(
virDirOpen
(
&
devicedir
,
device_path
)
<
0
)
return
-
1
;
}
snprintf
(
devicepattern
,
sizeof
(
devicepattern
),
"%u:%%u:%%u:%%u
\n
"
,
scanhost
);
...
...
src/util/vircgroup.c
浏览文件 @
e81de04c
...
...
@@ -3952,11 +3952,8 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
cgroup
->
controllers
[
i
].
placement
)
<
0
)
goto
cleanup
;
if
(
!
(
dh
=
opendir
(
base
)))
{
virReportSystemError
(
errno
,
_
(
"Unable to open dir '%s'"
),
base
);
if
(
virDirOpen
(
&
dh
,
base
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
dh
,
&
de
,
base
))
>
0
)
{
if
(
virAsprintf
(
&
entry
,
"%s/%s"
,
base
,
de
->
d_name
)
<
0
)
...
...
src/util/virfile.c
浏览文件 @
e81de04c
...
...
@@ -614,11 +614,8 @@ static int virFileLoopDeviceOpenSearch(char **dev_name)
VIR_DEBUG
(
"Looking for loop devices in /dev"
);
if
(
!
(
dh
=
opendir
(
"/dev"
)))
{
virReportSystemError
(
errno
,
"%s"
,
_
(
"Unable to read /dev"
));
if
(
virDirOpen
(
&
dh
,
"/dev"
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
dh
,
&
de
,
"/dev"
))
>
0
)
{
/* Checking 'loop' prefix is insufficient, since
...
...
@@ -782,12 +779,8 @@ virFileNBDDeviceFindUnused(void)
struct
dirent
*
de
;
int
direrr
;
if
(
!
(
dh
=
opendir
(
SYSFS_BLOCK_DIR
)))
{
virReportSystemError
(
errno
,
_
(
"Cannot read directory %s"
),
SYSFS_BLOCK_DIR
);
if
(
virDirOpen
(
&
dh
,
SYSFS_BLOCK_DIR
)
<
0
)
return
NULL
;
}
while
((
direrr
=
virDirRead
(
dh
,
&
de
,
SYSFS_BLOCK_DIR
))
>
0
)
{
if
(
STRPREFIX
(
de
->
d_name
,
"nbd"
))
{
...
...
@@ -942,11 +935,8 @@ int virFileDeleteTree(const char *dir)
if
(
!
dir
||
!
virFileExists
(
dir
))
return
0
;
if
(
!
(
dh
=
opendir
(
dir
)))
{
virReportSystemError
(
errno
,
_
(
"Cannot open dir '%s'"
),
dir
);
if
(
virDirOpen
(
&
dh
,
dir
)
<
0
)
return
-
1
;
}
while
((
direrr
=
virDirRead
(
dh
,
&
de
,
dir
))
>
0
)
{
struct
stat
sb
;
...
...
src/util/virhostcpu.c
浏览文件 @
e81de04c
...
...
@@ -339,10 +339,8 @@ virHostCPUParseNode(const char *node,
*
cores
=
0
;
*
sockets
=
0
;
if
(
!
(
cpudir
=
opendir
(
node
)))
{
virReportSystemError
(
errno
,
_
(
"cannot opendir %s"
),
node
);
if
(
virDirOpen
(
&
cpudir
,
node
)
<
0
)
goto
cleanup
;
}
/* Keep track of the CPUs that belong to the current node */
if
(
!
(
node_cpus_map
=
virBitmapNew
(
npresent_cpus
)))
...
...
src/util/virnetdev.c
浏览文件 @
e81de04c
...
...
@@ -3157,12 +3157,8 @@ virNetDevRDMAFeature(const char *ifname,
if
(
!
virFileExists
(
SYSFS_INFINIBAND_DIR
))
return
0
;
if
(
!
(
dirp
=
opendir
(
SYSFS_INFINIBAND_DIR
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
SYSFS_INFINIBAND_DIR
);
if
(
virDirOpen
(
&
dirp
,
SYSFS_INFINIBAND_DIR
)
<
0
)
return
-
1
;
}
if
(
virAsprintf
(
&
eth_devpath
,
SYSFS_NET_DIR
"%s/device/resource"
,
ifname
)
<
0
)
goto
cleanup
;
...
...
src/util/virnetdevtap.c
浏览文件 @
e81de04c
...
...
@@ -98,13 +98,8 @@ virNetDevTapGetRealDeviceName(char *ifname ATTRIBUTE_UNUSED)
char
*
devpath
=
NULL
;
int
fd
;
DIR
*
dirp
=
opendir
(
"/dev"
);
if
(
dirp
==
NULL
)
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
"/dev"
);
if
(
virDirOpen
(
&
dirp
,
"/dev"
)
<
0
)
return
NULL
;
}
while
(
virDirRead
(
dirp
,
&
dp
,
"/dev"
)
>
0
)
{
if
(
STRPREFIX
(
dp
->
d_name
,
"tap"
))
{
...
...
src/util/virpci.c
浏览文件 @
e81de04c
...
...
@@ -460,11 +460,8 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
VIR_DEBUG
(
"%s %s: iterating over "
PCI_SYSFS
"devices"
,
dev
->
id
,
dev
->
name
);
dir
=
opendir
(
PCI_SYSFS
"devices"
);
if
(
!
dir
)
{
VIR_WARN
(
"Failed to open "
PCI_SYSFS
"devices"
);
if
(
virDirOpen
(
&
dir
,
PCI_SYSFS
"devices"
)
<
0
)
return
-
1
;
}
while
((
ret
=
virDirRead
(
dir
,
&
entry
,
PCI_SYSFS
"devices"
))
>
0
)
{
unsigned
int
domain
,
bus
,
slot
,
function
;
...
...
@@ -1958,11 +1955,8 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev,
dev
->
address
.
slot
,
dev
->
address
.
function
)
<
0
)
goto
cleanup
;
if
(
!
(
dir
=
opendir
(
pcidir
)))
{
virReportSystemError
(
errno
,
_
(
"cannot open %s"
),
pcidir
);
if
(
virDirOpen
(
&
dir
,
pcidir
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
dir
,
&
ent
,
pcidir
))
>
0
)
{
/* Device assignment requires:
...
...
src/util/virprocess.c
浏览文件 @
e81de04c
...
...
@@ -612,7 +612,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids)
(
unsigned
long
long
)
pid
)
<
0
)
goto
cleanup
;
if
(
!
(
dir
=
opendir
(
taskPath
))
)
if
(
virDirOpen
(
&
dir
,
taskPath
)
<
0
)
goto
cleanup
;
while
((
value
=
virDirRead
(
dir
,
&
ent
,
taskPath
))
>
0
)
{
...
...
src/util/virscsi.c
浏览文件 @
e81de04c
...
...
@@ -127,11 +127,8 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
prefix
,
adapter_id
,
bus
,
target
,
unit
)
<
0
)
return
NULL
;
if
(
!
(
dir
=
opendir
(
path
)))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to open %s"
),
path
);
if
(
virDirOpen
(
&
dir
,
path
)
<
0
)
goto
cleanup
;
}
while
(
virDirRead
(
dir
,
&
entry
,
path
)
>
0
)
{
/* Assume a single directory entry */
...
...
@@ -170,11 +167,8 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
prefix
,
adapter_id
,
bus
,
target
,
unit
)
<
0
)
return
NULL
;
if
(
!
(
dir
=
opendir
(
path
)))
{
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to open %s"
),
path
);
if
(
virDirOpen
(
&
dir
,
path
)
<
0
)
goto
cleanup
;
}
while
(
virDirRead
(
dir
,
&
entry
,
path
)
>
0
)
{
ignore_value
(
VIR_STRDUP
(
name
,
entry
->
d_name
));
...
...
src/util/virusb.c
浏览文件 @
e81de04c
...
...
@@ -138,13 +138,8 @@ virUSBDeviceSearch(unsigned int vendor,
if
(
!
(
list
=
virUSBDeviceListNew
()))
goto
cleanup
;
dir
=
opendir
(
USB_SYSFS
"/devices"
);
if
(
!
dir
)
{
virReportSystemError
(
errno
,
_
(
"Could not open directory %s"
),
USB_SYSFS
"/devices"
);
if
(
virDirOpen
(
&
dir
,
USB_SYSFS
"/devices"
)
<
0
)
goto
cleanup
;
}
while
((
direrr
=
virDirRead
(
dir
,
&
de
,
USB_SYSFS
"/devices"
))
>
0
)
{
unsigned
int
found_prod
,
found_vend
,
found_bus
,
found_devno
;
...
...
src/util/virutil.c
浏览文件 @
e81de04c
...
...
@@ -1860,12 +1860,8 @@ virFindSCSIHostByPCI(const char *sysfs_prefix,
char
*
unique_path
=
NULL
;
unsigned
int
read_unique_id
;
if
(
!
(
dir
=
opendir
(
prefix
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
prefix
);
if
(
virDirOpen
(
&
dir
,
prefix
)
<
0
)
return
NULL
;
}
while
(
virDirRead
(
dir
,
&
entry
,
prefix
)
>
0
)
{
if
(
!
virFileIsLink
(
entry
->
d_name
))
...
...
@@ -2198,12 +2194,8 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
char
*
p
;
char
*
ret
=
NULL
;
if
(
!
(
dir
=
opendir
(
prefix
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
prefix
);
if
(
virDirOpen
(
&
dir
,
prefix
)
<
0
)
return
NULL
;
}
# define READ_WWN(wwn_path, buf) \
do { \
...
...
@@ -2289,12 +2281,8 @@ virFindFCHostCapableVport(const char *sysfs_prefix)
char
*
state
=
NULL
;
char
*
ret
=
NULL
;
if
(
!
(
dir
=
opendir
(
prefix
)))
{
virReportSystemError
(
errno
,
_
(
"Failed to opendir path '%s'"
),
prefix
);
if
(
virDirOpen
(
&
dir
,
prefix
)
<
0
)
return
NULL
;
}
while
(
virDirRead
(
dir
,
&
entry
,
prefix
)
>
0
)
{
unsigned
int
host
;
...
...
src/xen/xen_inotify.c
浏览文件 @
e81de04c
...
...
@@ -360,12 +360,9 @@ xenInotifyOpen(virConnectPtr conn,
return
-
1
;
/* populate initial list */
if
(
!
(
dh
=
opendir
(
priv
->
configDir
)))
{
virReportSystemError
(
errno
,
_
(
"cannot open directory: %s"
),
priv
->
configDir
);
if
(
virDirOpen
(
&
dh
,
priv
->
configDir
)
<
0
)
return
-
1
;
}
while
((
direrr
=
virDirRead
(
dh
,
&
ent
,
priv
->
configDir
))
>
0
)
{
if
(
STRPREFIX
(
ent
->
d_name
,
"."
))
continue
;
...
...
src/xen/xm_internal.c
浏览文件 @
e81de04c
...
...
@@ -319,12 +319,8 @@ xenXMConfigCacheRefresh(virConnectPtr conn)
priv
->
lastRefresh
=
now
;
/* Process the files in the config dir */
if
(
!
(
dh
=
opendir
(
priv
->
configDir
)))
{
virReportSystemError
(
errno
,
_
(
"cannot read directory %s"
),
priv
->
configDir
);
if
(
virDirOpen
(
&
dh
,
priv
->
configDir
)
<
0
)
return
-
1
;
}
while
((
ret
=
virDirRead
(
dh
,
&
ent
,
priv
->
configDir
))
>
0
)
{
struct
stat
st
;
...
...
tests/virschematest.c
浏览文件 @
e81de04c
...
...
@@ -80,12 +80,8 @@ testSchemaDir(const char *schema,
.
validator
=
validator
,
};
if
(
!
(
dir
=
opendir
(
dir_path
)))
{
virReportSystemError
(
errno
,
"Failed to opendir path '%s'"
,
dir_path
);
if
(
virDirOpen
(
&
dir
,
dir_path
)
<
0
)
return
-
1
;
}
while
((
rc
=
virDirRead
(
dir
,
&
ent
,
dir_path
))
>
0
)
{
if
(
!
virFileHasSuffix
(
ent
->
d_name
,
".xml"
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录