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

Ján Tomko jtomko at redhat.com
Mon Sep 23 12:36:35 UTC 2019


On Mon, Sep 23, 2019 at 02:44:25PM +0400, marcandre.lureau at redhat.com wrote:
>From: Marc-André Lureau <marcandre.lureau at redhat.com>
>
>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 at redhat.com>
>---
> 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 at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190923/aa8777e6/attachment-0001.sig>


More information about the libvir-list mailing list