]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Add the 'NeedReboot' flag back in
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 24 Mar 2015 12:18:59 +0000 (12:18 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 24 Mar 2015 12:33:25 +0000 (12:33 +0000)
Older versions of the code used to set a 'NeedReboot' registry value if
the PDO failed to start because the corresponding emulated device was
found to be still present. The value was set directly in the service key
which is non-volatile and thus the value would persist after reboot.

This patch adds code to again set a 'NeedReboot' value, but this time it
is in a volatile 'Status' key under the service key so that it does not
persist. This value can then be used by the XENNET co-installer to
determine whether it should request a reboot during postinstall
processing.

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

index 8cf843f8c83579262cb1d1fd1acec4276ee995f0..b9e6d2fb2caccdc5ba053eeaf3ae1075811fa9fd 100644 (file)
@@ -48,6 +48,7 @@ typedef struct _XENVIF_DRIVER {
     PDRIVER_OBJECT      DriverObject;
     HANDLE              ParametersKey;
     HANDLE              AddressesKey;
+    HANDLE              StatusKey;
 } XENVIF_DRIVER, *PXENVIF_DRIVER;
 
 static XENVIF_DRIVER    Driver;
@@ -124,6 +125,30 @@ DriverGetAddressesKey(
     return __DriverGetAddressesKey();
 }
 
+static FORCEINLINE VOID
+__DriverSetStatusKey(
+    IN  HANDLE  Key
+    )
+{
+    Driver.StatusKey = Key;
+}
+
+static FORCEINLINE HANDLE
+__DriverGetStatusKey(
+    VOID
+    )
+{
+    return Driver.StatusKey;
+}
+
+HANDLE
+DriverGetStatusKey(
+    VOID
+    )
+{
+    return __DriverGetStatusKey();
+}
+
 DRIVER_UNLOAD       DriverUnload;
 
 VOID
@@ -133,6 +158,7 @@ DriverUnload(
 {
     HANDLE              AddressesKey;
     HANDLE              ParametersKey;
+    HANDLE              StatusKey;
 
     ASSERT3P(DriverObject, ==, __DriverGetDriverObject());
 
@@ -141,7 +167,12 @@ DriverUnload(
     if (*InitSafeBootMode > 0)
         goto done;
 
-    AddressesKey = __DriverGetParametersKey();
+    StatusKey = __DriverGetStatusKey();
+    __DriverSetStatusKey(NULL);
+
+    RegistryCloseKey(StatusKey);
+
+    AddressesKey = __DriverGetAddressesKey();
     __DriverSetAddressesKey(NULL);
 
     RegistryCloseKey(AddressesKey);
@@ -254,6 +285,7 @@ DriverEntry(
     HANDLE              ServiceKey;
     HANDLE              ParametersKey;
     HANDLE              AddressesKey;
+    HANDLE              StatusKey;
     ULONG               Index;
     NTSTATUS            status;
 
@@ -308,6 +340,15 @@ DriverEntry(
 
     __DriverSetAddressesKey(AddressesKey);
 
+    status = RegistryCreateSubKey(ServiceKey,
+                                  "Status",
+                                  REG_OPTION_VOLATILE,
+                                  &StatusKey);
+    if (!NT_SUCCESS(status))
+        goto fail5;
+
+    __DriverSetStatusKey(StatusKey);
+
     RegistryCloseKey(ServiceKey);
 
     DriverObject->DriverExtension->AddDevice = AddDevice;
@@ -323,6 +364,13 @@ done:
 
     return STATUS_SUCCESS;
 
+fail5:
+    Error("fail5\n");
+
+    __DriverSetAddressesKey(NULL);
+
+    RegistryCloseKey(AddressesKey);
+
 fail4:
     Error("fail4\n");
 
index cdef7d1ae07f993e5b41bf2aad946a7217484b7f..17ed726ef980a644d6e80b6fc3cfe66fe2963d43 100644 (file)
@@ -48,7 +48,7 @@ DriverGetAddressesKey(
     );
 
 extern HANDLE
-DriverGetAliasesKey(
+DriverGetStatusKey(
     VOID
     );
 
index 369efb0664c1623ab1bd7aad6a8affb5e9ef1353..9352594125023eb342d9865c9e5c1eb00fd59de8 100644 (file)
@@ -1207,6 +1207,26 @@ PdoS3ToS4(
     Trace("(%s) <====\n", __PdoGetName(Pdo));
 }
 
+static VOID
+PdoRequestReboot(
+    IN  PXENVIF_PDO     Pdo
+    )
+{
+    HANDLE              StatusKey;
+
+    UNREFERENCED_PARAMETER(Pdo);
+
+    Info("<===>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    StatusKey = DriverGetStatusKey();
+
+    (VOID) RegistryUpdateDwordValue(StatusKey,
+                                    "NeedReboot",
+                                    1);
+}
+
 static DECLSPEC_NOINLINE NTSTATUS
 PdoStartDevice(
     IN  PXENVIF_PDO     Pdo,
@@ -1292,9 +1312,12 @@ fail6:
 fail5:
     Error("fail5\n");
 
+    goto fail3;
+
 fail4:
     Error("fail4\n");
 
+    PdoRequestReboot(Pdo);
     __FreeMibTable(Table);
 
 fail3: