1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
---
tags:
- nix
- qemu
---
`nixos-buildvm` dumps a shell script that:
Creates an empty filesystem image (qcow2) using qemu-img
A qemu KVM VM is started
```
exec /nix/store/5v70rrpzv3jwcg7ixa5k9zk0j0lai3nd-qemu-host-cpu-only-9.1.2/bin/qemu-kvm -cpu max \
-name tarrel \
-m 1024 \
-smp 1 \
-device virtio-rng-pci \
-net nic,netdev=user.0,model=virtio -netdev user,id=user.0,"$QEMU_NET_OPTS" \
-virtfs local,path=/nix/store,security_model=none,mount_tag=nix-store \
-virtfs local,path="${SHARED_DIR:-$TMPDIR/xchg}",security_model=none,mount_tag=shared \
-virtfs local,path="$TMPDIR"/xchg,security_model=none,mount_tag=xchg \
-drive cache=writeback,file="$NIX_DISK_IMAGE",id=drive1,if=none,index=1,werror=report -device virtio-blk-pci,bootindex=1,drive=drive1,serial=root \
-device virtio-keyboard \
-usb \
-device usb-tablet,bus=usb-bus.0 \
-kernel ${NIXPKGS_QEMU_KERNEL_tarrel:-/nix/store/47zad70cn0qi0pkvv21b43qwiis50lis-nixos-system-tarrel-24.11pre-git/kernel} \
-initrd /nix/store/aqbxrnk7jg7piy7g85npm9xysmrvlihw-initrd-linux-6.6.71/initrd \
-append "$(cat /nix/store/47zad70cn0qi0pkvv21b43qwiis50lis-nixos-system-tarrel-24.11pre-git/kernel-params) init=/nix/store/47zad70cn0qi0pkvv21b43qwiis50lis-nixos-system-tarrel-24.11pre-git/init regInfo=/nix/store/fii757n9q5f603hmqfdni49lskni93cb-closure-info/registration console=ttyS0,115200n8 console=tty0 $QEMU_KERNEL_PARAMS" \
$QEMU_OPTS \
"$@"
```
It shared 3 dirs from the host with the guest most notably the nix store. The disk image is used as a [[Wri]]
|