]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Add Unplug v2 (REV_0900000A)
authorOwen Smith <owen.smith@cloud.com>
Wed, 13 Sep 2023 14:15:22 +0000 (15:15 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Fri, 29 Sep 2023 13:42:28 +0000 (14:42 +0100)
If NICs have not been unplugged, do not start PV network devices and trigger a
required reboot.
This is to avoid the upgrade case where both emulated and PV devices could be
present, due to a 'revert to emulated' policy and emulated NICs not currently
getting IP configurations so the HasAlias value is not determined correctly.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
Adjusted XENBUS_UNPLUG method naming to match XENBUS and re-imported the
header.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
include/unplug_interface.h
src/xenvif.inf
src/xenvif/pdo.c

index e465e2e9e93cbcde84d1d3fc93817fef46173821..dbdc76d0c863d51e09f658801d78ebe3f7366715 100644 (file)
@@ -85,6 +85,20 @@ typedef VOID
     IN  BOOLEAN                     Make
     );
 
+/*! \typedef XENBUS_UNPLUG_IS_REQUESTED
+    \brief Has a type of emulated device been unplugged
+
+    \param Interface The interface header
+    \param Type The type of device
+
+    \return TRUE The type of device has been unplugged this boot.
+*/
+typedef BOOLEAN
+(*XENBUS_UNPLUG_IS_REQUESTED)(
+    IN  PINTERFACE                  Interface,
+    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
+    );
+
 // {73db6517-3d06-4937-989f-199b7501e229}
 DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
@@ -100,7 +114,19 @@ struct _XENBUS_UNPLUG_INTERFACE_V1 {
     XENBUS_UNPLUG_REQUEST   UnplugRequest;
 };
 
-typedef struct _XENBUS_UNPLUG_INTERFACE_V1 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
+/*! \struct _XENBUS_UNPLUG_INTERFACE_V2
+    \brief UNPLUG interface version 2
+    \ingroup interfaces
+*/
+struct _XENBUS_UNPLUG_INTERFACE_V2 {
+    INTERFACE                   Interface;
+    XENBUS_UNPLUG_ACQUIRE       UnplugAcquire;
+    XENBUS_UNPLUG_RELEASE       UnplugRelease;
+    XENBUS_UNPLUG_REQUEST       UnplugRequest;
+    XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
+};
+
+typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
 
 /*! \def XENBUS_UNPLUG
     \brief Macro at assist in method invocation
@@ -111,6 +137,6 @@ typedef struct _XENBUS_UNPLUG_INTERFACE_V1 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNP
 #endif  // _WINDLL
 
 #define XENBUS_UNPLUG_INTERFACE_VERSION_MIN  1
-#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  1
+#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_UNPLUG_INTERFACE_H
index 4b5c9f7a18f7d2850988392e37260a29f032375e..3db059dab64cdd9132334209c399cf40e9badec4 100644 (file)
@@ -60,9 +60,9 @@ xenvif_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll
 ; DisplayName          Section         DeviceID
 ; -----------          -------         --------
 
-%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_09000009
-%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_09000009
-%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_09000009
+%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_0900000A
+%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_0900000A
+%XenVifName%           =XenVif_Inst,   XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_0900000A
 
 [XenVif_Inst] 
 CopyFiles=XenVif_Copyfiles
index 2e47be2fd14f9b096161ad71647a0c47ba2a6663..5c951d909640a7aa506f322262f03db467355eb2 100644 (file)
@@ -1247,6 +1247,27 @@ PdoUnplugRequest(
     XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
 }
 
+static BOOLEAN
+PdoUnplugRequested(
+    IN  PXENVIF_PDO Pdo
+    )
+{
+    BOOLEAN         State;
+    NTSTATUS        status;
+
+    status = XENBUS_UNPLUG(Acquire, &Pdo->UnplugInterface);
+    if (!NT_SUCCESS(status))
+        return FALSE;
+
+    State = XENBUS_UNPLUG(IsRequested,
+                          &Pdo->UnplugInterface,
+                          XENBUS_UNPLUG_DEVICE_TYPE_NICS);
+
+    XENBUS_UNPLUG(Release, &Pdo->UnplugInterface);
+
+    return State;
+}
+
 static DECLSPEC_NOINLINE NTSTATUS
 PdoStartDevice(
     IN  PXENVIF_PDO     Pdo,
@@ -1343,7 +1364,7 @@ PdoStartDevice(
         break;
     }
 
-    if (Pdo->HasAlias) {
+    if (Pdo->HasAlias || !PdoUnplugRequested(Pdo)) {
         PdoUnplugRequest(Pdo, TRUE);
 
         status = STATUS_PNP_REBOOT_REQUIRED;