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

[PATCH 2/6] Skip stale device config when checking child compatibility


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Thu, 17 Jun 2021 13:33:52 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Thu, 17 Jun 2021 12:34:10 +0000
  • Ironport-hdrordr: A9a23:NFc+FKzLibT0Tj470jdwKrPw2L1zdoMgy1knxilNoENuH/Bwxv rFoB1E73TJYVYqN03Iz+rwRpVoJkmsiaKdgLNhQItKOTOLhILGFvAB0WKP+UyEJ8S6zJ8l6U 4CSdkFNDSTNykdsS+g2njILz9I+rDukNHKuQ6d9QYUcegNUdAF0+4TMHfhLqQZfnggOXI2fK Dsmfav8ADQCUg/X4CBNVdAd9T/hrTw+q7OUFo8NDBiwiyntwntyJOSKXml4is=
  • Ironport-sdr: 23kccZJEjkDhGeCkq685sUzDhg/cRGga7K+cuZIC7hZBb8LsEsB++V1lFWTtRkTo6dQ+YQsh37 hcx85xHf2va8l+pvh9mB2Opo/RYe37WfkH+abnq9ghb8ohvcN6j7wcZbxtiEZPpB/zz2f9igZO i4w7V6EWp9yecI5OinMTccSkbmE3a0SrbJAsk6TqPWdzzpj+K805dAn/b1lSJX7UI1zCC4ZZQq n/1yxgeBNRFDOH2siBsQuTPRrTCZBv8deK7NUkAJfbUfgUNxtfiWwiCJ/IR1Uc2xnmD9beSiyE tFs=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

When a device is updated, the Enum key for the old binding is not deleted.
This can lead to a device binding that is not in use (has been replaced by
a later binding) triggering the coinstaller to fail the upgrade to a newer
version. This is especially prevelent when the older stale information was
bound to a revision that is not present in the new driver INF file.

This fix ignores the stale entries under the Enum key when performing the
compatibility checks.

e.g.
tag 8.2.1 has 0x08000009 to 0x08000009 for its bindings
tag 9.0.0 has 0x08000009 to 0x09000007 for its bindings
commit a9631142d0be removed v8 revisions, leaving only 0x0900000x revisions
It should be possible to upgrade from tag 8.2.1 to tag 9.0.0 and then to
commits after a9631142d0be. At each stage of this upgrade, the revisions
overlap, even if the initial and end revisions do not have an overlap.
It is not possible to upgrade directly from tag 8.2.1 to commit a9631142d0be,
as there is no common revision that can be used.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/coinst/coinst.c | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index c29ce59..8dc290c 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -575,7 +575,8 @@ fail1:
 static BOOLEAN
 GetDriverKeyName(
     IN  HKEY    DeviceKey,
-    OUT PTCHAR  *Name
+    OUT PTCHAR  *Name,
+    OUT DWORD   *ConfigFlags
     )
 {
     HRESULT     Error;
@@ -586,6 +587,7 @@ GetDriverKeyName(
     DWORD       Index;
     HKEY        SubKey;
     PTCHAR      DriverKeyName;
+    DWORD       Flags;
 
     Error = RegQueryInfoKey(DeviceKey,
                             NULL,
@@ -612,9 +614,11 @@ GetDriverKeyName(
 
     SubKey = NULL;
     DriverKeyName = NULL;
+    Flags = 0;
 
     for (Index = 0; Index < SubKeys; Index++) {
         DWORD       MaxValueLength;
+        DWORD       ConfigFlagsLength;
         DWORD       DriverKeyNameLength;
         DWORD       Type;
 
@@ -661,6 +665,18 @@ GetDriverKeyName(
             goto fail4;
         }
 
+        ConfigFlagsLength = (DWORD)sizeof(DWORD);
+
+        Error = RegQueryValueEx(SubKey,
+                                "ConfigFlags",
+                                NULL,
+                                &Type,
+                                (LPBYTE)&Flags,
+                                &ConfigFlagsLength);
+        if (Error != ERROR_SUCCESS ||
+            Type != REG_DWORD)
+            Flags = 0;
+
         DriverKeyNameLength = MaxValueLength + sizeof (TCHAR);
 
         DriverKeyName = calloc(1, DriverKeyNameLength);
@@ -679,6 +695,7 @@ GetDriverKeyName(
 
         free(DriverKeyName);
         DriverKeyName = NULL;
+        Flags = 0;
 
         RegCloseKey(SubKey);
         SubKey = NULL;
@@ -692,6 +709,8 @@ GetDriverKeyName(
     free(SubKeyName);
 
     *Name = DriverKeyName;
+    if (ConfigFlags)
+        *ConfigFlags = Flags;
     return TRUE;
 
 fail5:
@@ -851,7 +870,7 @@ found:
         goto fail3;
 
     // Check for a bound driver
-    Success = GetDriverKeyName(DeviceKey, &DriverKeyName);
+    Success = GetDriverKeyName(DeviceKey, &DriverKeyName, NULL);
     if (!Success)
         goto fail4;
 
@@ -1452,6 +1471,7 @@ SupportChildDrivers(
     PTCHAR          SubKeyName;
     HKEY            DeviceKey;
     PTCHAR          DriverKeyName;
+    DWORD           ConfigFlags;
     HKEY            DriverKey;
     PTCHAR          MatchingDeviceID;
     DWORD           Index;
@@ -1511,20 +1531,23 @@ SupportChildDrivers(
         if (!Success)
             goto fail5;
 
-        Success = GetDriverKeyName(DeviceKey, &DriverKeyName);
+        Success = GetDriverKeyName(DeviceKey, &DriverKeyName, &ConfigFlags);
         if (!Success)
             goto fail6;
 
         if (DriverKeyName == NULL)
             goto loop1;
 
+        if (ConfigFlags & 0x20)
+            goto loop2;
+
         Success = OpenDriverKey(DriverKeyName, &DriverKey);
         if (!Success)
-            goto loop2;
+            goto loop3;
 
         Success = GetMatchingDeviceID(DriverKey, &MatchingDeviceID);
         if (!Success)
-            goto loop3;
+            goto loop4;
 
         Success = SupportDeviceID(MatchingDeviceID, NewBinding);
         if (!Success)
@@ -1532,9 +1555,11 @@ SupportChildDrivers(
 
         free(MatchingDeviceID);
 
-    loop3:
+    loop4:
         RegCloseKey(DriverKey);
 
+    loop3:
+
     loop2:
         free(DriverKeyName);
 
-- 
2.31.1.windows.1




 


Rackspace

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