Index | Thread | Search

From:
Yamasaki Yuu <miagetegorann@gmail.com>
Subject:
[PATCH 2/7] hyperv: attach drivers to channels regardless of monitor notification
To:
tech@openbsd.org
Date:
Wed, 11 Nov 2026 11:46:47 +0900

Download raw body.

Thread
hv_attach_devices() only offered channels that use monitored
notification to child drivers.  On Generation 2 VMs only the network
channel is monitored; the StorVSC channel isn't, so hvs(4) never
attached and there were no disks.  Mark the channels claimed by the
integration services instead and offer everything else.  Services
without a driver are not listed unless HYPERV_DEBUG is defined.

This also changes Generation 1 VMs.  Their IDE disks are offered
over VMBus as well, one channel per disk.  They now attach to
hvs(4), which keeps pciide(4) off them (pciide_skip_ata) as intended
since 2017, so their names change from wd to sd.  Installs that use
DUIDs are not affected.  Disks on the Generation 1 SCSI controller
attach too.  The IDE DVD drive stays on atapiscsi(4).
---
 sys/dev/pv/hyperv.c    | 7 ++++++-
 sys/dev/pv/hypervic.c  | 3 +--
 sys/dev/pv/hypervvar.h | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git sys/dev/pv/hyperv.c sys/dev/pv/hyperv.c
index 0c430a0345a..065cf1aa693 100644
--- sys/dev/pv/hyperv.c
+++ sys/dev/pv/hyperv.c
@@ -1788,12 +1788,17 @@ hv_handle_free(struct hv_channel *ch, uint32_t handle)
 static int
 hv_attach_print(void *aux, const char *name)
 {
+#ifdef HYPERV_DEBUG
 	struct hv_attach_args *aa = aux;
 
 	if (name)
 		printf("\"%s\" at %s", aa->aa_ident, name);
 
 	return (UNCONF);
+#else
+	/* Most offered services have no driver; don't list them. */
+	return (QUIET);
+#endif
 }
 
 int
@@ -1808,7 +1813,7 @@ hv_attach_devices(struct hv_softc *sc)
 	TAILQ_FOREACH(ch, &sc->sc_channels, ch_entry) {
 		if (ch->ch_state != HV_CHANSTATE_OFFERED)
 			continue;
-		if (!(ch->ch_flags & CHF_MONITOR))
+		if (ch->ch_flags & CHF_ICDEV)
 			continue;
 		dv = malloc(sizeof(*dv), M_DEVBUF, M_ZERO | M_NOWAIT);
 		if (dv == NULL) {
diff --git sys/dev/pv/hypervic.c sys/dev/pv/hypervic.c
index d78e0f861d9..90b18acc7ec 100644
--- sys/dev/pv/hypervic.c
+++ sys/dev/pv/hypervic.c
@@ -181,8 +181,6 @@ hv_attach_icdevs(struct hv_softc *sc)
 		TAILQ_FOREACH(ch, &sc->sc_channels, ch_entry) {
 			if (ch->ch_state != HV_CHANSTATE_OFFERED)
 				continue;
-			if (ch->ch_flags & CHF_MONITOR)
-				continue;
 			if (memcmp(dv->dv_type, &ch->ch_type,
 			    sizeof(ch->ch_type)) == 0)
 				break;
@@ -191,6 +189,7 @@ hv_attach_icdevs(struct hv_softc *sc)
 			continue;
 
 		dv->dv_ch = ch;
+		ch->ch_flags |= CHF_ICDEV;
 
 		/*
 		 * These services are not performance critical and
diff --git sys/dev/pv/hypervvar.h sys/dev/pv/hypervvar.h
index 9cd8036095d..94dc3366b3d 100644
--- sys/dev/pv/hypervvar.h
+++ sys/dev/pv/hypervvar.h
@@ -86,6 +86,7 @@ struct hv_channel {
 	uint32_t			 ch_flags;
 #define  CHF_BATCHED			  0x0001
 #define  CHF_MONITOR			  0x0002
+#define  CHF_ICDEV			  0x0004
 
 	uint8_t				 ch_mgroup;
 	uint8_t				 ch_mindex;