#!/usr/bin/env bash # # yqemu : yad front-end to qemu-system-* set -x mem_opt="-m $1" if [ -z "$1" ] ; then mem_opt="-m 512" fi image_file=$(yad --file-selection --file-filter="*.[iI][sSmM][oOgG]" --file-filter="*" \ --width=780 --height=640 --center --title=$"Select image file" --text="Select .iso or .img file." \ --filename="*" --button=OK:0 --button=Exit:1) if [[ $? = 1 ]] ; then exit 0 fi if [[ $image_file =~ .*\.(img|IMG) ]] ; then device_opt="-drive file=$image_file" elif [[ $image_file =~ .*\.(iso|ISO) ]] ; then device_opt="-cdrom $image_file" else echo -e "\n I don't know what to do with ${image_file##*/} \n" fi options=$(yad --list --checklist --title="Select options" --text="Select the options you want." \ --column "Choose" --column "Num" --column "Options" --button=OK:0 --button=Exit:1 \ --width=480 --height=220 --center \ TRUE 01 "Use 64-bit" \ TRUE 02 "Enable KVM" \ TRUE 03 "Enable uefi" \ TRUE 04 "Enable ssh" \ TRUE 05 "Display (vga std)") if [[ $? = 1 ]] ; then exit 0 fi echo "$options" if [[ $options =~ 01 ]] ;then cpu_opt="x86_64" else cpu_opt="i386" fi if [[ $options =~ 02 ]] ;then kvm_opt="-enable-kvm" fi if [[ $options =~ 03 ]] ;then uefi_opt="-bios /usr/share/ovmf/OVMF.fd" fi if [[ $options =~ 04 ]] ;then net_opt="-device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::5555-:22" fi if [[ $options =~ 05 ]] ; then display_opt="-vga std" fi if [[ -n "$net_opt" ]] ; then echo " Host to guest: ssh -p5555 address@hidden Guest to host: ssh -i /path/to/keyfile address@hidden " | yad --text-info --left --title="SSH Access" --geometry=400x100+0+0 --button=Close:0 & fi qemu-system-${cpu_opt} ${kvm_opt} ${uefi_opt} ${mem_opt} ${net_opt} ${user_opt1} ${user_opt2} ${device_opt} \ -soundhw hda -smp cores=2,threads=2 & exit 0 :<