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

[PATCH v2 4/6] Add Unplug v2 interface (REV_0900000A)



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@xxxxxxxxx>
---
 include/revision.h         |  3 +-
 include/unplug_interface.h | 30 +++++++++++++++++--
 include/xen.h              |  7 +++++
 src/xen/unplug.c           | 15 ++++++++++
 src/xenbus/unplug.c        | 59 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/include/revision.h b/include/revision.h
index 4d91927..9577fdb 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -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
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index e465e2e..ca55027 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -85,6 +85,20 @@ typedef VOID
     IN  BOOLEAN                     Make
     );
 
+/*! \typedef XENBUS_UNPLUG_WASREQUESTED
+    \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_WASREQUESTED)(
+    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_WASREQUESTED  UnplugWasRequested;
+};
+
+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
diff --git a/include/xen.h b/include/xen.h
index 132de21..37feef4 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -377,6 +377,13 @@ UnplugDecrementValue(
     IN  UNPLUG_TYPE Type
     );
 
+XEN_API
+VOID
+UnplugIsRequested(
+    IN  UNPLUG_TYPE Type,
+    OUT PBOOLEAN    Requested
+    );
+
 // LOG
 
 typedef enum _LOG_LEVEL {
diff --git a/src/xen/unplug.c b/src/xen/unplug.c
index ab94da5..2709153 100644
--- a/src/xen/unplug.c
+++ b/src/xen/unplug.c
@@ -344,6 +344,21 @@ fail1:
     return status;
 }
 
+XEN_API
+VOID
+UnplugIsRequested(
+    IN  UNPLUG_TYPE Type,
+    OUT PBOOLEAN    Requested
+    )
+{
+    PUNPLUG_CONTEXT Context = &UnplugContext;
+    KIRQL           Irql;
+
+    AcquireHighLock(&Context->Lock, &Irql);
+    *Requested = Context->Request[Type];
+    ReleaseHighLock(&Context->Lock, Irql);
+}
+
 XEN_API
 VOID
 UnplugDevices(
diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
index f2f13fa..235783c 100644
--- a/src/xenbus/unplug.c
+++ b/src/xenbus/unplug.c
@@ -110,6 +110,40 @@ UnplugRequest(
     ReleaseMutex(&Context->Mutex);
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
+static BOOLEAN
+UnplugWasRequested(
+    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:
+        UnplugIsRequested(UNPLUG_NICS, &Requested);
+        break;
+
+    case XENBUS_UNPLUG_DEVICE_TYPE_DISKS:
+        UnplugIsRequested(UNPLUG_DISKS, &Requested);
+        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,
+    UnplugWasRequested
+};
+
 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;
-- 
2.41.0.windows.3




 


Rackspace

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