diff options
-rw-r--r-- | usr.sbin/vmd/psp.c | 6 | ||||
-rw-r--r-- | usr.sbin/vmd/virtio.c | 43 | ||||
-rw-r--r-- | usr.sbin/vmd/vmd.h | 6 | ||||
-rw-r--r-- | usr.sbin/vmd/vmm.c | 37 |
4 files changed, 43 insertions, 49 deletions
diff --git a/usr.sbin/vmd/psp.c b/usr.sbin/vmd/psp.c index 4c1cfdab617..320da37dc99 100644 --- a/usr.sbin/vmd/psp.c +++ b/usr.sbin/vmd/psp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psp.c,v 1.4 2024/11/06 22:06:16 bluhm Exp $ */ +/* $OpenBSD: psp.c,v 1.5 2024/11/06 23:04:45 bluhm Exp $ */ /* * Copyright (c) 2023, 2024 Hans-Joerg Hoexer <hshoexer@genua.de> @@ -200,7 +200,7 @@ psp_launch_measure(uint32_t handle) i++, p += 2, len -= 2) { snprintf(p, len, "%02x", lm.measure[i]); } - log_info("%s: measurement\t0x%s", __func__, buf); + log_info("%s: measurement 0x%s", __func__, buf); len = sizeof(buf); memset(buf, 0, len); @@ -209,7 +209,7 @@ psp_launch_measure(uint32_t handle) i++, p += 2, len -= 2) { snprintf(p, len, "%02x", lm.measure_nonce[i]); } - log_info("%s: nonce\t0x%s", __func__, buf); + log_info("%s: nonce 0x%s", __func__, buf); return (0); } diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index 79402d04e01..fa924bfc264 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.116 2024/09/26 01:45:13 jsg Exp $ */ +/* $OpenBSD: virtio.c,v 1.117 2024/11/06 23:04:45 bluhm Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -1296,7 +1296,7 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) char *nargv[12], num[32], vmm_fd[32], vm_name[VM_NAME_MAX], t[2]; pid_t dev_pid; int sync_fds[2], async_fds[2], ret = 0; - size_t sz = 0; + size_t i, sz = 0; struct viodev_msg msg; struct virtio_dev *dev_entry; struct imsg imsg; @@ -1441,7 +1441,6 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) fatalx("unable to close other virtio devs"); } - memset(&nargv, 0, sizeof(nargv)); memset(num, 0, sizeof(num)); snprintf(num, sizeof(num), "%d", sync_fds[1]); memset(vmm_fd, 0, sizeof(vmm_fd)); @@ -1453,25 +1452,25 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) t[0] = dev->dev_type; t[1] = '\0'; - nargv[0] = env->argv0; - nargv[1] = "-X"; - nargv[2] = num; - nargv[3] = "-t"; - nargv[4] = t; - nargv[5] = "-i"; - nargv[6] = vmm_fd; - nargv[7] = "-p"; - nargv[8] = vm_name; - nargv[9] = "-n"; - nargv[10] = NULL; - - if (env->vmd_verbose == 1) { - nargv[10] = VMD_VERBOSE_1; - nargv[11] = NULL; - } else if (env->vmd_verbose > 1) { - nargv[10] = VMD_VERBOSE_2; - nargv[11] = NULL; - } + i = 0; + nargv[i++] = env->argv0; + nargv[i++] = "-X"; + nargv[i++] = num; + nargv[i++] = "-t"; + nargv[i++] = t; + nargv[i++] = "-i"; + nargv[i++] = vmm_fd; + nargv[i++] = "-p"; + nargv[i++] = vm_name; + if (env->vmd_debug) + nargv[i++] = "-d"; + if (env->vmd_verbose == 1) + nargv[i++] = "-v"; + else if (env->vmd_verbose > 1) + nargv[i++] = "-vv"; + nargv[i++] = NULL; + if (i > sizeof(nargv) / sizeof(nargv[0])) + fatalx("%s: nargv overflow", __func__); /* Control resumes in vmd.c:main(). */ execvp(nargv[0], nargv); diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h index 613d846edf0..b84656fc20c 100644 --- a/usr.sbin/vmd/vmd.h +++ b/usr.sbin/vmd/vmd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.h,v 1.130 2024/11/06 22:06:16 bluhm Exp $ */ +/* $OpenBSD: vmd.h,v 1.131 2024/11/06 23:04:45 bluhm Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -104,10 +104,6 @@ /* Unique local address for IPv6 */ #define VMD_ULA_PREFIX "fd00::/8" -/* Verbosity arguments for use when caling execvp(2). */ -#define VMD_VERBOSE_1 "-v"; -#define VMD_VERBOSE_2 "-vv"; - enum imsg_type { IMSG_VMDOP_START_VM_REQUEST = IMSG_PROC_MAX, IMSG_VMDOP_START_VM_CDROM, diff --git a/usr.sbin/vmd/vmm.c b/usr.sbin/vmd/vmm.c index ca1c58983ea..0ed2ffe4580 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.124 2024/10/22 15:19:48 claudio Exp $ */ +/* $OpenBSD: vmm.c,v 1.125 2024/11/06 23:04:45 bluhm Exp $ */ /* * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org> @@ -762,7 +762,6 @@ vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid) * Prepare our new argv for execvp(2) with the fd of our open * pipe to the parent/vmm process as an argument. */ - memset(&nargv, 0, sizeof(nargv)); memset(num, 0, sizeof(num)); snprintf(num, sizeof(num), "%d", fds[1]); memset(vmm_fd, 0, sizeof(vmm_fd)); @@ -770,23 +769,23 @@ vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid) memset(psp_fd, 0, sizeof(psp_fd)); snprintf(psp_fd, sizeof(psp_fd), "%d", env->vmd_psp_fd); - nargv[0] = env->argv0; - nargv[1] = "-V"; - nargv[2] = num; - nargv[3] = "-n"; - nargv[4] = "-i"; - nargv[5] = vmm_fd; - nargv[6] = "-j"; - nargv[7] = psp_fd; - nargv[8] = NULL; - - if (env->vmd_verbose == 1) { - nargv[8] = VMD_VERBOSE_1; - nargv[9] = NULL; - } else if (env->vmd_verbose > 1) { - nargv[8] = VMD_VERBOSE_2; - nargv[9] = NULL; - } + i = 0; + nargv[i++] = env->argv0; + nargv[i++] = "-V"; + nargv[i++] = num; + nargv[i++] = "-i"; + nargv[i++] = vmm_fd; + nargv[i++] = "-j"; + nargv[i++] = psp_fd; + if (env->vmd_debug) + nargv[i++] = "-d"; + if (env->vmd_verbose == 1) + nargv[i++] = "-v"; + else if (env->vmd_verbose > 1) + nargv[i++] = "-vv"; + nargv[i++] = NULL; + if (i > sizeof(nargv) / sizeof(nargv[0])) + fatalx("%s: nargv overflow", __func__); /* Control resumes in vmd main(). */ execvp(nargv[0], nargv); |