Re: [PATCH v5 02/20] qemu-interop: ignore non-readable directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 23, 2019 at 02:44:25PM +0400, marcandre.lureau@xxxxxxxxxx wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

Whether a directory is missing or is not readable doesn't make much
difference when populating the available configs.

This removes errors when firmare or vhost-user config is looked up
from a user session libvirt if /etc/libvirt is not readable for ex.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
src/qemu/qemu_interop_config.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_interop_config.c b/src/qemu/qemu_interop_config.c
index 1f39d4b576..f3c5d2e083 100644
--- a/src/qemu/qemu_interop_config.c
+++ b/src/qemu/qemu_interop_config.c
@@ -41,8 +41,14 @@ qemuBuildFileList(virHashTablePtr files, const char *dir)
    int rc;
    int ret = -1;

-    if ((rc = virDirOpenIfExists(&dirp, dir)) < 0)
+    if ((rc = virDirOpenIfExists(&dirp, dir)) < 0) {
+        /* silently ignore unreadable directories */

This will not be silent - virDirOpenIfExists already logged an error.

You can call virFileExists upfront - which is just a wrapper to access
and then take virDirOpenIfExists errors seriously - if someone changes
the permissions in the meantime, they deserve the error.

+        if (virLastErrorIsSystemErrno(EACCES)) {
+            virResetLastError();
+            return 0;
+        }
        return -1;
+    }


With that fixed:
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux