How to share files between the host and guests of a NixOS test

512 views
Skip to first unread message

Bas van Dijk

unread,
Sep 5, 2017, 11:38:23 AM9/5/17
to nix-devel
I'm debugging a NixOS test and I would like to transfer some files from the qemu guests to the host.

I see the guests have a 9p filesystem mounted on /tmp/shared. Is that available from the host?

Alternatively I thought of mounting the root file system of the VM using guestmount from libguestfs. The NixOS manual mentions[1] that when you run the VMs using ./result/bin/nixos-run-vms the root file system of the VMs is created on the fly and kept across VM restarts in ./hostname.qcow2. However I don't see the .qcow2 files in my working directory when I run that command. Where are they created?

Leo Gaspard

unread,
Sep 5, 2017, 1:11:07 PM9/5/17
to nix-...@googlegroups.com
According to the file in `result/bin/run-*-vm` after a `nixos-rebuild
build-vm`, `/tmp/shared` in the guest seems to be equivalent in the host
to the file in `$SHARED_DIR` or, if this variable is not defined, in
`/tmp/nix-vm.*/xchg`

HTH,
Leo
> --
> You received this message because you are subscribed to the Google
> Groups "nix-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nix-devel+...@googlegroups.com
> <mailto:nix-devel+...@googlegroups.com>.
> To post to this group, send email to nix-...@googlegroups.com
> <mailto:nix-...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nix-devel/CADLz5wU3t0do2wDpC%2BdA%2BDsEPbYQvRE8TNyJzBLmffRH%3DJfpdw%40mail.gmail.com
> <https://groups.google.com/d/msgid/nix-devel/CADLz5wU3t0do2wDpC%2BdA%2BDsEPbYQvRE8TNyJzBLmffRH%3DJfpdw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Bas van Dijk

unread,
Sep 5, 2017, 2:58:55 PM9/5/17
to Leo Gaspard, nix-devel
Thanks Leo, I see that /tmp/xchg in the guest is equivalent to /tmp/vm-state-$name/xchg on the host. That solves my problem.

On 5 September 2017 at 19:11, Leo Gaspard <l...@gaspard.io> wrote:
According to the file in `result/bin/run-*-vm` after a `nixos-rebuild
build-vm`, `/tmp/shared` in the guest seems to be equivalent in the host
to the file in `$SHARED_DIR` or, if this variable is not defined, in
`/tmp/nix-vm.*/xchg`

HTH,
Leo


On 09/05/2017 05:38 PM, Bas van Dijk wrote:
> I'm debugging a NixOS test and I would like to transfer some files from
> the qemu guests to the host.
>
> I see the guests have a 9p filesystem mounted on /tmp/shared. Is that
> available from the host?
>
> Alternatively I thought of mounting the root file system of the VM using
> guestmount from libguestfs. The NixOS manual mentions[1] that when you
> run the VMs using ./result/bin/nixos-run-vms the root file system of the
> VMs is created on the fly and kept across VM restarts in
> ./hostname.qcow2. However I don't see the .qcow2 files in my working
> directory when I run that command. Where are they created?
>
> Bas
>
> [1] https://nixos.org/nixos/manual/index.html#sec-running-nixos-tests
>
> --
> You received this message because you are subscribed to the Google
> Groups "nix-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send

> To post to this group, send email to nix-...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "nix-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nix-devel+unsubscribe@googlegroups.com.
To post to this group, send email to nix-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nix-devel/c9233e69-defb-abee-6a57-b159310984a9%40gaspard.io.
Reply all
Reply to author
Forward
0 new messages