Skip to content

Log file-handle-caused errors

This series makes virtiofsd log errors that are caused by file handles, specifically those that indicate a configuration problem on the user’s end (or a bug in virtiofsd, let’s be honest):

  • When some filesystem doesn’t support file handles
  • When we have trouble opening a mount FD for a given mount ID, i.e. when we cannot make a file handle openable

The second point has already caused problems in the past, where sandbox=none and sandbox=chroot modes (in some configurations) caused errors (because of bugs), resulting in a silent fallback to O_PATH FDs, which then caused suboptimal interactions with NFS. It would have been nice if virtiofsd had logged some warning there.

These errors are logged only once per filesystem, so the log isn’t spammed with them.

To make this work, this series introduces a new error type file_handle::MPRError (MPR stands for “mount-point-related”) that encapsulates an io::Error, a string describing the circumstance, and a description of the offending FS (by mount ID and mount root path[1]). Objects of this type are generally generated through a new MountFds::error_on() method that ensures that only one error is logged per mount ID.

[1] Note that the mount root path is in virtiofsd’s namespace and chroot environment, so the shared directory prefix is stripped from it (unless in sandbox=none mode). I wasn’t sure whether we should re-prepend the shared directory path for logging, so I didn’t. Should we?

Merge request reports