vmd(8): fix verbose logging in child processes.
authordv <dv@openbsd.org>
Thu, 27 Jul 2023 09:27:43 +0000 (09:27 +0000)
committerdv <dv@openbsd.org>
Thu, 27 Jul 2023 09:27:43 +0000 (09:27 +0000)
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@

usr.sbin/vmd/virtio.c
usr.sbin/vmd/vmd.h
usr.sbin/vmd/vmm.c

index a58e351..798b5fe 100644 (file)
@@ -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 <mlarkin@openbsd.org>
@@ -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
index 744b8d1..19995e9 100644 (file)
@@ -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 <mlarkin@openbsd.org>
 /* 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,
index 541222e..a48868c 100644 (file)
@@ -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 <mlarkin@openbsd.org>
@@ -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);