]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Remove reboot request from the co-installer...
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 22 Jul 2016 09:37:12 +0000 (10:37 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Fri, 22 Jul 2016 09:37:12 +0000 (10:37 +0100)
...and use the XENBUS_MONITOR service instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/coinst/coinst.c
src/xenvbd/driver.c
src/xenvbd/driver.h
src/xenvbd/fdo.c

index 1bdcbc60b93ff318cda5584426e4b49d4a59f2ce..f9728220d955d55bea8c2fd718eff605fc94c804 100644 (file)
@@ -570,124 +570,6 @@ fail1:
     return FALSE;
 }
 
-static BOOLEAN
-CheckStatus(
-    OUT PBOOLEAN    NeedReboot
-    )
-{
-    HKEY            StatusKey;
-    HRESULT         Error;
-    DWORD           ValueLength;
-    DWORD           Value;
-    DWORD           Type;
-
-    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
-                         STATUS_KEY,
-                         0,
-                         KEY_READ,
-                         &StatusKey);
-    if (Error != ERROR_SUCCESS) {
-        SetLastError(Error);
-        goto fail1;
-    }
-
-    ValueLength = sizeof (Value);
-
-    Error = RegQueryValueEx(StatusKey,
-                            "NeedReboot",
-                            NULL,
-                            &Type,
-                            (LPBYTE)&Value,
-                            &ValueLength);
-    if (Error != ERROR_SUCCESS) {
-        if (Error == ERROR_FILE_NOT_FOUND) {
-            Type = REG_DWORD;
-            Value = 0;
-        } else {
-            SetLastError(Error);
-            goto fail2;
-        }
-    }
-
-    if (Type != REG_DWORD) {
-        SetLastError(ERROR_BAD_FORMAT);
-        goto fail3;
-    }
-
-    *NeedReboot = (Value != 0) ? TRUE : FALSE;
-
-    if (*NeedReboot)
-        Log("NeedReboot");
-
-    RegCloseKey(StatusKey);
-
-    return TRUE;
-
-fail3:
-    Log("fail3");
-
-fail2:
-    Log("fail2");
-
-    RegCloseKey(StatusKey);
-
-fail1:
-    Error = GetLastError();
-
-    {
-        PTCHAR  Message;
-        Message = __GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
-        LocalFree(Message);
-    }
-
-    return FALSE;
-}
-
-static BOOLEAN
-RequestReboot(
-    IN  HDEVINFO            DeviceInfoSet,
-    IN  PSP_DEVINFO_DATA    DeviceInfoData
-    )
-{
-    SP_DEVINSTALL_PARAMS    DeviceInstallParams;
-    HRESULT                 Error;
-
-    DeviceInstallParams.cbSize = sizeof (DeviceInstallParams);
-
-    if (!SetupDiGetDeviceInstallParams(DeviceInfoSet,
-                                       DeviceInfoData,
-                                       &DeviceInstallParams))
-        goto fail1;
-
-    DeviceInstallParams.Flags |= DI_NEEDREBOOT;
-
-    Log("Flags = %08x", DeviceInstallParams.Flags);
-
-    if (!SetupDiSetDeviceInstallParams(DeviceInfoSet,
-                                       DeviceInfoData,
-                                       &DeviceInstallParams))
-        goto fail2;
-
-    return TRUE;
-
-fail2:
-    Log("fail2");
-
-fail1:
-    Error = GetLastError();
-
-    {
-        PTCHAR  Message;
-
-        Message = __GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
-        LocalFree(Message);
-    }
-
-    return FALSE;
-}
-
 static FORCEINLINE HRESULT
 __DifInstallPreProcess(
     IN  HDEVINFO                    DeviceInfoSet,
@@ -742,9 +624,8 @@ __DifInstallPostProcess(
     IN  PCOINSTALLER_CONTEXT_DATA   Context
     )
 {
-    BOOLEAN                         Success;
-    BOOLEAN                         NeedReboot;
-
+    UNREFERENCED_PARAMETER(DeviceInfoSet);
+    UNREFERENCED_PARAMETER(DeviceInfoData);
     UNREFERENCED_PARAMETER(Context);
 
     Log("====>");
@@ -753,12 +634,6 @@ __DifInstallPostProcess(
     (VOID) OverrideSanPolicy();
     (VOID) IncreaseDiskTimeOut();
 
-    NeedReboot = FALSE;
-
-    Success = CheckStatus(&NeedReboot);
-    if (Success && NeedReboot)
-        (VOID) RequestReboot(DeviceInfoSet, DeviceInfoData);
-
     Log("<====");
 
     return NO_ERROR;
index 6e7b6358d48ba46bf2670ff395aa1aeaebb13fd8..33de481f35e05e7983b37a2050fe8b8a68871011 100644 (file)
@@ -279,49 +279,74 @@ __DriverGetFdo(
     return IsFdo;
 }
 
+#define SERVICES_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services"
+
+#define SERVICE_KEY(_Name) \
+        SERVICES_PATH ## "\\" ## #_Name
+
+#define REQUEST_KEY \
+        SERVICE_KEY(XENBUS_MONITOR) ## "\\Request"
+
 VOID
-DriverNotifyInstaller(
+DriverRequestReboot(
     VOID
     )
 {
-    UNICODE_STRING                  Unicode;
-    PKEY_VALUE_PARTIAL_INFORMATION  Partial;
+    ANSI_STRING                     Ansi;
+    UNICODE_STRING                  KeyName;
+    UNICODE_STRING                  ValueName;
+    WCHAR                           Value[] = L"XENVBD";
+    OBJECT_ATTRIBUTES               Attributes;
+    HANDLE                          Key;
     NTSTATUS                        status;
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
-    Partial = __AllocateNonPagedPoolWithTag(__FUNCTION__,
-                                            __LINE__,
-                                            FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data) +
-                                            sizeof (ULONG),
-                                            XENVBD_POOL_TAG);
-    status = STATUS_NO_MEMORY;
-    if (Partial == NULL)
-        goto fail1;
+    RtlInitAnsiString(&Ansi, REQUEST_KEY);
 
-    Partial->TitleIndex = 0;
-    Partial->Type = REG_DWORD;
-    Partial->DataLength = sizeof (ULONG);
-    *(PULONG)Partial->Data = 1;
+    status = RtlAnsiStringToUnicodeString(&KeyName, &Ansi, TRUE);
+    if (!NT_SUCCESS(status))
+        goto fail1;
 
-    RtlInitUnicodeString(&Unicode, L"NeedReboot");
+    InitializeObjectAttributes(&Attributes,
+                               &KeyName,
+                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+                               NULL,
+                               NULL);
 
-    status = ZwSetValueKey(Driver.StatusKey,
-                           &Unicode,
-                           Partial->TitleIndex,
-                           Partial->Type,
-                           Partial->Data,
-                           Partial->DataLength);
+    status = ZwOpenKey(&Key,
+                       KEY_ALL_ACCESS,
+                       &Attributes);
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    __FreePoolWithTag(Partial, XENVBD_POOL_TAG);
+    RtlInitUnicodeString(&ValueName, L"Reboot");
+
+    status = ZwSetValueKey(Key,
+                           &ValueName,
+                           0,
+                           REG_SZ,
+                           Value,
+                           sizeof(Value));
+    if (!NT_SUCCESS(status))
+        goto fail3;
+
+    ZwClose(Key);
+
+    RtlFreeUnicodeString(&KeyName);
 
     return;
 
+fail3:
+    Error("fail3\n");
+
+    ZwClose(Key);
+
 fail2:
     Error("fail2\n");
 
+    RtlFreeUnicodeString(&KeyName);
+
 fail1:
     Error("fail1 (%08x)\n", status);
 }
index 79260cd898926df9757b0c3c829dd2b15102df1d..cf55330f2db7d5861593c315196a2fd7e3b2df53 100644 (file)
@@ -81,7 +81,7 @@ DriverUnlinkFdo(
     );
 
 extern VOID
-DriverNotifyInstaller(
+DriverRequestReboot(
     VOID
     );
 
index 5f1778bcfeddc7b2db2e555bf46d56306b7e004d..deac224964e336f6621d39548423251e5bb60fe4 100644 (file)
@@ -830,7 +830,7 @@ FdoScanTargets(
         StorPortNotification(BusChangeDetected, Fdo, 0);
     }
     if (NeedReboot) {
-        DriverNotifyInstaller();
+        DriverRequestReboot();
     }
 }