summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2016-10-06 18:48:41 +0000
committerreyk <reyk@openbsd.org>2016-10-06 18:48:41 +0000
commitae6ee9de7f66edde7bd264b159f91ab1fb8e7689 (patch)
treecc81b5fa4222fcf6dc85609b7b47ed93a33991a4
parentRemove board IDs for the i.MX platform. The kernel doesn't need them anymore. (diff)
downloadwireguard-openbsd-ae6ee9de7f66edde7bd264b159f91ab1fb8e7689.tar.xz
wireguard-openbsd-ae6ee9de7f66edde7bd264b159f91ab1fb8e7689.zip
Terminate VMs on shutdown of vmd instead of leaving them running as
undead VM processes. OK mlarkin@
-rw-r--r--usr.sbin/vmd/vmd.c5
-rw-r--r--usr.sbin/vmd/vmd.h3
-rw-r--r--usr.sbin/vmd/vmm.c21
3 files changed, 24 insertions, 5 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index c8815be76e0..cab5400a32d 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.32 2016/10/05 17:30:13 reyk Exp $ */
+/* $OpenBSD: vmd.c,v 1.33 2016/10/06 18:48:41 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -52,8 +52,7 @@ static struct privsep_proc procs[] = {
/* Keep "priv" on top as procs[0] */
{ "priv", PROC_PRIV, NULL, priv },
{ "control", PROC_CONTROL, vmd_dispatch_control, control },
- { "vmm", PROC_VMM, vmd_dispatch_vmm, vmm },
-
+ { "vmm", PROC_VMM, vmd_dispatch_vmm, vmm, vmm_shutdown },
};
/* For the privileged process */
diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h
index c072e1219b6..04e7e359a9a 100644
--- a/usr.sbin/vmd/vmd.h
+++ b/usr.sbin/vmd/vmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.h,v 1.27 2016/10/05 17:30:13 reyk Exp $ */
+/* $OpenBSD: vmd.h,v 1.28 2016/10/06 18:48:41 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -171,6 +171,7 @@ int vm_priv_brconfig(struct privsep *, struct vmd_switch *);
/* vmm.c */
void vmm(struct privsep *, struct privsep_proc *);
+void vmm_shutdown(void);
int write_mem(paddr_t, void *buf, size_t);
int read_mem(paddr_t, void *buf, size_t);
int opentap(char *);
diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c
index 83215c24023..90c81ef2866 100644
--- a/usr.sbin/vmd/vmm.c
+++ b/usr.sbin/vmd/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.47 2016/10/05 17:30:13 reyk Exp $ */
+/* $OpenBSD: vmm.c,v 1.48 2016/10/06 18:48:41 reyk Exp $ */
/*
* Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
@@ -315,6 +315,25 @@ vmm_sighdlr(int sig, short event, void *arg)
}
/*
+ * vmm_shutdown
+ *
+ * Terminate VMs on shutdown to avoid "zombie VM" processes.
+ */
+void
+vmm_shutdown(void)
+{
+ struct vm_terminate_params vtp;
+ struct vmd_vm *vm, *vm_next;
+
+ TAILQ_FOREACH_SAFE(vm, env->vmd_vms, vm_entry, vm_next) {
+ vtp.vtp_vm_id = vm->vm_params.vcp_id;
+
+ /* XXX suspend or request graceful shutdown */
+ terminate_vm(&vtp);
+ }
+}
+
+/*
* vcpu_reset
*
* Requests vmm(4) to reset the VCPUs in the indicated VM to