Compare commits
No commits in common. "759e085fc0bf2756af97fbb1cec8ecd4b1137dc9" and "5a2233bd04df6d728f879864aecc1de018e111fa" have entirely different histories.
759e085fc0
...
5a2233bd04
2 changed files with 31 additions and 18 deletions
|
@ -1,21 +1,34 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env python3
|
||||||
set -x
|
|
||||||
|
|
||||||
# How many CPU cores to use
|
# Set number of vCPUs to use to the environment variable QEMUSH_NPROC or
|
||||||
nproc=$QEMUSH_NPROC
|
# half of total vCPUs installed if it fails
|
||||||
[ -z "$nproc" ] && nproc=$(($(nproc) / 2))
|
try:
|
||||||
|
from os import environ
|
||||||
|
nproc = environ['QEMUSH_NPROC']
|
||||||
|
except KeyError:
|
||||||
|
from multiprocessing import cpu_count
|
||||||
|
nproc = str(cpu_count() // 2)
|
||||||
|
|
||||||
# How much RAM to use
|
# Set amount of RAM to use to the environment variable QEMUSH_RAM or half
|
||||||
ram=$QEMUSH_RAM
|
# of total RAM installed if it fails
|
||||||
[ -z "$ram" ] && ram=$(($(free | grep '^Mem:\s' | awk '{ print $NF }') / 2))K
|
try:
|
||||||
|
ram = environ['QEMUSH_RAM']
|
||||||
|
except KeyError:
|
||||||
|
from psutil import virtual_memory
|
||||||
|
ram = str(virtual_memory().available // 2 // (1024 ** 2))
|
||||||
|
|
||||||
# Set the arguments
|
# Set the command to initialize; all required parameters to make a sane KVM
|
||||||
set -- qemu-system-x86_64 \
|
# are included and optional arguments are appended from argv
|
||||||
-enable-kvm \
|
from sys import argv
|
||||||
-M q35 \
|
command = [
|
||||||
-cpu host -smp "$nproc" \
|
'qemu-system-x86_64',
|
||||||
-m "$ram" \
|
'-enable-kvm',
|
||||||
"$@"
|
'-M', 'q35',
|
||||||
|
'-cpu', 'host', '-smp', nproc,
|
||||||
|
'-m', ram,
|
||||||
|
] + argv[1:]
|
||||||
|
|
||||||
# Start the machine
|
# Print the final command and replace the main process with it
|
||||||
exec "$@"
|
print(command)
|
||||||
|
from os import execvp
|
||||||
|
execvp(command[0], command)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -x
|
#!/bin/sh -x
|
||||||
base=$(echo "$QEMUSH_BASE" | cut -d , -f 1)
|
base=$(echo "$QEMUSH_BASE" | cut -d , -f 1)
|
||||||
QEMUSH_BASE=$(echo "$QEMUSH_BASE" | sed "s/^${base}//" | sed 's/^,//')
|
QEMUSH_BASE=$(echo "$QEMUSH_BASE" | cut -d , -f 2-)
|
||||||
|
|
||||||
exec "$base" \
|
exec "$base" \
|
||||||
-vga qxl \
|
-vga qxl \
|
||||||
|
|
Loading…
Reference in a new issue