Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
qemu: Report all errors on virtiofsd execution
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 4ee382c)
  • Loading branch information
c3d authored and fidencio committed Jun 24, 2020
1 parent 44887a2 commit f85a2d5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,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
Expand Down Expand Up @@ -673,9 +669,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
Expand Down

0 comments on commit f85a2d5

Please sign in to comment.