summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vmd.c
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2023-01-14 20:55:56 +0000
committerDave Voutila <dv@cvs.openbsd.org>2023-01-14 20:55:56 +0000
commite42623735b649cec551a362e562dc629b10aed29 (patch)
tree856d0a9400942209774fea6699264a9f28ed9043 /usr.sbin/vmd/vmd.c
parent349f21b018fdca9463438de483454f2a19906717 (diff)
Only open /dev/vmm once in vmd(8).
Have the parent process open /dev/vmm and send the fd to the vmm child process. Only the vmm process and its resulting children (guest vms) need it for ioctl calls. ok kn@
Diffstat (limited to 'usr.sbin/vmd/vmd.c')
-rw-r--r--usr.sbin/vmd/vmd.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/vmd/vmd.c b/usr.sbin/vmd/vmd.c
index 6bffb2519a3..0557a3101c9 100644
--- a/usr.sbin/vmd/vmd.c
+++ b/usr.sbin/vmd/vmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmd.c,v 1.135 2022/12/28 21:30:19 jmc Exp $ */
+/* $OpenBSD: vmd.c,v 1.136 2023/01/14 20:55:55 dv Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -847,8 +847,8 @@ main(int argc, char **argv)
proc_priv->p_pw = &proc_privpw; /* initialized to all 0 */
proc_priv->p_chroot = ps->ps_pw->pw_dir; /* from VMD_USER */
- /* Open /dev/vmm */
- if (env->vmd_noaction == 0) {
+ /* Open /dev/vmm early. */
+ if (env->vmd_noaction == 0 && proc_id == PROC_PARENT) {
env->vmd_fd = open(VMM_NODE, O_RDWR);
if (env->vmd_fd == -1)
fatal("%s", VMM_NODE);
@@ -971,6 +971,10 @@ vmd_configure(void)
exit(0);
}
+ /* Send VMM device fd to vmm proc. */
+ proc_compose_imsg(&env->vmd_ps, PROC_VMM, -1,
+ IMSG_VMDOP_RECEIVE_VMM_FD, -1, env->vmd_fd, NULL, 0);
+
/* Send shared global configuration to all children */
if (config_setconfig(env) == -1)
return (-1);