]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: use virDirRead API
authorEric Blake <eblake@redhat.com>
Fri, 25 Apr 2014 20:45:49 +0000 (14:45 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 28 Apr 2014 23:52:45 +0000 (17:52 -0600)
commitac1d42ac7226008ea0903569fe04c131fc2a829a
treef9e8fa56d53f2b5528d2beb5e90b5c85dfd319d8
parent6b9f40e856b7bf40078c5a3e1e225533d9799ca7
util: use virDirRead API

In making the conversion to the new API, I fixed a couple bugs:
virSCSIDeviceGetSgName would leak memory if a directory
unexpectedly contained multiple entries;
virNetDevTapGetRealDeviceName could report a spurious error
from a stale errno inherited before starting the readdir search.

The decision on whether to store the result of virDirRead into
a variable is based on whether the end of the loop falls through
to cleanup code automatically.  In some cases, we have loops that
are documented to return NULL on failure, and which raise an
error on most failure paths but not in the case where the directory
was unexpectedly empty; it may be worth a followup patch to
explicitly report an error if readdir was successful but the
directory was empty, so that a NULL return always has an error set.

* src/util/vircgroup.c (virCgroupRemoveRecursively): Use new
interface.
(virCgroupKillRecursiveInternal, virCgroupSetOwner): Report
readdir failures.
* src/util/virfile.c (virFileLoopDeviceOpenSearch)
(virFileNBDDeviceFindUnused, virFileDeleteTree): Use new
interface.
* src/util/virnetdevtap.c (virNetDevTapGetRealDeviceName):
Properly check readdir errors.
* src/util/virpci.c (virPCIDeviceIterDevices)
(virPCIDeviceFileIterate, virPCIGetNetName): Report readdir
failures.
(virPCIDeviceAddressIOMMUGroupIterate): Use new interface.
* src/util/virscsi.c (virSCSIDeviceGetSgName): Report readdir
failures, and avoid memory leak.
(virSCSIDeviceGetDevName): Report readdir failures.
* src/util/virusb.c (virUSBDeviceSearch): Report readdir
failures.
* src/util/virutil.c (virGetFCHostNameByWWN)
(virFindFCHostCapableVport): Report readdir failures.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/vircgroup.c
src/util/virfile.c
src/util/virnetdevtap.c
src/util/virpci.c
src/util/virscsi.c
src/util/virusb.c
src/util/virutil.c