qemush/qemu/launchers/kvm
2023-12-13 12:41:28 +01:00

20 lines
439 B
Python
Executable file

#!/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)