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

Re: [PATCH 2/6] Reset StorNvme's StartOverride


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Paul Durrant <xadimgnik@xxxxxxxxx>
  • Date: Tue, 12 Sep 2023 09:17:39 +0200
  • Delivery-date: Tue, 12 Sep 2023 07:17:50 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 31/08/2023 08:29, Owen Smith wrote:
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(+)


This seems like a straight fix for an existing problem so I could take it now?

Reviewed-by: Paul Durrant <paul@xxxxxxx>

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("<====");




 


Rackspace

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