From 1e0ffd02973a154e1475e5262ba3415190335609 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Mon, 17 Aug 2020 20:26:26 +0300 Subject: scripts/run_archiso.sh: don't duplicate qemu commands for each boot mode Various bash script improvements. --- scripts/run_archiso.sh | 103 ++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 57 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 210246c..4a062ee 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -15,117 +15,106 @@ set -eu print_help() { - cat << EOF + local usagetext + IFS='' read -r -d '' usagetext < 0 )); then while getopts 'bhi:su' flag; do - case "${flag}" in + case "$flag" in b) - boot_type=bios + boot_type='bios' ;; h) print_help @@ -135,13 +124,13 @@ if [ ${#@} -gt 0 ]; then image="$OPTARG" ;; u) - boot_type=uefi + boot_type='uefi' ;; s) - secure_boot=yes + secure_boot='on' ;; *) - echo "Error: Wrong option. Try 'run_archiso -h'." + printf '%s\n' "Error: Wrong option. Try 'run_archiso -h'." exit 1 ;; esac -- cgit v1.2.3-70-g09d2 From 55d9d1ffc4b43ef10e4e8a1cc43457e521a62cb3 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Mon, 17 Aug 2020 20:31:54 +0300 Subject: scripts/run_archiso.sh: disable PXE ROM ISO testing doesn't require the emulated firmware's PXE stack. For UEFI, it only disable iPXE in favor of EDK II network stack. https://github.com/tianocore/tianocore.github.io/wiki/EDKII-Network-Over-QEMU#verification-result --- scripts/run_archiso.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 4a062ee..5405ded 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -83,7 +83,7 @@ run_image() { -drive file="${image}",media=cdrom,readonly=on,if=virtio \ -display sdl \ -vga virtio \ - -device virtio-net-pci,netdev=net0 -netdev user,id=net0 \ + -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ -machine type=q35,smm=on,accel=kvm \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ -- cgit v1.2.3-70-g09d2 From ba3e8345ad335120af6de680766436640f9c3bd3 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Mon, 17 Aug 2020 20:33:50 +0300 Subject: scripts/run_archiso.sh: support booting the image as a hard disk or an optical disc Use virtio-scsi to attach the image. virtio-blk (if=virtio) is inconsistent about the used media type. --- scripts/run_archiso.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 5405ded..1ce00cf 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -22,6 +22,7 @@ Usage: Options: -b set boot type to 'BIOS' (default) + -d set image type to hard disk instead of optical disc -h print help -i [image] image to boot into -s use Secure Boot (only relevant when using UEFI) @@ -80,7 +81,9 @@ run_image() { -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \ -k en \ -name archiso,process=archiso_0 \ - -drive file="${image}",media=cdrom,readonly=on,if=virtio \ + -device virtio-scsi-pci,id=scsi0 \ + -device "scsi-${mediatype%rom},bus=scsi0.0,drive=${mediatype}0" \ + -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \ -display sdl \ -vga virtio \ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ @@ -105,17 +108,21 @@ set_image() { image='' boot_type='bios' +mediatype='cdrom' secure_boot='off' qemu_options=() working_dir="$(mktemp -dt run_archiso.XXXXXXXXXX)" trap cleanup_working_dir EXIT if (( ${#@} > 0 )); then - while getopts 'bhi:su' flag; do + while getopts 'bdhi:su' flag; do case "$flag" in b) boot_type='bios' ;; + d) + mediatype='hd' + ;; h) print_help exit 0 -- cgit v1.2.3-70-g09d2 From 5f4260fcb11b6b7ab5412b00bea282808c349a0c Mon Sep 17 00:00:00 2001 From: Alexander Epaneshnikov Date: Wed, 7 Oct 2020 18:11:13 +0300 Subject: add sound support in run_archiso.sh also included serial output on stdio it helps in debugging without sight. --- scripts/run_archiso.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 1ce00cf..9f55369 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -86,12 +86,16 @@ run_image() { -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \ -display sdl \ -vga virtio \ + -audiodev pa,id=snd0 \ + -device ich9-intel-hda \ + -device hda-output,audiodev=snd0 \ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ - -machine type=q35,smm=on,accel=kvm \ + -machine type=q35,smm=on,accel=kvm,pcspk-audiodev=snd0 \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ "${qemu_options[@]}" \ - -no-reboot + -no-reboot \ + -serial stdio } set_image() { -- cgit v1.2.3-70-g09d2 From cc2d9bbf8e8f68ba9a9faf32db53900f545ff863 Mon Sep 17 00:00:00 2001 From: Alexander Epaneshnikov Date: Wed, 21 Oct 2020 23:27:38 +0300 Subject: run_archiso: add braille support necessary for testing brltty in archiso --- scripts/run_archiso.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 9f55369..3e01f92 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -87,9 +87,11 @@ run_image() { -display sdl \ -vga virtio \ -audiodev pa,id=snd0 \ + -chardev braille,id=brltty \ -device ich9-intel-hda \ -device hda-output,audiodev=snd0 \ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ + -device usb-braille,id=usbbrl,chardev=brltty \ -machine type=q35,smm=on,accel=kvm,pcspk-audiodev=snd0 \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ -- cgit v1.2.3-70-g09d2 From 551edcd56dd02533505a6a671045a5a00bbdc42c Mon Sep 17 00:00:00 2001 From: Alexander Epaneshnikov Date: Sun, 25 Oct 2020 00:11:22 +0300 Subject: run_archiso: fixup !86 forgot to enable USB support. --- scripts/run_archiso.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 3e01f92..7491290 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -92,7 +92,7 @@ run_image() { -device hda-output,audiodev=snd0 \ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ -device usb-braille,id=usbbrl,chardev=brltty \ - -machine type=q35,smm=on,accel=kvm,pcspk-audiodev=snd0 \ + -machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ "${qemu_options[@]}" \ -- cgit v1.2.3-70-g09d2 From e748a770b1612b084f533d31c6def148eceeb130 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 29 Oct 2020 10:52:03 +0100 Subject: Add accessibility support based on option flag scripts/run_archiso.sh: Add the `-a` option flag to add accessibility support on demand for `run_archiso`. Add accessibility specific options to qemu in `run_image()`. Not providing the specific braille chardev hardware otherwise blocks running run_archiso with `qemu-system-x86_64: -chardev braille,id=brltty: brlapi__openConnection: connect: No such file or directory`. Fixes #77 --- scripts/run_archiso.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 7491290..4c52703 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -21,6 +21,7 @@ Usage: run_archiso [options] Options: + -a set accessibility support using brltty -b set boot type to 'BIOS' (default) -d set image type to hard disk instead of optical disc -h print help @@ -76,6 +77,13 @@ run_image() { ) fi + if [[ "${accessibility}" == 'on' ]]; then + qemu_options+=( + '-chardev' 'braille,id=brltty' + '-device' 'usb-braille,id=usbbrl,chardev=brltty' + ) + fi + qemu-system-x86_64 \ -boot order=d,menu=on,reboot-timeout=5000 \ -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \ @@ -87,17 +95,15 @@ run_image() { -display sdl \ -vga virtio \ -audiodev pa,id=snd0 \ - -chardev braille,id=brltty \ -device ich9-intel-hda \ -device hda-output,audiodev=snd0 \ -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ - -device usb-braille,id=usbbrl,chardev=brltty \ -machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ "${qemu_options[@]}" \ - -no-reboot \ - -serial stdio + -serial stdio \ + -no-reboot } set_image() { @@ -113,6 +119,7 @@ set_image() { } image='' +accessibility='' boot_type='bios' mediatype='cdrom' secure_boot='off' @@ -121,8 +128,11 @@ working_dir="$(mktemp -dt run_archiso.XXXXXXXXXX)" trap cleanup_working_dir EXIT if (( ${#@} > 0 )); then - while getopts 'bdhi:su' flag; do + while getopts 'abdhi:su' flag; do case "$flag" in + a) + accessibility='on' + ;; b) boot_type='bios' ;; -- cgit v1.2.3-70-g09d2 From e556491c27d58009658308c76ea3d0252f07e50a Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 29 Dec 2020 20:59:13 +0100 Subject: add VNC support to run_archiso.sh Usage: Launch run_archiso.sh -v ..., and then use a VNC viewer (e.g. from https://wiki.archlinux.org/index.php/List_of_applications/Internet#Remote_desktop) to connect (typically to `localhost`) on the default VNC port (5900). This enables using run_archiso in a "headless" session; e.g. when SSH logged in to the CLI of a VM, without a local display attached. This is handy e.g. when playing https://en.wikipedia.org/wiki/Inception and running an archlinux*.iso on any non-Arch (say Fedora workstation), on which one built a new ISO, that you then "run_archiso", inside which you could build another ISO, which you could itself start inside the nested VM... ;-) Jokes apart, this could also be used to run automated CI/CD tests of the built ISO, which is particularly interesting in combination with the cloud-init support; see https://wiki.archlinux.org/index.php/Cloud-init. see https://bugs.archlinux.org/task/69142 --- scripts/run_archiso.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 4c52703..27b8730 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -28,6 +28,7 @@ Options: -i [image] image to boot into -s use Secure Boot (only relevant when using UEFI) -u set boot type to 'UEFI' + -v use VNC display (instead of default SDL) Example: Run an image using UEFI: @@ -87,12 +88,12 @@ run_image() { qemu-system-x86_64 \ -boot order=d,menu=on,reboot-timeout=5000 \ -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \ - -k en \ + -k en-us \ -name archiso,process=archiso_0 \ -device virtio-scsi-pci,id=scsi0 \ -device "scsi-${mediatype%rom},bus=scsi0.0,drive=${mediatype}0" \ -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \ - -display sdl \ + -display "${display}" \ -vga virtio \ -audiodev pa,id=snd0 \ -device ich9-intel-hda \ @@ -123,12 +124,13 @@ accessibility='' boot_type='bios' mediatype='cdrom' secure_boot='off' +display='sdl' qemu_options=() working_dir="$(mktemp -dt run_archiso.XXXXXXXXXX)" trap cleanup_working_dir EXIT if (( ${#@} > 0 )); then - while getopts 'abdhi:su' flag; do + while getopts 'abdhi:suv' flag; do case "$flag" in a) accessibility='on' @@ -152,6 +154,10 @@ if (( ${#@} > 0 )); then s) secure_boot='on' ;; + v) + display='none' + qemu_options+=(-vnc 'vnc=0.0.0.0:0,vnc=[::]:0') + ;; *) printf '%s\n' "Error: Wrong option. Try 'run_archiso -h'." exit 1 -- cgit v1.2.3-70-g09d2 From 955343925b6c95dae0677f1cd27cc800f2293fb5 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 29 Dec 2020 23:27:30 +0100 Subject: make run_archiso forward VM's port 22 to host 60022, for easy SSH testing --- scripts/run_archiso.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 27b8730..b19d280 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -98,7 +98,7 @@ run_image() { -audiodev pa,id=snd0 \ -device ich9-intel-hda \ -device hda-output,audiodev=snd0 \ - -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0 \ + -device virtio-net-pci,romfile=,netdev=net0 -netdev user,id=net0,hostfwd=tcp::60022-:22 \ -machine type=q35,smm=on,accel=kvm,usb=on,pcspk-audiodev=snd0 \ -global ICH9-LPC.disable_s3=1 \ -enable-kvm \ -- cgit v1.2.3-70-g09d2 From 608d1100c8a87b3284efa8163ea483e8c11bc311 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Wed, 30 Dec 2020 04:02:34 +0100 Subject: add -c => -cdrom cloud-init.iso support to run_archiso.sh Co-authored-by: nl6720 --- scripts/run_archiso.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index b19d280..74f3096 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -29,6 +29,7 @@ Options: -s use Secure Boot (only relevant when using UEFI) -u set boot type to 'UEFI' -v use VNC display (instead of default SDL) + -c [image] attach an additional optical disc image (e.g. for cloud-init) Example: Run an image using UEFI: @@ -85,6 +86,13 @@ run_image() { ) fi + if [[ -n "${oddimage}" ]]; then + qemu_options+=( + '-device' 'scsi-cd,bus=scsi0.0,drive=cdrom1' + '-drive' "id=cdrom1,if=none,format=raw,media=cdrom,readonly=on,file=${oddimage}" + ) + fi + qemu-system-x86_64 \ -boot order=d,menu=on,reboot-timeout=5000 \ -m "size=3072,slots=0,maxmem=$((3072*1024*1024))" \ @@ -120,6 +128,7 @@ set_image() { } image='' +oddimage='' accessibility='' boot_type='bios' mediatype='cdrom' @@ -130,7 +139,7 @@ working_dir="$(mktemp -dt run_archiso.XXXXXXXXXX)" trap cleanup_working_dir EXIT if (( ${#@} > 0 )); then - while getopts 'abdhi:suv' flag; do + while getopts 'abc:dhi:suv' flag; do case "$flag" in a) accessibility='on' @@ -138,6 +147,9 @@ if (( ${#@} > 0 )); then b) boot_type='bios' ;; + c) + oddimage="$OPTARG" + ;; d) mediatype='hd' ;; -- cgit v1.2.3-70-g09d2 From dd51457d09662df72adbf3fc53d2d034b8a7dad5 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sat, 30 Jan 2021 15:15:40 +0100 Subject: rm un-used set_image() dupe of check_image() in run_archiso.sh --- scripts/run_archiso.sh | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 74f3096..36569b5 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -115,18 +115,6 @@ run_image() { -no-reboot } -set_image() { - if [[ -z "$image" ]]; then - printf 'ERROR: %s\n' "Image name can not be empty." - exit 1 - fi - if [[ ! -f "$image" ]]; then - printf 'ERROR: %s\n' "Image (${image}) does not exist." - exit 1 - fi - image="$1" -} - image='' oddimage='' accessibility='' -- cgit v1.2.3-70-g09d2 From 4b14350e5f6a429dbfbe25ed401dbc130b4eca54 Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 6 May 2021 01:40:17 +0200 Subject: Use QEMU 6.x options scripts/run_archiso: Change parameters to qemu's `-drive` option to make use of the explicit `read-only=on`, as the implicit `read-only` is now obsolete. Closes #126 --- scripts/run_archiso.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/run_archiso.sh') diff --git a/scripts/run_archiso.sh b/scripts/run_archiso.sh index 36569b5..6ddce15 100755 --- a/scripts/run_archiso.sh +++ b/scripts/run_archiso.sh @@ -73,7 +73,7 @@ run_image() { local ovmf_code='/usr/share/edk2-ovmf/x64/OVMF_CODE.fd' fi qemu_options+=( - '-drive' "if=pflash,format=raw,unit=0,file=${ovmf_code},readonly" + '-drive' "if=pflash,format=raw,unit=0,file=${ovmf_code},read-only=on" '-drive' "if=pflash,format=raw,unit=1,file=${working_dir}/OVMF_VARS.fd" '-global' "driver=cfi.pflash01,property=secure,value=${secure_boot}" ) @@ -89,7 +89,7 @@ run_image() { if [[ -n "${oddimage}" ]]; then qemu_options+=( '-device' 'scsi-cd,bus=scsi0.0,drive=cdrom1' - '-drive' "id=cdrom1,if=none,format=raw,media=cdrom,readonly=on,file=${oddimage}" + '-drive' "id=cdrom1,if=none,format=raw,media=cdrom,read-only=on,file=${oddimage}" ) fi @@ -100,7 +100,7 @@ run_image() { -name archiso,process=archiso_0 \ -device virtio-scsi-pci,id=scsi0 \ -device "scsi-${mediatype%rom},bus=scsi0.0,drive=${mediatype}0" \ - -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},readonly=on,file=${image}" \ + -drive "id=${mediatype}0,if=none,format=raw,media=${mediatype/hd/disk},read-only=on,file=${image}" \ -display "${display}" \ -vga virtio \ -audiodev pa,id=snd0 \ -- cgit v1.2.3-70-g09d2