]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Skip stale device config...
authorOwen Smith <owen.smith@citrix.com>
Tue, 7 Feb 2023 08:11:45 +0000 (08:11 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Tue, 14 Feb 2023 17:55:11 +0000 (17:55 +0000)
...when checking child compatibility

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.

This is similar to the XenBus commit 16c8ad0c446eded7246cc5f3d72de0bc3ff7baf5
which handles the same failure for XenBus's child devices

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/coinst/coinst.c

index 489e600231b367f0edabe7f57808cbd6357108fe..403eac8e4b020f0f0349c5ba0d176373b694a6b9 100644 (file)
@@ -502,7 +502,8 @@ fail1:
 static BOOLEAN
 GetDriverKeyName(
     IN  HKEY    DeviceKey,
-    OUT PTCHAR  *Name
+    OUT PTCHAR  *Name,
+    OUT DWORD   *ConfigFlags
     )
 {
     HRESULT     Error;
@@ -513,6 +514,7 @@ GetDriverKeyName(
     DWORD       Index;
     HKEY        SubKey;
     PTCHAR      DriverKeyName;
+    DWORD       Flags;
 
     Error = RegQueryInfoKey(DeviceKey,
                             NULL,
@@ -539,9 +541,11 @@ GetDriverKeyName(
 
     SubKey = NULL;
     DriverKeyName = NULL;
+    Flags = 0;
 
     for (Index = 0; Index < SubKeys; Index++) {
         DWORD       MaxValueLength;
+        DWORD       ConfigFlagsLength;
         DWORD       DriverKeyNameLength;
         DWORD       Type;
 
@@ -588,6 +592,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);
@@ -606,6 +622,7 @@ GetDriverKeyName(
 
         free(DriverKeyName);
         DriverKeyName = NULL;
+        Flags = 0;
 
         RegCloseKey(SubKey);
         SubKey = NULL;
@@ -619,6 +636,8 @@ GetDriverKeyName(
     free(SubKeyName);
 
     *Name = DriverKeyName;
+    *ConfigFlags = Flags;
+
     return TRUE;
 
 fail5:
@@ -889,6 +908,7 @@ SupportChildDrivers(
     PTCHAR      SubKeyName;
     HKEY        DeviceKey;
     PTCHAR      DriverKeyName;
+    DWORD       ConfigFlags;
     HKEY        DriverKey;
     PTCHAR      MatchingDeviceID;
     DWORD       Index;
@@ -948,20 +968,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);
         if (!Success)
@@ -969,9 +992,11 @@ SupportChildDrivers(
 
         free(MatchingDeviceID);
 
-    loop3:
+    loop4:
         RegCloseKey(DriverKey);
 
+    loop3:
+
     loop2:
         free(DriverKeyName);