diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-21 04:42:08 -0400 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-21 04:42:08 -0400 |
| commit | deed94c0f111ad6c2e092ee5c124688c174ac816 (patch) | |
| tree | 32f52a1502a1621407f28bf8e006f4e7cbb93f89 /scripts/launch_qemu_vgpu.sh | |
| parent | 5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60 (diff) | |
| download | open-iov-deed94c0f111ad6c2e092ee5c124688c174ac816.tar.gz open-iov-deed94c0f111ad6c2e092ee5c124688c174ac816.zip | |
Fix create_mdev.sh type names and update launch_qemu_vgpu.sh with install/run modes
Diffstat (limited to 'scripts/launch_qemu_vgpu.sh')
| -rwxr-xr-x | scripts/launch_qemu_vgpu.sh | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/scripts/launch_qemu_vgpu.sh b/scripts/launch_qemu_vgpu.sh index 5a57737..2b64f63 100755 --- a/scripts/launch_qemu_vgpu.sh +++ b/scripts/launch_qemu_vgpu.sh @@ -1,14 +1,26 @@ #!/bin/bash # launch_qemu_vgpu.sh - Launch QEMU with NVIDIA vGPU mediated device -# Usage: ./launch_qemu_vgpu.sh [MDEV_UUID] [GUEST_IMAGE] [OPTIONS] +# Usage: ./launch_qemu_vgpu.sh [install|run] [MDEV_UUID] [GUEST_IMAGE] [OPTIONS] set -euo pipefail +MODE="${1:-run}" +if [[ "$MODE" == "install" ]]; then + shift +elif [[ "$MODE" == "run" ]]; then + shift +else + # Default to run if first arg doesn't match + MODE="run" +fi + MDEV_UUID="${1:-}" GUEST_IMAGE="${2:-/var/lib/libvirt/images/ubuntu-22.04.qcow2}" shift 2 || true EXTRA_QEMU_ARGS=("$@") +ISO_IMAGE="/var/lib/libvirt/images/ubuntu-24.04.5-live-server-amd64.iso" + # Find mdev device if UUID not specified if [[ -z "$MDEV_UUID" ]]; then echo "Scanning for available mdev devices..." @@ -62,7 +74,7 @@ VGPU_TYPE=$(cat "$MDEV_PATH/mdev_type/name" 2>/dev/null || echo "unknown") PCI_ADDR=$(readlink -f "$MDEV_PATH/../../.." | xargs basename) echo "==========================================" -echo "Launching QEMU with NVIDIA vGPU" +echo "Launching QEMU with NVIDIA vGPU ($MODE mode)" echo "==========================================" echo "mdev UUID: $MDEV_UUID" echo "vGPU Type: $VGPU_TYPE" @@ -87,21 +99,13 @@ HUGEPAGE_OPTS=( # VFIO device configuration VFIO_OPTS=( - -device vfio-pci,sysfsdev="$MDEV_PATH",display=off,x-igd-opregion=on - -device vfio-pci,sysfsdev="$MDEV_PATH",display=off,romfile= + -device vfio-pci,sysfsdev="$MDEV_PATH",display=off ) -# Display (use SPICE/VNC for headless, or virtio-gpu for local) +# Display - use qxl-vga with GTK for local visible window DISPLAY_OPTS=( - -vga none - -display none - # Uncomment for VNC: - # -vnc :1 - # Uncomment for SPICE: - # -spice port=5900,addr=127.0.0.1,disable-ticketing=on - # -device virtio-serial-pci - # -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 - # -chardev spicevmc,id=spicechannel0,name=vdagent + -device qxl-vga + -display gtk ) # Network @@ -111,11 +115,22 @@ NET_OPTS=( ) # Storage -STORAGE_OPTS=( - -drive file="$GUEST_IMAGE",format=qcow2,if=virtio,cache=writeback,aio=threads - # Add ISO for installation: - # -drive file=/path/to/ubuntu-22.04-live-server-amd64.iso,format=raw,if=virtio,media=cdrom -) +if [[ "$MODE" == "install" ]]; then + if [[ ! -f "$ISO_IMAGE" ]]; then + echo "ERROR: ISO image not found: $ISO_IMAGE" + exit 1 + fi + STORAGE_OPTS=( + -drive file="$GUEST_IMAGE",format=qcow2,if=virtio,cache=writeback,aio=threads + -drive file="$ISO_IMAGE",format=raw,if=virtio,media=cdrom + ) + echo "Installation mode: ISO attached ($ISO_IMAGE)" +else + STORAGE_OPTS=( + -drive file="$GUEST_IMAGE",format=qcow2,if=virtio,cache=writeback,aio=threads + ) + echo "Run mode: No ISO attached" +fi # USB tablet for better mouse integration USB_OPTS=( @@ -129,12 +144,10 @@ RNG_OPTS=( -device virtio-rng-pci,rng=rng0 ) -# TPM (optional, for Windows guests) -# TPM_OPTS=( -# -chardev socket,id=chrtpm,path=/var/run/tpm-emulator/swtpm-sock -# -tpmdev emulator,id=tpm0,chardev=chrtpm -# -device tpm-tis,tpmdev=tpm0 -# ) +# Serial log for debugging +SERIAL_OPTS=( + -serial file:/tmp/qemu-serial.log +) # QEMU command QEMU_CMD=( @@ -150,6 +163,7 @@ QEMU_CMD=( "${STORAGE_OPTS[@]}" "${USB_OPTS[@]}" "${RNG_OPTS[@]}" + "${SERIAL_OPTS[@]}" "${EXTRA_QEMU_ARGS[@]}" -name "vGPU-Guest-$VGPU_TYPE" -pidfile "/tmp/qemu-vgpu-$MDEV_UUID.pid" @@ -162,17 +176,18 @@ echo "" "${QEMU_CMD[@]}" -sleep 2 +sleep 3 if [[ -f "/tmp/qemu-vgpu-$MDEV_UUID.pid" ]]; then PID=$(cat "/tmp/qemu-vgpu-$MDEV_UUID.pid") if kill -0 "$PID" 2>/dev/null; then echo "SUCCESS: QEMU started with PID $PID" echo "" + echo "GTK window should be visible on your display" echo "Connect via SSH: ssh -p 2222 user@localhost" - echo "Or VNC: vncviewer localhost:1 (if enabled)" echo "" echo "To stop: kill $PID" + echo "Serial log: /tmp/qemu-serial.log" else echo "ERROR: QEMU failed to start" exit 1 |
