vmtest icon indicating copy to clipboard operation
vmtest copied to clipboard

"file not found" on temporary files with host /tmp usage

Open d-e-s-o opened this issue 1 year ago • 5 comments

After https://github.com/danobi/vmtest/commit/0a63dce0e073273ba79c8dd4bfba10b571bcbd09 I am seeing test failures when working with temporary files (everything works if I back the commit out). For example:

  use tempfile::tempfile;

  #[test]
  fn foobar() {
    let file = tempfile().unwrap();
    let _meta = file.metadata().unwrap();
  }

when run in with something like:

vmtest -k /tmp/bzImage-v6.6-empty -- foobar-9a2323dd7af7c821

fails with:

thread 'tests::foobar' panicked at src/main.rs:15:33:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I tried that or similar things on three different systems, leading me to believe this isn't exactly specific to my setup. I suspect this is some sort of limitation of 9P fs, but don't know much about it. The error disappears when using a named temporary file.

Any ideas? Temporary files seem pretty important for testing. I can work around it by setting TMPDIR=/var/run/ inside the VM, but it's not great. And there are still other issues of similar but potentially slightly different nature that this does not resolve. So perhaps we should go back to using a dedicated tmpfs after all? :-(

d-e-s-o avatar Aug 21 '24 20:08 d-e-s-o

Just found this issue: https://gitlab.com/qemu-project/qemu/-/issues/103

d-e-s-o avatar Aug 21 '24 21:08 d-e-s-o

Just found this issue: https://gitlab.com/qemu-project/qemu/-/issues/103

In light of this revelation of sadness, here are perhaps a few other options aside from revert:

  • add support for configuring a dedicated tmpfs overwriting a host path (I don't think this is possible currently, but haven't studied the config options too closely)
    • I suppose that ultimately it will come down to what default we want to have: /tmp/ files accessible by default with 9P bugs present, or isolation with proper behavior
  • switch to a different file system for accessing host stuff (no idea what else there is, to be honest)

Edit:

  • rebasing Greg's Qemu patches to see if that fixes the issue
  • seems to be a major PITA for someone not familiar with the code base, but would be good impacc

d-e-s-o avatar Aug 21 '24 21:08 d-e-s-o

Did you give the qemu patches a try?

We could also try to switch to virtiofs. I believe that's the successor to this 9pfs use case.

https://virtio-fs.gitlab.io/ Also #16

danobi avatar Aug 22 '24 17:08 danobi

I tried rebasing the Qemu patches, but put it on hold for now, as it's a major effort. Haven't decided if I will spent the time on them, given that it's not even clear it would solve the issue. The original set was based off of 2.6.50 or something like that (>8 years old at this point).

As interesting, yeah, virtiofs looks promising.

danielocfb avatar Aug 22 '24 22:08 danielocfb

FWIW, I ran the same tests that we causing trouble with https://github.com/danobi/vmtest/pull/88 and there were no issues.

danielocfb avatar Aug 29 '24 18:08 danielocfb