]> xenbits.xensource.com Git - people/pauldu/xenvif.git/commitdiff
Prevent VIF from being incorrectly considered offline...
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 23 Mar 2016 11:50:35 +0000 (11:50 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 23 Mar 2016 14:40:57 +0000 (14:40 +0000)
...one resume from suspend.

My previous reversion of 765b7a6a exposed the original reason the
reverted patch.

On resume from suspend, the backend will have been re-created by the
toolstack and hence the frontend detects it as being offline. This
causes the frontend to request ejection of the disk (thinking that
the reason for the backend going offline is because the VIF is being
unplugged).

This patch works around this problem by introducing an early suspend
callback to note that the frontend has actually gone offline, which
will prevent the ejection from being requested.

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

index 9aa1d76e98448f439cfb53630ebdd33a77dadc33..7840cb7944ec859d202dbd7cb4d44a94555fd680 100644 (file)
@@ -81,6 +81,7 @@ struct _XENVIF_FRONTEND {
     XENBUS_SUSPEND_INTERFACE    SuspendInterface;
     XENBUS_STORE_INTERFACE      StoreInterface;
 
+    PXENBUS_SUSPEND_CALLBACK    SuspendCallbackEarly;
     PXENBUS_SUSPEND_CALLBACK    SuspendCallbackLate;
     PXENBUS_DEBUG_CALLBACK      DebugCallback;
     PXENBUS_STORE_WATCH         Watch;
@@ -2234,6 +2235,16 @@ __FrontendSuspend(
     (VOID) FrontendSetState(Frontend, FRONTEND_UNKNOWN);
 }
 
+static DECLSPEC_NOINLINE VOID
+FrontendSuspendCallbackEarly(
+    IN  PVOID           Argument
+    )
+{
+    PXENVIF_FRONTEND    Frontend = Argument;
+
+    Frontend->Online = FALSE;
+}
+
 static DECLSPEC_NOINLINE VOID
 FrontendSuspendCallbackLate(
     IN  PVOID           Argument
@@ -2263,6 +2274,15 @@ FrontendResume(
 
     __FrontendResume(Frontend);
 
+    status = XENBUS_SUSPEND(Register,
+                            &Frontend->SuspendInterface,
+                            SUSPEND_CALLBACK_EARLY,
+                            FrontendSuspendCallbackEarly,
+                            Frontend,
+                            &Frontend->SuspendCallbackEarly);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
     status = XENBUS_SUSPEND(Register,
                             &Frontend->SuspendInterface,
                             SUSPEND_CALLBACK_LATE,
@@ -2270,7 +2290,7 @@ FrontendResume(
                             Frontend,
                             &Frontend->SuspendCallbackLate);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;
 
     KeLowerIrql(Irql);
 
@@ -2289,6 +2309,14 @@ FrontendResume(
 
     return STATUS_SUCCESS;
     
+fail3:
+    Error("fail3\n");
+
+    XENBUS_SUSPEND(Deregister,
+                   &Frontend->SuspendInterface,
+                   Frontend->SuspendCallbackEarly);
+    Frontend->SuspendCallbackEarly = NULL;
+
 fail2:
     Error("fail2\n");
 
@@ -2320,6 +2348,11 @@ FrontendSuspend(
                    Frontend->SuspendCallbackLate);
     Frontend->SuspendCallbackLate = NULL;
 
+    XENBUS_SUSPEND(Deregister,
+                   &Frontend->SuspendInterface,
+                   Frontend->SuspendCallbackEarly);
+    Frontend->SuspendCallbackEarly = NULL;
+
     __FrontendSuspend(Frontend);
 
     XENBUS_SUSPEND(Release, &Frontend->SuspendInterface);