[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Call AdapterDisable during NdisDevicePnPEventSurpriseRemoved


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Tu Dinh" <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Thu, 16 Apr 2026 11:10:12 +0000
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@xxxxxxxxxx" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
  • Cc: "Tu Dinh" <ngoc-tu.dinh@xxxxxxxxxx>, "Owen Smith" <owen.smith@xxxxxxxxxx>
  • Delivery-date: Thu, 16 Apr 2026 12:02:35 +0000
  • Feedback-id: 30504962:30504962.20260416:md
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

During a surprise removal, NDIS performs the following sequence:
1. Call MiniportDevicePnPEventNotify(NdisDevicePnPEventSurpriseRemoved)
2. Pause protocol and filter drivers
3. Only then pause the miniport

Since MiniportPause is not called until after the protocols have been
paused, in the absence of hang detection, step 2 will hang indefinitely
while NDIS waits for transmitted packets to be returned even though the
backend's already gone.

MiniportDevicePnPEventNotify is currently the last opportunity for us to
disable the adapter, so do that here.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xennet/miniport.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/xennet/miniport.c b/src/xennet/miniport.c
index 3ec76a9..9f3a8c6 100644
--- a/src/xennet/miniport.c
+++ b/src/xennet/miniport.c
@@ -230,10 +230,16 @@ MiniportDevicePnPEventNotify(
     IN  PNET_DEVICE_PNP_EVENT   NetDevicePnPEvent
     )
 {
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);
-    UNREFERENCED_PARAMETER(NetDevicePnPEvent);
+    PXENNET_ADAPTER             Adapter = 
(PXENNET_ADAPTER)MiniportAdapterContext;
 
-    Trace("<===>\n");
+    if (NetDevicePnPEvent->DevicePnPEvent != NdisDevicePnPEventSurpriseRemoved)
+        return;
+
+    Trace("====>\n");
+
+    AdapterDisable(Adapter);
+
+    Trace("<====\n");
 }
 
 static
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.