git.iko.soy/typeable/nixpkgs
on master help sign in
qemu-vm: fix inconsistent caching of xchg dirs

xchg is advertised as a bidirectional exchange dir, but file content transfer from host to VM fails due to caching: If a file is read in the VM and then modified on the host, subsequent re-reads in the VM can yield old, cached data. This is caused by the use of 9p's cache=loose mode that is explicitly meant for read-only mounts. 9p doesn't provide any suitable cache modes, so fix this by disabling caching. Also, remove a now unnecessary sync in the test driver.

commitd85dc4f6902819be8277d1d65414e51bfbef0ac6 authorErik Arvstedt <erik.arvstedt@gmail.com> dateWed 27 May 2020, 22:07 (6 years ago) parentdfa743e
4 files changed+3−4
nixos/lib/test-driver/test-driver.py−1 nixos/modules/virtualisation/qemu-vm.nix+1−1 pkgs/build-support/vm/default.nix+1−1 pkgs/build-support/vm/windows/controller/default.nix+1−1
nixos/lib/test-driver/test-driver.py−1
@@ -615,7 +615,6 @@ class Machine:
615615 # Copy the file to the shared directory inside VM
616616 self.succeed(make_command(["mkdir", "-p", vm_shared_temp]))
617617 self.succeed(make_command(["cp", "-r", vm_src, vm_intermediate]))
618− self.succeed("sync")
619618 abs_target = out_dir / target_dir / vm_src.name
620619 abs_target.parent.mkdir(exist_ok=True, parents=True)
621620 # Copy the file from the shared directory outside VM
nixos/modules/virtualisation/qemu-vm.nix+1−1
@@ -567,7 +567,7 @@ in
567567 "/tmp/xchg" =
568568 { device = "xchg";
569569 fsType = "9p";
570− options = [ "trans=virtio" "version=9p2000.L" "cache=loose" ];
570+ options = [ "trans=virtio" "version=9p2000.L" ];
571571 neededForBoot = true;
572572 };
573573 "/tmp/shared" =
pkgs/build-support/vm/default.nix+1−1
@@ -115,7 +115,7 @@ rec {
115115
116116 echo "mounting host's temporary directory..."
117117 mkdir -p /fs/tmp/xchg
118− mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L,cache=loose
118+ mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L
119119
120120 mkdir -p /fs/proc
121121 mount -t proc none /fs/proc
pkgs/build-support/vm/windows/controller/default.nix+1−1
@@ -53,7 +53,7 @@ let
5353 store /fs/nix/store
5454
5555 mount -t 9p \
56− -o trans=virtio,version=9p2000.L,cache=loose \
56+ -o trans=virtio,version=9p2000.L \
5757 xchg /fs/xchg
5858
5959 echo root:x:0:0::/root:/bin/false > /fs/etc/passwd