Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/qemu-vm: Option to use squashfs Nix store closure instead of virtfs access to host's store #72354

Open
wants to merge 6 commits into
base: staging
from

Conversation

@chkno
Copy link
Contributor

chkno commented Oct 31, 2019

Motivation for this change

Allow VMs built with nixos-rebuild build-vm to work without any virtfs mounts into the host. In particular, allow them to use a nix store closure in a squashfs like the installer uses.

This allows better isolation of guests. A host that runs multiple VMs may not wish the guests to be able to see each others' derivations.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review rev --branch staging HEAD" -- It's zero packages, but this refactoring touches all the NixOS tests. I ran a handful of existing ones.
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after) -- N/A?
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
chkno added 5 commits Oct 30, 2019
When the store is not shared, the closure used in the VM it is packaged
up in a squashfs, just like the ISO installer does.
This allows other parts of this .nix file to know which disk will end up
in which position.  Presently, there is only one sometimes-there
sometimes-not disk -- the boot disk.  But the following commit which
adds the shareNixStore option adds a second sometimes-there
sometimes-not disk, and also needs to know what device name that disk
will have inside the VM, which is determined by the device order.
This change allows device names to be determined.

(We will need to know the device name inside the VM because squashfs
does not support volume labels or UUIDs.  Feature requests about that:
  https://sourceforge.net/p/squashfs/feature-requests/36/
  plougher/squashfs-tools#59
)
@chkno chkno force-pushed the chkno:qemu-vm-isolation branch from b6be77a to 12cf6fe Nov 1, 2019
@chkno chkno force-pushed the chkno:qemu-vm-isolation branch from 12cf6fe to 588aaba Nov 1, 2019
@chkno

This comment has been minimized.

Copy link
Contributor Author

chkno commented Nov 1, 2019

(Rebased on top of #72342 so the NixOS tests can run)

@chkno

This comment has been minimized.

Copy link
Contributor Author

chkno commented Nov 1, 2019

@GrahamcOfBorg test qemu-private-store

@matthewbauer matthewbauer requested review from aanderse, samueldr and Infinisil Nov 3, 2019
@matthewbauer

This comment has been minimized.

Copy link
Member

matthewbauer commented Nov 3, 2019

@GrahamcOfBorg test qemu-private-store

Copy link
Member

matthewbauer left a comment

This all looks like a good idea, though I don't have enough familiarity to really judge whether this breaks anything. Requested a few more people to review.

@matthewbauer matthewbauer requested review from bjornfor and cleverca22 Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.