2018-06-30 19:18:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-06-30 19:42:31 +00:00
|
|
|
NAME=NAME_PLACEHOLDER
|
|
|
|
|
2018-06-30 19:51:56 +00:00
|
|
|
NIX_DISK_IMAGE=NIX_DISK_IMAGE_PLACEHOLDER
|
2018-06-30 19:18:21 +00:00
|
|
|
|
|
|
|
if ! test -e "$NIX_DISK_IMAGE"; then
|
|
|
|
qemu-img create -f qcow2 "$NIX_DISK_IMAGE" 512M || exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create a directory for storing temporary data of the running VM.
|
2018-06-30 20:42:11 +00:00
|
|
|
TMPDIR=$(dirname ${NIX_DISK_IMAGE})/../../share/NAME_PLACEHOLDER
|
2018-06-30 19:18:21 +00:00
|
|
|
|
|
|
|
# Create a directory for exchanging data with the VM.
|
2018-06-30 20:42:11 +00:00
|
|
|
mkdir -p $TMPDIR
|
2018-06-30 19:18:21 +00:00
|
|
|
cd $TMPDIR
|
|
|
|
|
|
|
|
NIX_SYSTEM="NIX_SYSTEM_PLACEHOLDER"
|
|
|
|
|
|
|
|
# Start QEMU.
|
|
|
|
qemu-system-x86_64 -enable-kvm \
|
2018-06-30 19:42:31 +00:00
|
|
|
-name NAME_PLACEHOLDER \
|
2018-06-30 19:18:21 +00:00
|
|
|
-m 1024 \
|
|
|
|
-smp 1 \
|
|
|
|
-device virtio-rng-pci \
|
|
|
|
-net nic,netdev=user.0,model=virtio -netdev user,id=user.0${QEMU_NET_OPTS:+,$QEMU_NET_OPTS} \
|
2018-06-30 20:01:23 +00:00
|
|
|
-spice port=PORT_PLACEHOLDER,addr=127.200.0.1,disable-ticketing,image-compression=off,seamless-migration=on \
|
2018-06-30 19:18:21 +00:00
|
|
|
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
|
|
|
|
-virtfs local,path=/nix/store,security_model=none,mount_tag=store,readonly \
|
2018-06-30 20:42:11 +00:00
|
|
|
-virtfs local,path=$TMPDIR,security_model=none,mount_tag=xchg \
|
|
|
|
-virtfs local,path=${SHARED_DIR:-$TMPDIR},security_model=none,mount_tag=shared \
|
2018-06-30 19:18:21 +00:00
|
|
|
-drive index=0,id=drive$((0 + 1)),file=$NIX_DISK_IMAGE,cache=writeback,werror=report,if=virtio \
|
|
|
|
-kernel ${NIX_SYSTEM}/kernel \
|
|
|
|
-initrd ${NIX_SYSTEM}/initrd \
|
|
|
|
-append "$(cat ${NIX_SYSTEM}/kernel-params) init=${NIX_SYSTEM}/init regInfo=/nix/store/622pn30mg7z4knkrqsh3acrjyaiyq6sr-closure-info/registration" \
|
|
|
|
-device qxl-vga,vgamem_mb=256 #-display gtk
|