Commit
+32 -18 +/-4 browse
1 | diff --git a/PKGBUILD b/PKGBUILD |
2 | index b41f081..5aa3003 100644 |
3 | --- a/PKGBUILD |
4 | +++ b/PKGBUILD |
5 | @@ -9,10 +9,10 @@ validpgpkeys=() |
6 | |
7 | build() { |
8 | cp ../qemu-shim . |
9 | - cp ../qemu@.service . |
10 | + cp ../qemu-shim@.service . |
11 | } |
12 | |
13 | package() { |
14 | install -Dm755 "${pkgname}" -t "${pkgdir}"/usr/bin/ |
15 | - install -Dm644 "qemu@.service" -t "${pkgdir}"/usr/lib/systemd/user/ |
16 | + install -Dm644 "qemu-shim@.service" -t "${pkgdir}"/usr/lib/systemd/user/ |
17 | } |
18 | diff --git a/README.md b/README.md |
19 | index b2a7e3c..9a45199 100644 |
20 | --- a/README.md |
21 | +++ b/README.md |
22 | @@ -1,13 +1,23 @@ |
23 | # qemu-shim |
24 | |
25 | A tiny script for running VMs with QEMU with graceful shutdown in a way that |
26 | - is compatible with systemd. This script makes a few assumptions about the |
27 | - arguments it is given: |
28 | + is compatible with init systems like `systemd` or `OpenRC`. It was inspired by |
29 | + Arch Linux's [QEMU wiki](https://wiki.archlinux.org/title/QEMU#With_systemd_service). |
30 | + This script makes a few assumptions about the arguments it is given: |
31 | |
32 | * The args are a valid QEMU command |
33 | * They contain the -name flag |
34 | - * They contain a -monitor flag with a unix socket specified. TCP/Telnet is not |
35 | - * yet supported by the script. |
36 | + * They contain a -monitor flag with a unix socket specified. TCP/Telnet is not yet supported by the script. |
37 | * The guest OS supports ACPI shutdown signals |
38 | |
39 | + |
40 | ## Example |
41 | + ``` |
42 | + NAME=fuu |
43 | + qemu-shim qemu-system-x86_64 -name $NAME -m 2G -enable-kvm \ |
44 | + -boot order=d -drive ~/qemu/disks/$NAME.qcow \ |
45 | + -cpu host -smp 2 \ |
46 | + -vga qxl \ |
47 | + -spice unix=on,addr="/var/run/$UID/$NAME.socket,disable-ticketing=on" \ |
48 | + -monitor unix:/var/run/$UID/$NAME.socket,server,nowait |
49 | + ``` |
50 | diff --git a/qemu-shim@.service b/qemu-shim@.service |
51 | new file mode 100644 |
52 | index 0000000..1568c1b |
53 | --- /dev/null |
54 | +++ b/qemu-shim@.service |
55 | @@ -0,0 +1,16 @@ |
56 | + [Unit] |
57 | + Description=QEMU Virtual Machine (qemu-shim) |
58 | + |
59 | + [Service] |
60 | + KillMode=process |
61 | + ExecStart=/usr/bin/qemu-shim \ |
62 | + qemu-system-x86_64 \ |
63 | + -name %i \ |
64 | + -m 512M \ |
65 | + -enable-kvm \ |
66 | + -device virtio-serial-pci \ |
67 | + -spice unix=on,addr="%t/%i.socket,disable-ticketing=on" \ |
68 | + -monitor "unix:%t/%i-monitor.socket,server,nowait" |
69 | + |
70 | + [Install] |
71 | + WantedBy=default.target |
72 | diff --git a/qemu@.service b/qemu@.service |
73 | deleted file mode 100644 |
74 | index 346893c..0000000 |
75 | --- a/qemu@.service |
76 | +++ /dev/null |
77 | @@ -1,12 +0,0 @@ |
78 | - [Unit] |
79 | - Description=QEMU Virtual Machine (qemu-shim) |
80 | - |
81 | - [Service] |
82 | - KillMode=process |
83 | - Environment="QEMU_SHIM_TIMEOUT=10" |
84 | - ExecStart=/usr/bin/qemu-shim \ |
85 | - qemu-system-x86_64 -name %N \ |
86 | - -m 256M -nographic -monitor "unix:/tmp/test.sock,server,nowait" |
87 | - |
88 | - [Install] |
89 | - WantedBy=multi-user.target |