From: dv Date: Thu, 27 Jul 2023 09:27:43 +0000 (+0000) Subject: vmd(8): fix verbose logging in child processes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=61f4cd73731b746d6e9ca8a3fd7836083daa5bd3;p=openbsd vmd(8): fix verbose logging in child processes. The introduction of exec for vm's and fork+exec for virtio block and network devices missed passing the log verbosity in argv. Add the "-v" arguments based on current vverbosity at time of exec. ok brynet@, mlarkin@ --- diff --git a/usr.sbin/vmd/virtio.c b/usr.sbin/vmd/virtio.c index a58e3511543..798b5fea6d5 100644 --- a/usr.sbin/vmd/virtio.c +++ b/usr.sbin/vmd/virtio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtio.c,v 1.105 2023/07/15 18:32:21 dv Exp $ */ +/* $OpenBSD: virtio.c,v 1.106 2023/07/27 09:27:43 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -1475,12 +1475,15 @@ virtio_dev_launch(struct vmd_vm *vm, struct virtio_dev *dev) nargv[5] = "-i"; nargv[6] = vmm_fd; nargv[7] = "-n"; + nargv[8] = NULL; - if (env->vmd_verbose) { - nargv[8] = "-v"; + if (env->vmd_verbose == 1) { + nargv[8] = VMD_VERBOSE_1; nargv[9] = NULL; - } else - nargv[8] = NULL; + } else if (env->vmd_verbose > 1) { + nargv[8] = VMD_VERBOSE_2; + nargv[9] = NULL; + } /* Control resumes in vmd.c:main(). */ execvp(nargv[0], nargv); @@ -1699,8 +1702,10 @@ virtio_pci_io(int dir, uint16_t reg, uint32_t *data, uint8_t *intr, imsg_free(&imsg); if (msg.type == VIODEV_MSG_IO_READ && msg.data_valid) { +#if DEBUG log_debug("%s: got sync read response (reg=%s)", __func__, virtio_reg_name(msg.reg)); +#endif /* DEBUG */ *data = msg.data; /* * It's possible we're asked to {de,}assert after the diff --git a/usr.sbin/vmd/vmd.h b/usr.sbin/vmd/vmd.h index 744b8d19574..19995e951c7 100644 --- a/usr.sbin/vmd/vmd.h +++ b/usr.sbin/vmd/vmd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmd.h,v 1.123 2023/07/13 18:31:59 dv Exp $ */ +/* $OpenBSD: vmd.h,v 1.124 2023/07/27 09:27:43 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -102,6 +102,10 @@ /* 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 541222e0272..a48868c8dd0 100644 --- a/usr.sbin/vmd/vmm.c +++ b/usr.sbin/vmd/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.113 2023/07/13 18:31:59 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.114 2023/07/27 09:27:43 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -782,12 +782,15 @@ vmm_start_vm(struct imsg *imsg, uint32_t *id, pid_t *pid) nargv[3] = "-n"; nargv[4] = "-i"; nargv[5] = vmm_fd; + nargv[6] = NULL; - if (env->vmd_verbose) { - nargv[6] = "-v"; + if (env->vmd_verbose == 1) { + nargv[6] = VMD_VERBOSE_1; nargv[7] = NULL; - } else - nargv[6] = NULL; + } else if (env->vmd_verbose > 1) { + nargv[6] = VMD_VERBOSE_2; + nargv[7] = NULL; + } /* Control resumes in vmd main(). */ execvp(nargv[0], nargv);