From f60f378d6855836b782222a2cbeb7a01c60e1ea9 Mon Sep 17 00:00:00 2001 From: iliya <iliya.saroukhanian@etu.hesge.ch> Date: Fri, 15 Mar 2024 16:35:33 +0100 Subject: [PATCH] fix: correctly creating VM when both options are enabled (previously ifs were cascading) --- vm_run.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/vm_run.sh b/vm_run.sh index 10425db..94817ed 100755 --- a/vm_run.sh +++ b/vm_run.sh @@ -52,28 +52,33 @@ CPU_COUNT="2" NET_PV="-nic user,model=virtio-net-pci" GPU_PV="-vga virtio" + +# SPICE_SERVER="-device virtio-serial-pci \ +# -spice port=8000,disable-ticketing=on \ +# -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \ +# -chardev spicevmc,id=spicechannel0,name=vdagent,clipboard=on" + QEMU_GA="-device virtio-serial \ -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \ -chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0" SPICE_GA="-device virtio-serial-pci \ - -chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on \ - -device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0 " + -device virtserialport,chardev=ch1,id=ch1,name=com.redhat.spice.0 \ + -chardev qemu-vdagent,id=ch1,name=vdagent,clipboard=on" +if $DISK_OPT && $ISO_OPT; then + qemu-system-x86_64 -boot order=d -cdrom $ISO_PATH -m $MEM_COUNT -smp \ + cpus=$CPU_COUNT -enable-kvm $NET_PV $GPU_PV \ + -drive file=$DISK_PATH,index=0,media=disk,format=qcow2,if=virtio \ + $QEMU_GA $SPICE_GA +fi if $DISK_OPT; then qemu-system-x86_64 -m $MEM_COUNT -smp cpus=$CPU_COUNT -enable-kvm $NET_PV \ - $GPU_PV $DISK_PATH $QEMU_GA $SPICE_GA + $GPU_PV $DISK_PATH $QEMU_GA $SPICE_GA $SPICE_SERVER fi if $ISO_OPT; then qemu-system-x86_64 -cdrom $ISO_PATH -m $MEM_COUNT -smp cpus=$CPU_COUNT \ -enable-kvm $NET_PV $GPU_PV $QEMU_GA $SPICE_GA fi - -if $DISK_OPT && $ISO_OPT; then - qemu-system-x86_64 -boot=d -cdrom $ISO_PATH -m $MEM_COUNT -smp \ - cpus=$CPU_COUNT -enable-kvm $NET_PV $GPU_PV \ - -drive file=$DISK_PATH,index=0,media=disk,format=qcow2,if=virtio \ - $QEMU_GA $SPICE_GA -fi -- GitLab