summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/vioblk.c
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2023-09-26 01:53:55 +0000
committerDave Voutila <dv@cvs.openbsd.org>2023-09-26 01:53:55 +0000
commitb8e6fca5419f909fc39ece18850318eabeed5fa8 (patch)
tree29e48e26c23cccaed50bc73440b7ec0b7146c574 /usr.sbin/vmd/vioblk.c
parent72e6fdbb6d6a55641e4102bd4460a25351a6f3f5 (diff)
vmd(8): disambiguate log messages per vm and device.
The logging output from vmd(8) often specifies the function performing the logging, but leaves which vm or vm device to guesswork and reading tea leaves. Change the logging formatting to prefix with information about the specific vm and potentially the device subprocess. Most of this logging is behind the "verbose" mode, but for warnings this will clarify which vm or device logged the warning. The format of vm/<name>/<device><index> is chosen to be concise and less ugly than other approaches. This adjusts the process naming for devices to match, dropping the use of brackets. In the process of this change, updating log settings dynamically via vmctl(8) is fixed by properly broadcasting that information to the device subprocesses. The "vmm" process also now updates its own state properly, so settings survive vm reboots. ok mlarkin@
Diffstat (limited to 'usr.sbin/vmd/vioblk.c')
-rw-r--r--usr.sbin/vmd/vioblk.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/vmd/vioblk.c b/usr.sbin/vmd/vioblk.c
index a74348441fa..4dbd7f129ad 100644
--- a/usr.sbin/vmd/vioblk.c
+++ b/usr.sbin/vmd/vioblk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vioblk.c,v 1.8 2023/09/14 15:25:43 dv Exp $ */
+/* $OpenBSD: vioblk.c,v 1.9 2023/09/26 01:53:54 dv Exp $ */
/*
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
@@ -75,8 +75,6 @@ vioblk_main(int fd, int fd_vmm)
off_t szp = 0;
int i, ret, type;
- log_procinit("vioblk");
-
/*
* stdio - needed for read/write to disk fds and channels to the vm.
* vmm + proc - needed to create shared vm mappings.
@@ -118,7 +116,9 @@ vioblk_main(int fd, int fd_vmm)
}
vcp = &vm.vm_params.vmc_params;
current_vm = &vm;
- setproctitle("%s/vioblk[%d]", vcp->vcp_name, vioblk->idx);
+
+ setproctitle("%s/vioblk%d", vcp->vcp_name, vioblk->idx);
+ log_procinit("vm/%s/vioblk%d", vcp->vcp_name, vioblk->idx);
/* Now that we have our vm information, we can remap memory. */
ret = remap_guest_mem(&vm, fd_vmm);
@@ -154,7 +154,7 @@ vioblk_main(int fd, int fd_vmm)
goto fail;
}
vioblk->capacity = szp / 512;
- log_debug("%s: initialized vioblk[%d] with %s image (capacity=%lld)",
+ log_debug("%s: initialized vioblk%d with %s image (capacity=%lld)",
__func__, vioblk->idx, disk_type(type), vioblk->capacity);
/* If we're restoring hardware, reinitialize the virtqueue hva. */
@@ -434,6 +434,7 @@ dev_dispatch_vm(int fd, short event, void *arg)
struct imsgbuf *ibuf = &iev->ibuf;
struct imsg imsg;
ssize_t n = 0;
+ int verbose;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN)
@@ -472,6 +473,11 @@ dev_dispatch_vm(int fd, short event, void *arg)
case IMSG_VMDOP_UNPAUSE_VM:
log_debug("%s: unpausing", __func__);
break;
+ case IMSG_CTL_VERBOSE:
+ IMSG_SIZE_CHECK(&imsg, &verbose);
+ memcpy(&verbose, imsg.data, sizeof(verbose));
+ log_setverbose(verbose);
+ break;
default:
log_warnx("%s: unhandled imsg type %d", __func__,
imsg.hdr.type);