|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 3/3] Remove StartOverride from all storage adapters
Its possible to install non-Microsoft NVMe drivers on the emulated
NVMe device. During upgrades, the VM requires a reboot using the emulated
devices, but if the driver assigned for the emulated device has a StartOverride
setting, then its likely not started which results in a 0x7B bugcheck.
Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
src/monitor/monitor.c | 67 +++++++++++++++++---
vs2019/xenbus_monitor/xenbus_monitor.vcxproj | 2 +-
vs2022/xenbus_monitor/xenbus_monitor.vcxproj | 2 +-
3 files changed, 59 insertions(+), 12 deletions(-)
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 700f196..eb1be91 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -42,6 +42,8 @@
#include <assert.h>
#include <TraceLoggingProvider.h>
#include <winmeta.h>
+#include <setupapi.h>
+#include <devguid.h>
#include <version.h>
@@ -1328,7 +1330,7 @@ fail1:
return FALSE;
}
-static BOOL
+static VOID
RemoveStartOverride(
_In_ PTSTR DriverName
)
@@ -1336,17 +1338,61 @@ RemoveStartOverride(
TCHAR KeyName[MAX_PATH];
HRESULT Error;
+ LogInfo("%s", DriverName);
+
Error = StringCbPrintf(KeyName,
MAX_PATH,
SERVICES_KEY "\\%s\\StartOverride",
DriverName);
assert(SUCCEEDED(Error));
- Error = RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
- if (Error != ERROR_SUCCESS)
+ (VOID) RegDeleteKey(HKEY_LOCAL_MACHINE, KeyName);
+}
+
+static VOID
+RemoveStartOverrideForClass(
+ _In_ const GUID* Guid
+ )
+{
+ HRESULT Error;
+ HDEVINFO hDevInfo;
+ DWORD Index;
+ SP_DEVINFO_DATA devInfoData;
+
+ hDevInfo = SetupDiGetClassDevs(Guid,
+ NULL,
+ NULL,
+ 0);
+ if (hDevInfo == INVALID_HANDLE_VALUE)
goto fail1;
- return TRUE;
+ memset(&devInfoData, 0, sizeof(devInfoData));
+ devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+
+ for (Index = 0;
+ SetupDiEnumDeviceInfo(hDevInfo, Index, &devInfoData);
+ ++Index) {
+ TCHAR Buffer[MAX_PATH];
+ memset(Buffer, 0, sizeof(Buffer));
+
+ if (SetupDiGetDeviceRegistryProperty(hDevInfo,
+ &devInfoData,
+ SPDRP_SERVICE,
+ NULL,
+ (PBYTE)Buffer,
+ sizeof(Buffer),
+ NULL)) {
+ Buffer[MAX_PATH - 1] = _T('\0');
+ RemoveStartOverride(Buffer);
+ }
+
+ memset(&devInfoData, 0, sizeof(devInfoData));
+ devInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
+ }
+
+ SetupDiDestroyDeviceInfoList(hDevInfo);
+
+ return;
fail1:
Error = GetLastError();
@@ -1357,8 +1403,6 @@ fail1:
LogError("fail1 (%s)", Message);
LocalFree(Message);
}
-
- return FALSE;
}
VOID WINAPI
@@ -1381,7 +1425,8 @@ MonitorMain(
LogInfo("====>");
- (VOID) RemoveStartOverride("stornvme");
+ RemoveStartOverride("stornvme");
+ RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
PARAMETERS_KEY(__MODULE__),
@@ -1525,10 +1570,12 @@ done:
CloseHandle(Context->RequestEvent);
CloseHandle(Context->StopEvent);
- ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
-
RegCloseKey(Context->ParametersKey);
- (VOID) RemoveStartOverride("stornvme");
+
+ RemoveStartOverride("stornvme");
+ RemoveStartOverrideForClass(&GUID_DEVCLASS_SCSIADAPTER);
+
+ ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
LogInfo("<====");
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index 3b44e29..df1fd58 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
<RuntimeLibrary
Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
-
<AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+
<AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<CETCompat>true</CETCompat>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 484fa1c..196a744 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -34,7 +34,7 @@
<RuntimeLibrary
Condition="'$(UseDebugLibraries)'=='false'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
-
<AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+
<AdditionalDependencies>powrprof.lib;wtsapi32.lib;cfgmgr32.lib;setupapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<CETCompat>true</CETCompat>
<GenerateMapFile>true</GenerateMapFile>
<MapExports>true</MapExports>
--
2.51.2.windows.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |