summaryrefslogtreecommitdiff
path: root/src/qemu.sh
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2017-03-28 16:07:09 -0400
committerAndrew Cady <d@jerkface.net>2017-03-28 16:12:28 -0400
commit5160fd50cf2bf09700c20236cac992a7a85fc943 (patch)
treec4bef4cc1b8a0635222cf83b4927f5fdcdedf635 /src/qemu.sh
parent2a575328ac1432c21e0b983d2432f1f64dff0f96 (diff)
Use pxelinux "ipappend" option to choose rootfs source
This fixes the issue described in the first 'netkeys' commit, where the network would need to be available even when it was not used. The "ipappend" option results in a $BOOTIF variable in the initrd environment. This variable is now used to determine whether to wait on the network for a rootfs & keys, or to wait on the boot device becoming available to determine whether it has the keys. That is, there may or may not be a boot device which may or may not have keys and/or rootfs, but we will always know for sure whether it does, therefore there are no races and no waiting on the network unnecessarily. The qemu.sh script was updated to provide the BOOTIF variable when PXE boot is emulated.
Diffstat (limited to 'src/qemu.sh')
-rwxr-xr-xsrc/qemu.sh16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/qemu.sh b/src/qemu.sh
index b095eb8..3b8cdec 100755
--- a/src/qemu.sh
+++ b/src/qemu.sh
@@ -12,6 +12,8 @@ layered=${samizdat_iso_dir}/${iso%.iso}.layered.iso
12 12
13initrd.sh || { echo "initrd.sh failed" >&2; exit 1; }; 13initrd.sh || { echo "initrd.sh failed" >&2; exit 1; };
14 14
15[ "$NO_NET" ] || USE_NET=y
16
15NET='tap,vlan=0,ifname=tap0,script=no,downscript=no' 17NET='tap,vlan=0,ifname=tap0,script=no,downscript=no'
16 18
17[ "$SLOW_BOOT" ] || QEMU_LOADS_LINUX=y 19[ "$SLOW_BOOT" ] || QEMU_LOADS_LINUX=y
@@ -21,9 +23,13 @@ NET='tap,vlan=0,ifname=tap0,script=no,downscript=no'
21 23
22initrd=${samizdat_isolinux_dir}/linux/initrd.img 24initrd=${samizdat_isolinux_dir}/linux/initrd.img
23kernel=${samizdat_isolinux_dir}/linux/vmlinuz 25kernel=${samizdat_isolinux_dir}/linux/vmlinuz
24 kcmdline_NET='boot=samizdat components quiet splash nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp netkeys'
25kcmdline_CDROM_NET='boot=samizdat components quiet splash nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp'
26kcmdline_CDROM='boot=samizdat components quiet splash' 26kcmdline_CDROM='boot=samizdat components quiet splash'
27kcmdline_CDROM_NET="${kcmdline_CDROM} nbdroot=192.168.10.1,samizdat.btrfs nbddev=/dev/nbd0 ip=dhcp"
28kcmdline_NET="${kcmdline_CDROM_NET} netkeys"
29
30MAC='52-54-00-12-34-56'
31
32kcmdline_BOOTIF="BOOTIF=01-$MAC"
27 33
28set -- 34set --
29if [ "$USE_ISO" ]; then 35if [ "$USE_ISO" ]; then
@@ -40,7 +46,7 @@ if [ "$USE_ISO" ]; then
40 fi 46 fi
41else 47else
42 if [ "$QEMU_LOADS_LINUX" ]; then 48 if [ "$QEMU_LOADS_LINUX" ]; then
43 set -- "$@" -initrd "$initrd" -kernel "$kernel" -append "$kcmdline_NET" 49 set -- "$@" -initrd "$initrd" -kernel "$kernel" -append "$kcmdline_NET $kcmdline_BOOTIF"
44 else 50 else
45 set -- "$@" -boot n 51 set -- "$@" -boot n
46 fi 52 fi
@@ -49,8 +55,8 @@ fi
49set -x 55set -x
50sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \ 56sudo qemu-system-x86_64 -enable-kvm -smp 2 -m 640 -k en-us \
51 -vga qxl \ 57 -vga qxl \
52 -net nic,vlan=0,model=virtio \ 58 -net nic,vlan=0,model=virtio,macaddr=$MAC \
53 -net "$NET" \ 59 ${USE_NET:+ -net "$NET"} \
54 -rtc base=localtime \ 60 -rtc base=localtime \
55 -hda "$disk" \ 61 -hda "$disk" \
56 "$@" 62 "$@"