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

[PATCH 2/6] Reset StorNvme's StartOverride



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@xxxxxxxxx>
---
 src/monitor/monitor.c | 63 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index bb872ce..185838f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -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("<====");
 
-- 
2.41.0.windows.3




 


Rackspace

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