[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH RFC 3/4] xen: implement SCHEDOP_soft_reset



Reset event channels, replace grant pages with empty ones, unmount
previously mounted vcpu_info.

Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
---
 xen/common/domain.c        | 37 +++++++++++++++++++++++++++++++++----
 xen/common/schedule.c      |  4 ++++
 xen/include/public/sched.h |  7 +++++++
 xen/include/xen/domain.h   |  2 ++
 4 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 6803c4d..44e532b 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1116,12 +1116,12 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, 
unsigned offset)
 
 /*
  * Unmap the vcpu info page if the guest decided to place it somewhere
- * else.  This is only used from arch_domain_destroy, so there's no
- * need to do anything clever.
+ * else.
  */
 void unmap_vcpu_info(struct vcpu *v)
 {
     unsigned long mfn;
+    struct domain *d = v->domain;
 
     if ( v->vcpu_info_mfn == INVALID_MFN )
         return;
@@ -1129,8 +1129,9 @@ void unmap_vcpu_info(struct vcpu *v)
     mfn = v->vcpu_info_mfn;
     unmap_domain_page_global((void *)
                              ((unsigned long)v->vcpu_info & PAGE_MASK));
-
-    v->vcpu_info = &dummy_vcpu_info;
+    v->vcpu_info = ((v->vcpu_id < XEN_LEGACY_MAX_VCPUS)
+                    ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id])
+                    : &dummy_vcpu_info);
     v->vcpu_info_mfn = INVALID_MFN;
 
     put_page_and_type(mfn_to_page(mfn));
@@ -1446,6 +1447,34 @@ int continue_hypercall_on_cpu(
     return 0;
 }
 
+int domain_soft_reset(struct domain *d)
+{
+    struct vcpu *v;
+    int ret = 0;
+
+    for_each_vcpu ( d, v )
+    {
+        if ( v != current )
+            vcpu_pause(v);
+    }
+
+    evtchn_reset(d, 1);
+
+    ret = grant_table_soft_reset(d);
+    if ( ret )
+        goto vcpu_unpause;
+
+    for_each_vcpu ( d, v )
+            unmap_vcpu_info(v);
+
+ vcpu_unpause:
+    for_each_vcpu ( d, v )
+        if ( v != current )
+            vcpu_unpause(v);
+
+    return ret;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index f5a2e55..a76de60 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1030,6 +1030,10 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) 
arg)
         break;
     }
 
+    case SCHEDOP_soft_reset:
+        ret = domain_soft_reset(current->domain);
+        break;
+
     default:
         ret = -ENOSYS;
     }
diff --git a/xen/include/public/sched.h b/xen/include/public/sched.h
index 4000ac9..2fa65f3 100644
--- a/xen/include/public/sched.h
+++ b/xen/include/public/sched.h
@@ -118,6 +118,13 @@
  * With id != 0 and timeout != 0, poke watchdog timer and set new timeout.
  */
 #define SCHEDOP_watchdog    6
+
+/*
+ * Do soft reset.
+ */
+
+#define SCHEDOP_soft_reset  7
+
 /* ` } */
 
 struct sched_shutdown {
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index 848db8a..57f8ddd 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -78,6 +78,8 @@ void arch_dump_domain_info(struct domain *d);
 
 int arch_vcpu_reset(struct vcpu *);
 
+int domain_soft_reset(struct domain *d);
+
 extern spinlock_t vcpu_alloc_lock;
 bool_t domctl_lock_acquire(void);
 void domctl_lock_release(void);
-- 
1.9.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.