diff options
author | Dominique Martinet <asmadeus@codewreck.org> | 2016-01-19 18:05:32 +0100 |
---|---|---|
committer | Dominique Martinet <asmadeus@codewreck.org> | 2016-01-19 18:05:53 +0100 |
commit | 9086ab023019c2667c390cf09db491346e10d5f5 (patch) | |
tree | 45cce55e0d9330ef442d538db20a2977dbb326f8 | |
parent | 27e9f2f465267043283faaf9672e5ed578b72faf (diff) |
host_config: systemd units (+kvm-wrapper cleanup command for post-boot cleanup)
-rw-r--r-- | host_config/kvm-wrapper-cleanup.service | 7 | ||||
-rw-r--r-- | host_config/kvm-wrapper@.service | 11 | ||||
-rwxr-xr-x | kvm-wrapper.sh | 9 |
3 files changed, 27 insertions, 0 deletions
diff --git a/host_config/kvm-wrapper-cleanup.service b/host_config/kvm-wrapper-cleanup.service new file mode 100644 index 0000000..8890c9c --- /dev/null +++ b/host_config/kvm-wrapper-cleanup.service @@ -0,0 +1,7 @@ +[Unit] +Description=Cleanup kvm-wrapper local files after reboot +After=local-fs.target remote-fs.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/kvm-wrapper cleanup diff --git a/host_config/kvm-wrapper@.service b/host_config/kvm-wrapper@.service new file mode 100644 index 0000000..a91f58a --- /dev/null +++ b/host_config/kvm-wrapper@.service @@ -0,0 +1,11 @@ +[Unit] +Description=VM %I +Requires=kvm-wrapper-cleanup.service + +[Service] +Type=simple +ExecStart=/usr/bin/kvm-wrapper start-here %I +ExecStop=/usr/bin/kvm-wrapper stop %I + +[Install] +WantedBy=multi-user.target diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh index 8a26a37..20a458c 100755 --- a/kvm-wrapper.sh +++ b/kvm-wrapper.sh @@ -594,6 +594,11 @@ function kvm_top () top -d 2 -cp $pidlist } +function kvm_cleanup () +{ + [[ -n "$PID_DIR" ]] && rm -f "$PID_DIR/$(hostname -s):"*.pid +} + # Main function: start a virtual machine function kvm_start_vm () { @@ -1387,6 +1392,10 @@ case "$1" in else print_help; fi exit 0 ;; + cleanup) + kvm_cleanup + exit 0 + ;; help) shift print_help $@ |