feat: Support simpler QMP configuration (#1403)

This commit is contained in:
Kroese
2026-08-28 04:09:16 +02:00
committed by GitHub
parent b00f1d5d78
commit 489e3eda6f
2 changed files with 44 additions and 7 deletions
+2 -2
View File
@@ -110,6 +110,6 @@ Also see [Dynamic memory allocation](https://github.com/qemus/qemu/blob/master/d
| `DEBUG` | `N` | Enables verbose debug output. |
| `TRACE` | `N` | Enables shell command tracing. |
| `HOST_DEBUG` | `N` | Enables debug output for the DSM host helper. |
| `MONITOR` | | QEMU monitor configuration. |
| `QMP` | | QEMU Machine Protocol configuration. |
| `MONITOR` | | QEMU monitor, such as `/storage/monitor.sock` or `4444`. |
| `QMP` | | QEMU Machine Protocol, such as `/storage/qmp.sock` or `4444`. |
| `ARGUMENTS` | | Additional raw arguments appended to the QEMU command line. |
+42 -5
View File
@@ -31,17 +31,54 @@ configureMemory() {
return 0
}
normalizeSocket() {
local value="$1"
local backend="${value%%,*}"
if [[ "$backend" == *.sock && "$backend" != *:* ]]; then
value="unix:$value"
[[ ",$value," == *,server=* ]] || value+=",server=on"
if [[ ",$value," != *,wait=* ]] && [[ ",$value," != *,server=off,* ]]; then
value+=",wait=off"
fi
fi
echo "$value"
}
normalizePort() {
local value="$1"
local protocol="$2"
if [[ "$value" =~ ^[0-9]+$ ]]; then
value="$protocol:0.0.0.0:$value,server=on,wait=off"
fi
echo "$value"
}
configureMonitor() {
MON_OPTS=""
[ -n "$QMP" ] && MON_OPTS+=" -qmp $QMP"
[ -n "$MONITOR" ] && MON_OPTS+=" -monitor $MONITOR"
MON_OPTS="${MON_OPTS# }"
local name="${APP// /-}"
ID_OPTS="-name $name,process=$PROCESS,debug-threads=on"
if [ -n "$MONITOR" ]; then
MONITOR=$(normalizePort "$MONITOR" "telnet")
MONITOR=$(normalizeSocket "$MONITOR")
MON_OPTS+=" -monitor $MONITOR"
fi
if [ -n "$QMP" ]; then
QMP=$(normalizePort "$QMP" "tcp")
QMP=$(normalizeSocket "$QMP")
MON_OPTS+=" -qmp $QMP"
fi
ID_OPTS="-name ${APP// /-},process=$PROCESS"
PID_OPTS="-pidfile $QEMU_PID"
MON_OPTS="${MON_OPTS# }"
return 0
}