]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Move reboot request code into driver.c
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 8 Jul 2015 10:16:13 +0000 (11:16 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 8 Jul 2015 12:20:47 +0000 (13:20 +0100)
It doesn't really belong in pdo.c

Also this patch adds a check in PdoStartDevice() to fail if a reboot has
already been requested. This is because Windows 10 apparently has a couple
of goes at starting the PDO even after it failed to start the first time
(because we requested a reboot).

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

index 46fe7f13c2eca9255a6a65c665ddb2d824ca6f68..95a56e3eb335e544120df65cff9ec1d5695ade27 100644 (file)
@@ -48,6 +48,7 @@ typedef struct _XENVIF_DRIVER {
     PDRIVER_OBJECT      DriverObject;
     HANDLE              ParametersKey;
     HANDLE              StatusKey;
+    BOOLEAN             NeedReboot;
 } XENVIF_DRIVER, *PXENVIF_DRIVER;
 
 static XENVIF_DRIVER    Driver;
@@ -116,12 +117,27 @@ __DriverGetStatusKey(
     return Driver.StatusKey;
 }
 
-HANDLE
-DriverGetStatusKey(
+VOID
+DriverRequestReboot(
+    VOID
+    )
+{
+    Info("<===>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    (VOID) RegistryUpdateDwordValue(__DriverGetStatusKey(),
+                                    "NeedReboot",
+                                    1);
+    Driver.NeedReboot = TRUE;
+}
+
+BOOLEAN
+DriverIsRebootRequested(
     VOID
     )
 {
-    return __DriverGetStatusKey();
+    return Driver.NeedReboot;
 }
 
 DRIVER_UNLOAD       DriverUnload;
index cecefd0db9c6339e3f34d983ca48e6a0c3dd583b..53b85af9f7fe45dda7e8840f28e47af9a7f15c61 100644 (file)
@@ -42,8 +42,13 @@ DriverGetParametersKey(
     VOID
     );
 
-extern HANDLE
-DriverGetStatusKey(
+extern VOID
+DriverRequestReboot(
+    VOID
+    );
+
+BOOLEAN
+DriverIsRebootRequested(
     VOID
     );
 
index 0cf83b9706cf4e6a11d1992a75802c9a2c2946f0..9e3003e32f8799edc8ac1af07e19d9494f0ae71a 100644 (file)
@@ -1113,26 +1113,6 @@ 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,
@@ -1147,35 +1127,39 @@ PdoStartDevice(
     HANDLE              Key;
     NTSTATUS            status;
 
+    status = STATUS_UNSUCCESSFUL;
+    if (DriverIsRebootRequested())
+        goto fail1;
+
     status = RegistryOpenSoftwareKey(__PdoGetDeviceObject(Pdo),
                                      KEY_ALL_ACCESS,
                                      &Key);
     if (!NT_SUCCESS(status))
-        goto fail1;
+        goto fail2;
 
     status = __PdoSetCurrentAddress(Pdo, Key);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;
 
     status = __PdoSetLuid(Pdo, Key);
     if (!NT_SUCCESS(status))
-        goto fail3;
+        goto fail4;
 
     status = LinkGetRoutineAddress("netio.sys",
                                    "GetIfTable2",
                                    (PVOID *)&__GetIfTable2);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;
 
     status = LinkGetRoutineAddress("netio.sys",
                                    "FreeMibTable",
                                    (PVOID *)&__FreeMibTable);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     status = __GetIfTable2(&Table);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;
 
     for (Index = 0; Index < Table->NumEntries; Index++) {
         PMIB_IF_ROW2    Row = &Table->Table[Index];
@@ -1194,14 +1178,14 @@ PdoStartDevice(
         if (memcmp(Row->PhysicalAddress,
                    &Pdo->PermanentAddress,
                    sizeof (ETHERNET_ADDRESS)) == 0)
-            goto fail7;
+            goto fail8;
     }
 
     StackLocation = IoGetCurrentIrpStackLocation(Irp);
 
     status = PdoD3ToD0(Pdo);
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail9;
 
     __PdoSetDevicePnpState(Pdo, Started);
 
@@ -1214,39 +1198,42 @@ PdoStartDevice(
 
     return STATUS_SUCCESS;
 
+fail9:
+    Error("fail9\n");
+
+    __FreeMibTable(Table);
+    goto fail6;
+
 fail8:
     Error("fail8\n");
 
+    DriverRequestReboot();
     __FreeMibTable(Table);
-    goto fail6;
 
 fail7:
     Error("fail7\n");
 
-    PdoRequestReboot(Pdo);
-    __FreeMibTable(Table);
-
 fail6:
     Error("fail6\n");
 
 fail5:
     Error("fail5\n");
 
+    RtlZeroMemory(&Pdo->Luid, sizeof (NET_LUID));
+
 fail4:
     Error("fail4\n");
 
-    RtlZeroMemory(&Pdo->Luid, sizeof (NET_LUID));
+    RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
 
 fail3:
     Error("fail3\n");
 
-    RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+    RegistryCloseKey(Key);
 
 fail2:
     Error("fail2\n");
 
-    RegistryCloseKey(Key);
-
 fail1:
     Error("fail1 (%08x)\n", status);