[xen master] xen/domain: Make rangeset_domain_destroy() idempotent

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] xen/domain: Make rangeset_domain_destroy() idempotent

patchbot
commit da3bd8111858a1fb045a6ddc0b36d72164d9c5dd
Author:     Andrew Cooper <[hidden email]>
AuthorDate: Mon Sep 3 13:56:55 2018 +0100
Commit:     Andrew Cooper <[hidden email]>
CommitDate: Tue Sep 4 13:25:44 2018 +0100

    xen/domain: Make rangeset_domain_destroy() idempotent
   
    ... and move it into the common __domain_destroy() path.
   
    Signed-off-by: Andrew Cooper <[hidden email]>
    Reviewed-by: Jan Beulich <[hidden email]>
    Reviewed-by: Wei Liu <[hidden email]>
---
 xen/common/domain.c   | 9 +++------
 xen/common/rangeset.c | 3 +++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 544bbb44e3..78c450e4b4 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -272,6 +272,8 @@ static void _domain_destroy(struct domain *d)
 
     xfree(d->pbuf);
 
+    rangeset_domain_destroy(d);
+
     free_cpumask_var(d->dirty_cpumask);
 
     xsm_free_security_domain(d);
@@ -286,7 +288,7 @@ struct domain *domain_create(domid_t domid,
                              bool is_priv)
 {
     struct domain *d, **pd, *old_hwdom = NULL;
-    enum { INIT_watchdog = 1u<<1, INIT_rangeset = 1u<<2,
+    enum { INIT_watchdog = 1u<<1,
            INIT_evtchn = 1u<<3, INIT_gnttab = 1u<<4, INIT_arch = 1u<<5 };
     int err, init_status = 0;
 
@@ -350,7 +352,6 @@ struct domain *domain_create(domid_t domid,
         goto fail;
 
     rangeset_domain_initialise(d);
-    init_status |= INIT_rangeset;
 
     /* DOMID_{XEN,IO,etc} (other than IDLE) are sufficiently constructed. */
     if ( is_system_domain(d) && !is_idle_domain(d) )
@@ -475,8 +476,6 @@ struct domain *domain_create(domid_t domid,
         evtchn_destroy_final(d);
         radix_tree_destroy(&d->pirq_tree, free_pirq_struct);
     }
-    if ( init_status & INIT_rangeset )
-        rangeset_domain_destroy(d);
     if ( init_status & INIT_watchdog )
         watchdog_domain_destroy(d);
 
@@ -882,8 +881,6 @@ static void complete_domain_destroy(struct rcu_head *head)
 
     watchdog_domain_destroy(d);
 
-    rangeset_domain_destroy(d);
-
     sched_destroy_domain(d);
 
     /* Free page used by xen oprofile buffer. */
diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 7788cdd241..e3857ab816 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -482,6 +482,9 @@ void rangeset_domain_destroy(
 {
     struct rangeset *r;
 
+    if ( list_head_is_null(&d->rangesets) )
+        return;
+
     while ( !list_empty(&d->rangesets) )
     {
         r = list_entry(d->rangesets.next, struct rangeset, rangeset_list);
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog