diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-11-06 23:04:46 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2024-11-06 23:04:46 +0000 |
commit | 011f88d681392c6029ab2525a8d00f8ae7fc8fbd (patch) | |
tree | 628d1aa55f7187b7823dddb51147db27855d819c /usr.sbin/vmd/virtio.c | |
parent | ef15bf9fd8e2d8a6fb1fb39451923c217426b923 (diff) |
Fix vmd(8) logging to syslog(3) from child process.
Log messages from vmd(8) child processes went to /dev/null. Re-exec
set the -n option, which in turn sets vmd_noaction and vmd_debug.
Debugging means no more syslog(3), but stderr, which is /dev/null
for a daemon.
Remove -n from child re-exec, it does not have any effect except
looging. Pass on the -d flag when debugging. The VMD_VERBOSE
defines are more confusing than useful, just write -v like all the
other options. Rework creation of execvp arguments. Do not use
tab in syslog messages, space is sufficient.
OK mlarkin@ hshoexer@ dv@
Diffstat (limited to 'usr.sbin/vmd/virtio.c')
-rw-r--r-- | usr.sbin/vmd/virtio.c | 43 |
1 files changed, 21 insertions, 22 deletions
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); |