From 487520ff741cdfb8dc1c2c58d5d407811ef43b72 Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Wed, 13 May 2020 16:04:19 +0200 Subject: [PATCH] qemu: Report all errors on virtiofsd execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The virtiofs daemon may run into errors other than the file not existing, e.g. the file may not be executable. Fixes: #2682 Message is now: virtiofs daemon /usr/local/bin/hello returned with error: fork/exec /usr/local/bin/virtiofsd: permission denied instead of panic: runtime error: invalid memory address or nil Fixes: #2582 Message is now: virtiofs daemon /usr/local/bin/hello-not-found returned with error: fork/exec /usr/local/bin/hello-not-found: no such file or directory instead of: virtiofsd path (/usr/local/bin/hello-no-found) does not exist Signed-off-by: Christophe de Dinechin Signed-off-by: Fabiano FidĂȘncio --- src/runtime/virtcontainers/qemu.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/runtime/virtcontainers/qemu.go b/src/runtime/virtcontainers/qemu.go index fca0e57dee..2d04123442 100644 --- a/src/runtime/virtcontainers/qemu.go +++ b/src/runtime/virtcontainers/qemu.go @@ -646,10 +646,6 @@ func (q *qemu) setupVirtiofsd() (err error) { var listener *net.UnixListener var fd *os.File - if _, err = os.Stat(q.config.VirtioFSDaemon); os.IsNotExist(err) { - return fmt.Errorf("virtiofsd path (%s) does not exist", q.config.VirtioFSDaemon) - } - sockPath, err := q.vhostFSSocketPath(q.id) if err != nil { return err @@ -680,9 +676,10 @@ func (q *qemu) setupVirtiofsd() (err error) { } err = cmd.Start() - if err == nil { - q.state.VirtiofsdPid = cmd.Process.Pid + if err != nil { + return fmt.Errorf("virtiofs daemon %v returned with error: %v", q.config.VirtioFSDaemon, err) } + q.state.VirtiofsdPid = cmd.Process.Pid fd.Close() // Monitor virtiofsd's stderr and stop sandbox if virtiofsd quits