diff --git a/qemu/launchers/kvm b/qemu/launchers/kvm new file mode 100755 index 0000000..27c8ad4 --- /dev/null +++ b/qemu/launchers/kvm @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +from os import execvp +from multiprocessing import cpu_count +from psutil import virtual_memory +from sys import argv + +nproc = cpu_count() // 2 +ram_kilo = virtual_memory().available // 2 // 1024 + +command = [ + 'qemu-system-x86_64', + '-enable-kvm', + '-M', 'q35', + '-cpu', 'host', '-smp', str(nproc), + '-m', '{}K'.format(ram_kilo), + '-net', 'nic' +] + argv[1:] + +print(command) +execvp(command[0], command) diff --git a/qemu/launchers/linux-spice b/qemu/launchers/kvm-spice similarity index 85% rename from qemu/launchers/linux-spice rename to qemu/launchers/kvm-spice index d38aeb8..a4e88e4 100755 --- a/qemu/launchers/linux-spice +++ b/qemu/launchers/kvm-spice @@ -1,7 +1,6 @@ #!/bin/sh -x -exec linux \ +exec kvm \ -vga qxl \ - -device virtio-serial \ -chardev spicevmc,id=vdagent,debug=0,name=vdagent \ -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ -spice port="$(first-free-port 5900)",addr=127.0.0.1,disable-ticketing=on \ diff --git a/qemu/launchers/linux b/qemu/launchers/linux deleted file mode 100755 index 513afbc..0000000 --- a/qemu/launchers/linux +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -x -qemu-system-x86_64 \ - -enable-kvm \ - -M q35 \ - -cpu host -smp "$(("$(nproc)" / 2))" \ - -m "$(("$(free | awk '($1 == "Mem:") { print $2 }')" / 2))K" \ - -net nic \ - "$@" diff --git a/qemu/launchers/redox b/qemu/launchers/redox deleted file mode 100755 index d801324..0000000 --- a/qemu/launchers/redox +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -x -exec qemu-system-x86_64 \ - -enable-kvm \ - -M q35 \ - -cpu host -smp "$(("$(nproc)" / 2))" \ - -m "$(("$(free | grep '^Mem:\s' | awk '{ print $NF }')" / 2))K" \ - -device e1000,netdev=net0 \ - -device nec-usb-xhci,id=xhci \ - -device ich9-intel-hda -device hda-duplex \ - "$@" diff --git a/qemu/launchers/redox-spice b/qemu/launchers/redox-spice deleted file mode 100755 index f550aa6..0000000 --- a/qemu/launchers/redox-spice +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -x -exec redox \ - -vga qxl -spice port="$(first-free-port 5900)",addr=127.0.0.1,disable-ticketing=on \ - "$@" diff --git a/qemu/launchers/windows b/qemu/launchers/windows deleted file mode 100755 index acf4f15..0000000 --- a/qemu/launchers/windows +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -x -qemu-system-x86_64 \ - -enable-kvm \ - -cpu host -smp "$(("$(nproc)" / 2))" \ - -m "$(("$(free | grep '^Mem: ' | awk '{ print $NF }')" / 2))K" \ - -net nic \ - -device virtio-serial \ - -usbdevice tablet \ - "$@" diff --git a/qemu/launchers/windows-spice b/qemu/launchers/windows-spice deleted file mode 100755 index da49e67..0000000 --- a/qemu/launchers/windows-spice +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -x -exec windows \ - -vga qxl \ - -spice port="$(first-free-port 5900)",addr=127.0.0.1,disable-ticketing=on \ - -chardev spicevmc,id=vdagent,name=vdagent \ - -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 \ - "$@" diff --git a/qemu/launchers/windows10 b/qemu/launchers/windows10 new file mode 100755 index 0000000..b3be044 --- /dev/null +++ b/qemu/launchers/windows10 @@ -0,0 +1,10 @@ +#!/bin/sh -x +name="$(basename "$0")" +exec kvm-spice \ + -monitor stdio \ + -drive file="$(diskpath "$name")",if=virtio \ + -net user,hostname="${name}" \ + -device virtio-serial \ + -usbdevice tablet \ + -name "$name" \ + "$@"