]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
Fixed improper translation of SCHEDOP_Shutdown return code
authorDavid Buches <davebuch@amazon.com>
Tue, 22 Nov 2016 11:08:36 +0000 (11:08 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 22 Nov 2016 11:10:58 +0000 (11:10 +0000)
The documentation for the SCHEDOP_Shutdown hyper-call states that when
invoked with the SHUTDOWN_Suspend reason code, the return value indicates
that the guest domain either suspended (and resumed) in a new domain (0),
or that the operation was canceled (1).

The problem - the SchedShutdown() wrapper wasn't properly translating the
return value for SHUTDOWN_Suspend - it returned a success value for both
successful and canceled suspend operations, which resulted in suspend
callbacks erroneously being invoked for canceled operations, producing
undesirable side effects (suspend callbacks are only supposed to be
invoked when resuming on a new domain).

The code now returns an appropriate status value when SHUTDOWN_Suspend
operations are canceled.

Signed-off-by: David Buches <davebuch@amazon.com>
Slightly re-factored for cosmetic reasons.

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

index 07e03ce6e478fe8e8ce14852bebed96962b10975..c16866a5664b81f644d7da0bb6dcd18f75ff9086 100644 (file)
@@ -89,12 +89,20 @@ SchedShutdown(
     op.reason = Reason;
 
     rc = SchedOp(SCHEDOP_shutdown, &op);
-    
+
     if (rc < 0) {
         ERRNO_TO_STATUS(-rc, status);
         goto fail1;
     }
 
+    /*
+     * When a SCHEDOP_shutdown hypercall is issued with SHUTDOWN_suspend
+     * reason code, a return value of 1 indicates that the operation was
+     * cancelled
+     */
+    if(Reason == SHUTDOWN_suspend && rc == 1)
+        return STATUS_CANCELLED;
+
     return STATUS_SUCCESS;
 
 fail1: