git: 9ea13242985d - main - bhyve: Add CPU pinning diagnostic message

From: Chuck Tuffli <chuck_at_FreeBSD.org>
Date: Tue, 30 Jun 2026 22:19:00 UTC
The branch main has been updated by chuck:

URL: https://cgit.FreeBSD.org/src/commit/?id=9ea13242985dc145b2471cc8f651be87c6a74bfe

commit 9ea13242985dc145b2471cc8f651be87c6a74bfe
Author:     John De Boskey <jwd@FreeBSD.org>
AuthorDate: 2026-06-30 21:29:50 +0000
Commit:     Chuck Tuffli <chuck@FreeBSD.org>
CommitDate: 2026-06-30 22:18:20 +0000

    bhyve: Add CPU pinning diagnostic message
    
    When pinning a vcpu to a hostcpu fails, print out a diagnostic message
    to stderr indicating the failing CPU pair.
    
    MFC after:      1 month
    Reviewed by:    bnovkov
    Differential Revision:  https://reviews.freebsd.org/D57619
---
 usr.sbin/bhyve/bhyverun.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index b5e7a4709fb4..8cbc19fcfef8 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -566,15 +566,21 @@ fbsdrun_start_thread(void *param)
 {
 	char tname[MAXCOMLEN + 1];
 	struct vcpu_info *vi = param;
-	int error;
 
 	snprintf(tname, sizeof(tname), "vcpu %d", vi->vcpuid);
 	pthread_set_name_np(pthread_self(), tname);
 
 	if (vcpumap[vi->vcpuid] != NULL) {
-		error = pthread_setaffinity_np(pthread_self(),
-		    sizeof(cpuset_t), vcpumap[vi->vcpuid]);
-		assert(error == 0);
+		if (pthread_setaffinity_np(pthread_self(),
+		    sizeof(cpuset_t), vcpumap[vi->vcpuid]) != 0) {
+			int i;
+			warn("Error pinning vcpu %d to host cpuset@%p", vi->vcpuid,
+			    vcpumap[vi->vcpuid]);
+			CPU_FOREACH_ISSET(i, vcpumap[vi->vcpuid]) {
+				warnx("cpu %d enabled\n", i);
+			}
+			exit(BHYVE_EXIT_ERROR);
+		}
 	}
 
 #ifdef BHYVE_SNAPSHOT