kvm : support des sockets de monitoring
This commit is contained in:
parent
4937871c14
commit
4be5f86cf3
3 changed files with 36 additions and 1 deletions
|
@ -1,3 +1,16 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# Invoked on termination if the last command failed
|
||||||
|
error() { >&2 echo "$(basename "$0"): failed"; }
|
||||||
|
|
||||||
|
# Trap errors
|
||||||
|
trap error EXIT
|
||||||
|
|
||||||
|
# Assert that the QEMUSH_NAME variable is not null
|
||||||
[ -n "$QEMUSH_NAME" ]
|
[ -n "$QEMUSH_NAME" ]
|
||||||
|
|
||||||
|
# Release the trap
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
# Print the actual string
|
||||||
printf %s/%s.qcow2\\n ~/disks "$QEMUSH_NAME"
|
printf %s/%s.qcow2\\n ~/disks "$QEMUSH_NAME"
|
||||||
|
|
|
@ -1,3 +1,16 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
# Invoked on termination if the last command failed
|
||||||
|
error() { >&2 echo "$(basename "$0"): failed"; }
|
||||||
|
|
||||||
|
# Trap errors
|
||||||
|
trap error EXIT
|
||||||
|
|
||||||
|
# Assert that the QEMUSH_NAME variable is not null
|
||||||
[ -n "$QEMUSH_NAME" ]
|
[ -n "$QEMUSH_NAME" ]
|
||||||
|
|
||||||
|
# Release the trap
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
# Print the actual string
|
||||||
printf %s/%s ~/sockets "$QEMUSH_NAME"
|
printf %s/%s ~/sockets "$QEMUSH_NAME"
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from os import environ
|
|
||||||
|
# Retrieve the name of the monitor socket
|
||||||
|
from subprocess import check_output
|
||||||
|
from subprocess import CalledProcessError
|
||||||
|
try:
|
||||||
|
socket = 'unix:%s,server,nowait' % (check_output(["sockpath"], text=True))
|
||||||
|
except CalledProcessError as e:
|
||||||
|
exit(e.returncode)
|
||||||
|
|
||||||
# Set number of vCPUs to use to the environment variable QEMUSH_NPROC or
|
# Set number of vCPUs to use to the environment variable QEMUSH_NPROC or
|
||||||
# half of total vCPUs installed if it fails
|
# half of total vCPUs installed if it fails
|
||||||
|
from os import environ
|
||||||
try:
|
try:
|
||||||
nproc = environ['QEMUSH_NPROC']
|
nproc = environ['QEMUSH_NPROC']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -23,6 +31,7 @@ from sys import argv
|
||||||
command = [
|
command = [
|
||||||
'qemu-system-x86_64',
|
'qemu-system-x86_64',
|
||||||
'-enable-kvm', '-daemonize',
|
'-enable-kvm', '-daemonize',
|
||||||
|
'-monitor', socket,
|
||||||
'-M', 'q35',
|
'-M', 'q35',
|
||||||
'-cpu', 'host', '-smp', nproc,
|
'-cpu', 'host', '-smp', nproc,
|
||||||
'-m', ram,
|
'-m', ram,
|
||||||
|
|
Loading…
Reference in a new issue