If domain_create() fails, complete_domain_destroy() doesn't get called, meaning that sched_destroy_domain() is missed. In practice, this can only fail because of exceptional late_hwdom_init() issues at the moment.
Make sched_destroy_domain() idempotent, and call it in the fail path. Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> --- CC: George Dunlap <george.dun...@eu.citrix.com> CC: Jan Beulich <jbeul...@suse.com> CC: Konrad Rzeszutek Wilk <konrad.w...@oracle.com> CC: Stefano Stabellini <sstabell...@kernel.org> CC: Tim Deegan <t...@xen.org> CC: Wei Liu <wei.l...@citrix.com> CC: Dario Faggioli <dfaggi...@suse.com> CC: Roger Pau Monné <roger....@citrix.com> --- xen/common/domain.c | 3 +++ xen/common/schedule.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index e0b024c..3cefe76 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -404,6 +404,9 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags, hardware_domain = old_hwdom; atomic_set(&d->refcnt, DOMAIN_DESTROYED); xfree(d->pbuf); + + sched_destroy_domain(d); + if ( init_status & INIT_arch ) arch_domain_destroy(d); if ( init_status & INIT_gnttab ) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 5f596f0..64524f4 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -436,16 +436,18 @@ int sched_init_domain(struct domain *d, int poolid) void sched_destroy_domain(struct domain *d) { - ASSERT(d->cpupool != NULL || is_idle_domain(d)); ASSERT(d->domain_id < DOMID_FIRST_RESERVED); - SCHED_STAT_CRANK(dom_destroy); - TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id); + if ( d->cpupool ) + { + SCHED_STAT_CRANK(dom_destroy); + TRACE_1D(TRC_SCHED_DOM_REM, d->domain_id); - sched_free_domdata(dom_scheduler(d), d->sched_priv); - d->sched_priv = NULL; + sched_free_domdata(dom_scheduler(d), d->sched_priv); + d->sched_priv = NULL; - cpupool_rm_domain(d); + cpupool_rm_domain(d); + } } void vcpu_sleep_nosync(struct vcpu *v) -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel