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

[win-pv-devel] [PATCH] Handle ActiveLocationInformation value not found


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 19 Aug 2019 15:26:15 +0100
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=owen.smith@xxxxxxxxxx; spf=Pass smtp.mailfrom=owen.smith@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Mon, 19 Aug 2019 14:27:15 +0000
  • Ironport-sdr: VgdAJ6msmARB783tk83UjjkQgeAsf59QZqCkr/zKOs1O9tvo0gEv81+6eetPfwT8BZt4qhlWBH zwKG88Gfw+9HyEnR1dkNpcW9/ElADmIIIw6dea13sy5sCDdQsFsxnYWV200rOwWfNkD6wrPklx ubvDkWCYcMlg0Vy8TTSBdVOkhhIg18oy+ahcTU5x0B7Wd+yNjg2jgx6GQxQIRSCzdkMwVOBRvt sJlwtLRTByi5MeHFsc3FvHNIs3g5XjQdfV6Lh7Ld6nEnik53INV1KjvZS0DVG2wtH45bHyqu8b bUY=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

v8.2 drivers do not set ActiveLocationInformation, so when upgrading
xenbus to v9.0, xenfilt fails during PdoSetDeviceInformation.

Allow xenfilt to handle missing ActiveLocationInformation, and make
xenbus add ActiveLocationInformation and ActiveInstanceID, if missing,
for the active device.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenbus/driver.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/xenbus/driver.h |  7 +++++
 src/xenbus/fdo.c    |  4 +++
 src/xenfilt/pdo.c   | 15 +++++-----
 4 files changed, 102 insertions(+), 8 deletions(-)

diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index c49a7de..a1c7b56 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -532,6 +532,90 @@ fail1:
     return status;
 }
 
+NTSTATUS
+DriverUpdateActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    )
+{
+    HANDLE      ActiveKey;
+    ANSI_STRING Ansi[2];
+    PCHAR       ActiveInstanceID;
+    PCHAR       ActiveLocationInformation;
+    NTSTATUS    status;
+
+    Trace("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryOpenSubKey(NULL,
+                                ACTIVE_PATH,
+                                KEY_ALL_ACCESS,
+                                &ActiveKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (__DriverIsDeviceLegacy(DeviceID) &&
+        __DriverIsVendorDevicePresent())
+        goto fail2;
+
+    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
+
+    status = DriverGetActive("InstanceID", &ActiveInstanceID);
+    if (NT_SUCCESS(status)) {
+        ExFreePool(ActiveInstanceID);
+    } else {
+        RtlInitAnsiString(&Ansi[0], InstanceID);
+
+        status = RegistryUpdateSzValue(ActiveKey,
+                                       "ActiveInstanceID",
+                                       REG_SZ,
+                                       Ansi);
+        if (!NT_SUCCESS(status))
+            goto fail3;
+    }
+
+    status = DriverGetActive("LocationInformation", 
&ActiveLocationInformation);
+    if (NT_SUCCESS(status)) {
+        ExFreePool(ActiveLocationInformation);
+    } else {
+        RtlInitAnsiString(&Ansi[0], LocationInformation);
+
+        status = RegistryUpdateSzValue(ActiveKey,
+                                       "ActiveLocationInformation",
+                                       REG_SZ,
+                                       Ansi);
+        if (!NT_SUCCESS(status))
+            goto fail4;
+    }
+
+    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
+
+    RegistryCloseKey(ActiveKey);
+
+    Trace("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail4:
+    Error("fail4\n");
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    RegistryCloseKey(ActiveKey);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
 NTSTATUS
 DriverClearActive(
     VOID
diff --git a/src/xenbus/driver.h b/src/xenbus/driver.h
index 3875b42..55ec97b 100644
--- a/src/xenbus/driver.h
+++ b/src/xenbus/driver.h
@@ -77,6 +77,13 @@ DriverSetActive(
     IN  PCHAR   LocationInformation
     );
 
+NTSTATUS
+DriverUpdateActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    );
+
 NTSTATUS
 DriverClearActive(
     VOID
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 60201fc..7047f6a 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -745,6 +745,10 @@ FdoSetActive(
     status = DriverGetActive("DeviceID", &ActiveDeviceID);
     if (NT_SUCCESS(status)) {
         Fdo->Active = (_stricmp(DeviceID, ActiveDeviceID) == 0) ? TRUE : FALSE;
+
+        if (Fdo->Active)
+            (VOID) DriverUpdateActive(DeviceID, InstanceID, 
LocationInformation);
+
         ExFreePool(ActiveDeviceID);
     } else {
         status = DriverSetActive(DeviceID, InstanceID, LocationInformation);
diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
index 9fba36c..37b4a45 100644
--- a/src/xenfilt/pdo.c
+++ b/src/xenfilt/pdo.c
@@ -289,8 +289,13 @@ PdoSetDeviceInformation(
 
         status = DriverGetActive("LocationInformation",
                                  &LocationInformation);
-        if (!NT_SUCCESS(status))
-            goto fail3;
+        if (!NT_SUCCESS(status)) {
+            status = DriverQueryDeviceText(Pdo->LowerDeviceObject,
+                                           DeviceTextLocationInformation,
+                                           &LocationInformation);
+            if (!NT_SUCCESS(status))
+                LocationInformation = NULL;
+        }
     } else {
         status = DriverQueryId(Pdo->LowerDeviceObject,
                                BusQueryInstanceID,
@@ -311,12 +316,6 @@ PdoSetDeviceInformation(
 
     return STATUS_SUCCESS;
 
-fail3:
-    Error("fail3\n");
-
-    ASSERT(Pdo->Active);
-    ExFreePool(InstanceID);
-
 fail2:
     Error("fail2\n");
 
-- 
2.16.2.windows.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

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