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

[Xen-devel] [PATCH 10/16] x86/vm-event: centralize vcpu-destroy cleanup in vm-events code



Move vm-event cleanup sequence on vcpu destroyal to vm_event.h along with the
other vm-event functions.

Signed-off-by: Corneliu ZUZU <czuzu@xxxxxxxxxxxxxxx>
---
 xen/arch/x86/domain.c          |  4 ++--
 xen/arch/x86/vm_event.c        |  5 +----
 xen/include/asm-x86/vm_event.h | 10 ++++++++++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index bb59247..2a702be 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -56,6 +56,7 @@
 #include <asm/debugreg.h>
 #include <asm/msr.h>
 #include <asm/traps.h>
+#include <asm/vm_event.h>
 #include <asm/nmi.h>
 #include <asm/mce.h>
 #include <asm/amd.h>
@@ -492,8 +493,7 @@ int vcpu_initialise(struct vcpu *v)
 
 void vcpu_destroy(struct vcpu *v)
 {
-    xfree(v->arch.vm_event);
-    v->arch.vm_event = NULL;
+    vm_event_cleanup_vcpu_destroy(v);
 
     if ( is_pv_32bit_vcpu(v) )
     {
diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c
index e795e5e..bb9c0a0 100644
--- a/xen/arch/x86/vm_event.c
+++ b/xen/arch/x86/vm_event.c
@@ -67,10 +67,7 @@ void vm_event_cleanup_domain(struct domain *d, struct 
vm_event_domain *ved)
 
     /* Per-vcpu uninitializations. */
     for_each_vcpu ( d, v )
-    {
-        xfree(v->arch.vm_event);
-        v->arch.vm_event = NULL;
-    }
+        vm_event_cleanup_vcpu_destroy(v);
 
     d->arch.mem_access_emulate_each_rep = 0;
 }
diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h
index 934f385..c1b82ab 100644
--- a/xen/include/asm-x86/vm_event.h
+++ b/xen/include/asm-x86/vm_event.h
@@ -35,6 +35,16 @@ int vm_event_init_domain(struct domain *d, struct 
vm_event_domain *ved);
 
 void vm_event_cleanup_domain(struct domain *d, struct vm_event_domain *ved);
 
+/* Called on vCPU destroy. */
+static inline void vm_event_cleanup_vcpu_destroy(struct vcpu *v)
+{
+    if ( likely(!v->arch.vm_event) )
+        return;
+
+    xfree(v->arch.vm_event);
+    v->arch.vm_event = NULL;
+}
+
 void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v);
 
 void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp);
-- 
2.5.0


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

 


Rackspace

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