]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Add Unplug v2 interface (REV_0900000A)
authorOwen Smith <owen.smith@cloud.com>
Wed, 13 Sep 2023 13:45:16 +0000 (14:45 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Thu, 28 Sep 2023 15:25:09 +0000 (16:25 +0100)
Unplug v2 adds a query call to determine if a device type has had its unplug issued.
This is useful during upgrade cases when the Unplug keys have been set to 0, and can
be used to prevent XenVif from starting whilst emulated devices are present, but those
emulated devices have not been assigned a valid configuration yet (emulated devices
will receive valid configuration, but not at this point in the startup sequence during
upgrade)

Signed-off-by: Owen Smith <owen.smith@cloud.com>
Renamed UnplugWasRequested() to UnplugIsRequested() in the XENBUS_UNPLUG_INTERFACE_V2
by renaming the clashing XEN_API function from UnplugIsRequested() to UnplugGetRequest()

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
include/revision.h
include/unplug_interface.h
include/xen.h
src/xen/unplug.c
src/xenbus/unplug.c

index 4d919274ff15cf3990818ab233ad8f2499b1ede8..9577fdb008a57ee2c1a7b65fccd77fe084f7a7e6 100644 (file)
@@ -57,6 +57,7 @@
     DEFINE_REVISION(0x09000006,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000007,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  2), \
     DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
-    DEFINE_REVISION(0x09000009,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2)
+    DEFINE_REVISION(0x09000009,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
+    DEFINE_REVISION(0x0900000A,  1,  4,  9,  1,  2,  1,  2,  4,  2,  1,  2)
 
 #endif  // _REVISION_H
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 132de21c1b62db91512e3362678ec5917eba8de6..f8721e89dd8c4ed6cd168bf06e3853476403dd10 100644 (file)
@@ -377,6 +377,12 @@ UnplugDecrementValue(
     IN  UNPLUG_TYPE Type
     );
 
+XEN_API
+BOOLEAN
+UnplugGetRequest(
+    IN  UNPLUG_TYPE Type
+    );
+
 // LOG
 
 typedef enum _LOG_LEVEL {
index ab94da5bc375d8c09aab0c5cf09de5f59c807979..7ace2ab0787926d6b460e7a1ff03c857f874221f 100644 (file)
@@ -344,6 +344,23 @@ fail1:
     return status;
 }
 
+XEN_API
+BOOLEAN
+UnplugGetRequest(
+    IN  UNPLUG_TYPE Type
+    )
+{
+    PUNPLUG_CONTEXT Context = &UnplugContext;
+    KIRQL           Irql;
+    BOOLEAN         Request;
+
+    AcquireHighLock(&Context->Lock, &Irql);
+    Request = Context->Request[Type];
+    ReleaseHighLock(&Context->Lock, Irql);
+
+    return Request;
+}
+
 XEN_API
 VOID
 UnplugDevices(
index f2f13fa9be435a92b2b53380a91054f9c813e998..7c5ffc464b3897fce79a8adfdea1a52e4d0bacf1 100644 (file)
@@ -110,6 +110,40 @@ UnplugRequest(
     ReleaseMutex(&Context->Mutex);
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
+static BOOLEAN
+UnplugIsRequested(
+    IN  PINTERFACE                  Interface,
+    IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
+    )
+{
+    PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
+    BOOLEAN                         Requested;
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    AcquireMutex(&Context->Mutex);
+
+    Requested = FALSE;
+    switch (Type) {
+    case XENBUS_UNPLUG_DEVICE_TYPE_NICS:
+        Requested = UnplugGetRequest(UNPLUG_NICS);
+        break;
+
+    case XENBUS_UNPLUG_DEVICE_TYPE_DISKS:
+        Requested = UnplugGetRequest(UNPLUG_DISKS);
+        break;
+
+    default:
+        ASSERT(FALSE);
+        break;
+    }
+
+    ReleaseMutex(&Context->Mutex);
+
+    return Requested;
+}
+
 static NTSTATUS
 UnplugAcquire(
     IN  PINTERFACE          Interface
@@ -157,6 +191,14 @@ static struct _XENBUS_UNPLUG_INTERFACE_V1 UnplugInterfaceVersion1 = {
     UnplugRequest
 };
 
+static struct _XENBUS_UNPLUG_INTERFACE_V2 UnplugInterfaceVersion2 = {
+    { sizeof (struct _XENBUS_UNPLUG_INTERFACE_V2), 2, NULL, NULL, NULL },
+    UnplugAcquire,
+    UnplugRelease,
+    UnplugRequest,
+    UnplugIsRequested
+};
+
 NTSTATUS
 UnplugInitialize(
     IN  PXENBUS_FDO             Fdo,
@@ -218,6 +260,23 @@ UnplugGetInterface(
         status = STATUS_SUCCESS;
         break;
     }
+    case 2: {
+        struct _XENBUS_UNPLUG_INTERFACE_V2   *UnplugInterface;
+
+        UnplugInterface = (struct _XENBUS_UNPLUG_INTERFACE_V2 *)Interface;
+
+        status = STATUS_BUFFER_OVERFLOW;
+        if (Size < sizeof (struct _XENBUS_UNPLUG_INTERFACE_V2))
+            break;
+
+        *UnplugInterface = UnplugInterfaceVersion2;
+
+        ASSERT3U(Interface->Version, ==, Version);
+        Interface->Context = Context;
+
+        status = STATUS_SUCCESS;
+        break;
+    }
     default:
         status = STATUS_NOT_SUPPORTED;
         break;