[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH RFC 1/4] xen: add a domain unique id to each domain
Xenstore is referencing domains by their domid, but reuse of a domid can lead to the situation that Xenstore can't tell whether a domain with that domid has been deleted and created again without Xenstore noticing the domain is a new one now. Add a global domain creation unique id which is updated when creating a new domain, and store that value in struct domain of the new domain. The global unique id is initialized with the system time and updates are done via the xorshift algorithm which is used for pseudo random number generation, too (see https://en.wikipedia.org/wiki/Xorshift). Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- xen/common/domain.c | 16 ++++++++++++++++ xen/include/xen/sched.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index 6ee5d033b0..755349b93f 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -84,6 +84,9 @@ vcpu_info_t dummy_vcpu_info; bool __read_mostly vmtrace_available; +/* Unique domain identifier, protected by domctl lock. */ +static uint64_t unique_id; + static void __domain_finalise_shutdown(struct domain *d) { struct vcpu *v; @@ -473,6 +476,18 @@ static void _domain_destroy(struct domain *d) free_domain_struct(d); } +static uint64_t get_unique_id(void) +{ + uint64_t x = unique_id ? : NOW(); + + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + unique_id = x; + + return x; +} + static int sanitise_domain_config(struct xen_domctl_createdomain *config) { bool hvm = config->flags & XEN_DOMCTL_CDF_hvm; @@ -552,6 +567,7 @@ struct domain *domain_create(domid_t domid, /* Sort out our idea of is_system_domain(). */ d->domain_id = domid; + d->unique_id = get_unique_id(); /* Debug sanity. */ ASSERT(is_system_domain(d) ? config == NULL : config != NULL); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 28146ee404..b827c5af8d 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -362,6 +362,9 @@ struct domain domid_t domain_id; unsigned int max_vcpus; + + uint64_t unique_id; /* Unique domain identifier */ + struct vcpu **vcpu; shared_info_t *shared_info; /* shared data area */ -- 2.26.2
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |