Skip to content
Snippets Groups Projects
Verified Commit d2d399e4 authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

WIP: vm_run, TODO clipboard

parents
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
print_usage() {
echo "Usage: ./vm_run.sh -d disk -i iso"
echo "disk the disk to use (qcow file)"
echo "iso the CD/DVD-ROM image to use (iso file)"
echo ""
echo "At least one image must be specified"
}
if [ $# -eq 0 ]; then
print_usage
exit 1
fi
DISK_OPT=false
ISO_OPT=false
DISK_PATH=""
ISO_PATH=""
# flags -d and -i require arguments, -h doesn't
OPTSTRING=":d:i:h"
while getopts $OPTSTRING flag; do
case $flag in
h)
print_usage
exit 0
;;
d)
DISK_OPT=true
DISK_PATH=$OPTARG
;;
i)
ISO_OPT=true
ISO_PATH=$OPTARG
;;
:)
echo "Option -${OPTARG} requires an argument."
exit 2
;;
?)
echo "Invalid option: -${OPTARG}."
exit 3
;;
esac
done
MEM_COUNT="4G"
CPU_COUNT="2"
NET_PV="-nic user,model=virtio-net-pci"
GPU_PV="-vga virtio"
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 "
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment