]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Reset StorNvme's StartOverride
authorOwen Smith <owen.smith@cloud.com>
Wed, 13 Sep 2023 13:45:13 +0000 (14:45 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Thu, 28 Sep 2023 12:45:45 +0000 (13:45 +0100)
When StorNvme does not enumerate any devices during boot start, it sets
the StartOverride value, which means that StorNvme does not start during
the next boot.
This can be an issue when attempting to revert to emulated boot, such as
during a driver upgrade, as StorNvme will not be loaded and not take control
of the boot disk, leading to a 0x7B bugcheck.

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

index bb872ceb0ee6ea5d11c50629f683c3b870e87510..185838f4ec3c61dd2a7a9bddd25c3b6f495f5b13 100644 (file)
@@ -1173,6 +1173,66 @@ fail1:
     return FALSE;
 }
 
+static BOOL
+RemoveStartOverride(
+    IN PTCHAR           DriverName
+    )
+{
+    TCHAR               KeyName[MAX_PATH];
+    HKEY                Key;
+    DWORD               Value;
+    HRESULT             Error;
+
+    Error = StringCbPrintf(KeyName,
+                           MAX_PATH,
+                           SERVICES_KEY "\\%s\\StartOverride",
+                           DriverName);
+    assert(SUCCEEDED(Error));
+
+    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                         KeyName,
+                         0,
+                         KEY_READ | KEY_WRITE,
+                         &Key);
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail1;
+    }
+
+    Value = 0;
+    Error = RegSetValueEx(Key,
+                          "0",
+                          0,
+                          REG_DWORD,
+                          (const BYTE*)&Value,
+                          (DWORD) sizeof(Value));
+    if (Error != ERROR_SUCCESS) {
+        SetLastError(Error);
+        goto fail2;
+    }
+
+    RegCloseKey(Key);
+
+    return TRUE;
+
+fail2:
+    Log("fail2");
+
+    RegCloseKey(Key);
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTCHAR  Message;
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    return FALSE;
+}
+
 VOID WINAPI
 MonitorMain(
     _In_    DWORD       argc,
@@ -1189,6 +1249,8 @@ MonitorMain(
 
     Log("====>");
 
+    (VOID) RemoveStartOverride("stornvme");
+
     Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                          PARAMETERS_KEY(__MODULE__),
                          0,
@@ -1301,6 +1363,7 @@ done:
     (VOID) DeregisterEventSource(Context->EventLog);
 
     CloseHandle(Context->ParametersKey);
+    (VOID) RemoveStartOverride("stornvme");
 
     Log("<====");