aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-06-04 10:49:00 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-06-04 10:49:00 +0100
commitbfb9fa349f74a0c9c0921e4dbba8b33b56343cf3 (patch)
tree8429cde7473f06f7b98224d0546f983b581012c1
parentdd46701cedb49045b9d6d4d7cb3448c7a915ae00 (diff)
downloadxen-bfb9fa349f74a0c9c0921e4dbba8b33b56343cf3.tar.gz
xen-bfb9fa349f74a0c9c0921e4dbba8b33b56343cf3.tar.bz2
xen-bfb9fa349f74a0c9c0921e4dbba8b33b56343cf3.zip
Allow domains to set a shutdown code without actually shutting down
Useful for Windows guests, since the PV drivers are notified that the domain is about to crash just before the crash dump gets written. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com> xen-unstable changeset: 21510:2dffb2585516 xen-unstable date: Fri Jun 04 09:33:11 2010 +0100
-rw-r--r--xen/common/domain.c14
-rw-r--r--xen/common/schedule.c21
-rw-r--r--xen/include/public/sched.h7
-rw-r--r--xen/include/public/trace.h1
4 files changed, 39 insertions, 4 deletions
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 2cd3b59ca7..ab41187d79 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -231,11 +231,13 @@ struct domain *domain_create(
atomic_set(&d->refcnt, 1);
spin_lock_init_prof(d, domain_lock);
spin_lock_init_prof(d, page_alloc_lock);
- spin_lock_init(&d->shutdown_lock);
spin_lock_init(&d->hypercall_deadlock_mutex);
INIT_PAGE_LIST_HEAD(&d->page_list);
INIT_PAGE_LIST_HEAD(&d->xenpage_list);
+ spin_lock_init(&d->shutdown_lock);
+ d->shutdown_code = -1;
+
if ( domcr_flags & DOMCRF_hvm )
d->is_hvm = 1;
@@ -483,11 +485,15 @@ void domain_shutdown(struct domain *d, u8 reason)
{
struct vcpu *v;
+ spin_lock(&d->shutdown_lock);
+
+ if ( d->shutdown_code == -1 )
+ d->shutdown_code = reason;
+ reason = d->shutdown_code;
+
if ( d->domain_id == 0 )
dom0_shutdown(reason);
- spin_lock(&d->shutdown_lock);
-
if ( d->is_shutting_down )
{
spin_unlock(&d->shutdown_lock);
@@ -495,7 +501,6 @@ void domain_shutdown(struct domain *d, u8 reason)
}
d->is_shutting_down = 1;
- d->shutdown_code = reason;
smp_mb(); /* set shutdown status /then/ check for per-cpu deferrals */
@@ -527,6 +532,7 @@ void domain_resume(struct domain *d)
spin_lock(&d->shutdown_lock);
d->is_shutting_down = d->is_shut_down = 0;
+ d->shutdown_code = -1;
for_each_vcpu ( d, v )
{
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 70289041d2..2534957a8c 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -650,6 +650,27 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg)
break;
}
+ case SCHEDOP_shutdown_code:
+ {
+ struct sched_shutdown sched_shutdown;
+ struct domain *d = current->domain;
+
+ ret = -EFAULT;
+ if ( copy_from_guest(&sched_shutdown, arg, 1) )
+ break;
+
+ TRACE_3D(TRC_SCHED_SHUTDOWN_CODE,
+ d->domain_id, current->vcpu_id, sched_shutdown.reason);
+
+ spin_lock(&d->shutdown_lock);
+ if ( d->shutdown_code == -1 )
+ d->shutdown_code = (u8)sched_shutdown.reason;
+ spin_unlock(&d->shutdown_lock);
+
+ ret = 0;
+ break;
+ }
+
case SCHEDOP_poll:
{
struct sched_poll sched_poll;
diff --git a/xen/include/public/sched.h b/xen/include/public/sched.h
index 2227a95be6..e498c3c501 100644
--- a/xen/include/public/sched.h
+++ b/xen/include/public/sched.h
@@ -99,6 +99,13 @@ typedef struct sched_remote_shutdown sched_remote_shutdown_t;
DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
/*
+ * Latch a shutdown code, so that when the domain later shuts down it
+ * reports this code to the control tools.
+ * @arg == as for SCHEDOP_shutdown.
+ */
+#define SCHEDOP_shutdown_code 5
+
+/*
* Reason codes for SCHEDOP_shutdown. These may be interpreted by control
* software to determine the appropriate action. For the most part, Xen does
* not care about the shutdown code.
diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h
index 9385cb75ff..1863952071 100644
--- a/xen/include/public/trace.h
+++ b/xen/include/public/trace.h
@@ -78,6 +78,7 @@
#define TRC_SCHED_DOM_TIMER_FN (TRC_SCHED_VERBOSE + 13)
#define TRC_SCHED_SWITCH_INFPREV (TRC_SCHED_VERBOSE + 14)
#define TRC_SCHED_SWITCH_INFNEXT (TRC_SCHED_VERBOSE + 15)
+#define TRC_SCHED_SHUTDOWN_CODE (TRC_SCHED_VERBOSE + 16)
#define TRC_MEM_PAGE_GRANT_MAP (TRC_MEM + 1)
#define TRC_MEM_PAGE_GRANT_UNMAP (TRC_MEM + 2)