summaryrefslogtreecommitdiff
path: root/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'systemd')
-rwxr-xr-xsystemd/system/qemu11
-rw-r--r--systemd/system/qemu@.service15
2 files changed, 26 insertions, 0 deletions
diff --git a/systemd/system/qemu b/systemd/system/qemu
new file mode 100755
index 0000000..98ca582
--- /dev/null
+++ b/systemd/system/qemu
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+source "/etc/conf.d/qemu.d/$1"
+args+=(
+ -name "$1",debug-threads=on
+ -pidfile "/run/qemu-$1/pid"
+ -vnc unix:"/run/qemu-$1/vnc.sock"
+ -monitor unix:"/run/qemu-$1/monitor.sock",server,nowait
+ -daemonize
+)
+exec qemu-system-"${system}" "${args[@]}"
diff --git a/systemd/system/qemu@.service b/systemd/system/qemu@.service
new file mode 100644
index 0000000..7adcbfb
--- /dev/null
+++ b/systemd/system/qemu@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Virtual Machine %I
+Documentation=man:qemu(1)
+PartOf=machines.target
+Before=machines.target
+
+[Service]
+Type=forking
+RuntimeDirectory=qemu-%I
+PIDFile=/run/qemu-%I/pid
+ExecStart=/etc/systemd/system/qemu %I
+ExecStop=/bin/socat SYSTEM:'echo system_powerdown; sleep infinity' UNIX-CONNECT:/run/qemu-%I/monitor.sock
+
+[Install]
+WantedBy=machines.target