From ad00e8c1670a81ad060e76292d00f4c4814074da Mon Sep 17 00:00:00 2001 From: dv Date: Sun, 8 Jan 2023 19:57:17 +0000 Subject: [PATCH] vmd(8): add thread names to vm process. ok guenther@. --- usr.sbin/vmd/vm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/vmd/vm.c b/usr.sbin/vmd/vm.c index f2852411550..25204bcccb8 100644 --- a/usr.sbin/vmd/vm.c +++ b/usr.sbin/vmd/vm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm.c,v 1.80 2023/01/04 02:19:19 dv Exp $ */ +/* $OpenBSD: vm.c,v 1.81 2023/01/08 19:57:17 dv Exp $ */ /* * Copyright (c) 2015 Mike Larkin @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include /* PAGE_SIZE */ +#include /* PAGE_SIZE, MAXCOMLEN */ #include #include #include @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -1211,6 +1212,7 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_PER_DISK], size_t i; int ret; pthread_t *tid, evtid; + char tname[MAXCOMLEN + 1]; struct vm_run_params **vrp; void *exit_status; @@ -1353,6 +1355,9 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_PER_DISK], __func__, i); return (ret); } + + snprintf(tname, sizeof(tname), "vcpu-%zu", i); + pthread_set_name_np(tid[i], tname); } log_debug("%s: waiting on events for VM %s", __func__, vcp->vcp_name); @@ -1362,6 +1367,7 @@ run_vm(int child_cdrom, int child_disks[][VM_MAX_BASE_PER_DISK], log_warn("%s: could not create event thread", __func__); return (ret); } + pthread_set_name_np(evtid, "event"); for (;;) { ret = pthread_cond_wait(&threadcond, &threadmutex); -- 2.20.1