diff --git a/local/scripts/test-iommu-qemu.sh b/local/scripts/test-iommu-qemu.sh index cc663f944f..aea5e6a464 100755 --- a/local/scripts/test-iommu-qemu.sh +++ b/local/scripts/test-iommu-qemu.sh @@ -79,12 +79,18 @@ firmware="$(find_uefi_firmware)" || { } arch="${ARCH:-$(uname -m)}" +iso="build/$arch/$config.iso" image="build/$arch/$config/harddrive.img" extra="build/$arch/$config/extra.img" extra_qemu_args="${filtered_args[*]:-}" -if [[ ! -f "$image" ]]; then - echo "ERROR: missing image $image" >&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -93,14 +99,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -64,7 +70,13 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 rm -f "$log_file" @@ -84,8 +96,7 @@ timeout 90s qemu-system-x86_64 \ -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -nographic -vga none \ - -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \ - -device nvme,drive=drv0,serial=NVME_SERIAL \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host \ diff --git a/local/scripts/test-ps2-qemu.sh b/local/scripts/test-ps2-qemu.sh index 2ed18a89fd..10910008ab 100755 --- a/local/scripts/test-ps2-qemu.sh +++ b/local/scripts/test-ps2-qemu.sh @@ -63,12 +63,18 @@ firmware="$(find_uefi_firmware)" || { } arch="${ARCH:-$(uname -m)}" +iso="build/$arch/$config.iso" image="build/$arch/$config/harddrive.img" extra="build/$arch/$config/extra.img" extra_qemu_args="${filtered_args[*]:-}" -if [[ ! -f "$image" ]]; then - echo "ERROR: missing image $image" >&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -77,14 +83,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -77,14 +83,20 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then expect <&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -85,9 +95,17 @@ if [[ ! -f "$usb_img" ]]; then truncate -s 64M "$usb_img" fi +# Boot-disk args: ISO via -cdrom, or legacy harddrive via nvme. Data drives +# (extra, usb-storage) are always attached the same way. +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + expected_sector_b64="$(seed_usb_image "$usb_img")" -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 rm -f "$log_file" @@ -95,7 +113,7 @@ expect <&2 +boot_media="" +if [[ -f "$iso" ]]; then + boot_media="iso" +elif [[ -f "$image" ]]; then + boot_media="harddrive" +else + echo "ERROR: no bootable image found ($iso or $image)" >&2 echo "Build it first with: ./local/scripts/build-redbear.sh $config" >&2 exit 1 fi @@ -72,7 +81,13 @@ if [[ ! -f "$extra" ]]; then truncate -s 1g "$extra" fi -pkill -f "qemu-system-x86_64.*$image" 2>/dev/null || true +if [[ "$boot_media" == "iso" ]]; then + boot_args=(-cdrom "$iso") +else + boot_args=(-drive file="$image",format=raw,if=none,id=drv0,snapshot=on -device nvme,drive=drv0,serial=NVME_SERIAL) +fi + +pkill -f "qemu-system-x86_64.*$config" 2>/dev/null || true sleep 1 if [[ "$check_mode" -eq 1 ]]; then @@ -96,8 +111,7 @@ if [[ "$check_mode" -eq 1 ]]; then -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -nographic -vga none \ - -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \ - -device nvme,drive=drv0,serial=NVME_SERIAL \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host \ @@ -175,8 +189,7 @@ exec qemu-system-x86_64 \ -netdev user,id=net0 \ -object filter-dump,id=f1,netdev=net0,file="build/$arch/$config/network.pcap" \ -vga std \ - -drive file="$image",format=raw,if=none,id=drv0,snapshot=on \ - -device nvme,drive=drv0,serial=NVME_SERIAL \ + "${boot_args[@]}" \ -drive file="$extra",format=raw,if=none,id=drv1,snapshot=on \ -device nvme,drive=drv1,serial=NVME_EXTRA \ -enable-kvm -cpu host