From 6b0475ad4ee67e30599c967ddb0207881ef6a573 Mon Sep 17 00:00:00 2001 From: Ahurac Date: Wed, 13 Dec 2023 12:41:28 +0100 Subject: [PATCH] launchers : remaniement --- qemu/launchers/kvm | 20 ++++++++++++++++++++ qemu/launchers/{linux-spice => kvm-spice} | 3 +-- qemu/launchers/linux | 8 -------- qemu/launchers/redox | 10 ---------- qemu/launchers/redox-spice | 4 ---- qemu/launchers/windows | 9 --------- qemu/launchers/windows-spice | 7 ------- qemu/launchers/windows10 | 10 ++++++++++ 8 files changed, 31 insertions(+), 40 deletions(-) create mode 100755 qemu/launchers/kvm rename qemu/launchers/{linux-spice => kvm-spice} (85%) delete mode 100755 qemu/launchers/linux delete mode 100755 qemu/launchers/redox delete mode 100755 qemu/launchers/redox-spice delete mode 100755 qemu/launchers/windows delete mode 100755 qemu/launchers/windows-spice create mode 100755 qemu/launchers/windows10 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" \ + "$@"