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>
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: