[libvirt PATCH] qemu: virtiofs: check whether the supplied binary exists

Ján Tomko posted 1 patch 2 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c1bb4c7ee36b2a1af3f3948c5c98e354ece51abc.1643307763.git.jtomko@redhat.com
src/qemu/qemu_virtiofs.c | 7 +++++++
1 file changed, 7 insertions(+)
[libvirt PATCH] qemu: virtiofs: check whether the supplied binary exists
Posted by Ján Tomko 2 years, 2 months ago
Report an error upfront if the binary does not exist
or is not executable.

https://bugzilla.redhat.com/show_bug.cgi?id=1999372

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_virtiofs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
index 1b853a5a59..7e3324b017 100644
--- a/src/qemu/qemu_virtiofs.c
+++ b/src/qemu/qemu_virtiofs.c
@@ -184,6 +184,13 @@ qemuVirtioFSStart(virQEMUDriver *driver,
     VIR_AUTOCLOSE logfd = -1;
     int rc;
 
+    if (!virFileIsExecutable(fs->binary)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("virtiofsd binary '%s' is not executable"),
+                       fs->binary);
+        return -1;
+    }
+
     if (!virFileExists(fs->src->path)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("the virtiofs export directory '%s' does not exist"),
-- 
2.31.1

Re: [libvirt PATCH] qemu: virtiofs: check whether the supplied binary exists
Posted by Andrea Bolognani 2 years, 1 month ago
On Thu, Jan 27, 2022 at 07:22:50PM +0100, Ján Tomko wrote:
> Report an error upfront if the binary does not exist
> or is not executable.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1999372
>
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_virtiofs.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization