From: "Alejandro Vallejo" <alejandro.vallejo@cloud.com>
To: "Juergen Gross" <jgross@suse.com>, <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH 1/6] xen: add a domain unique id to each domain
Date: Wed, 23 Oct 2024 15:08:51 +0100 [thread overview]
Message-ID: <D538TV4LGFZF.J375ZVYWPIHO@cloud.com> (raw)
In-Reply-To: <20241023131005.32144-2-jgross@suse.com>
On Wed Oct 23, 2024 at 2:10 PM BST, Juergen Gross wrote:
> 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@suse.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> ---
> V1:
> - make unique_id local to function (Jan Beulich)
> - add lock (Julien Grall)
> - add comment (Julien Grall)
> ---
> xen/common/domain.c | 20 ++++++++++++++++++++
> xen/include/xen/sched.h | 3 +++
> 2 files changed, 23 insertions(+)
>
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 92263a4fbd..3948640fb0 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -562,6 +562,25 @@ static void _domain_destroy(struct domain *d)
> free_domain_struct(d);
> }
>
> +static uint64_t get_unique_id(void)
> +{
> + static uint64_t unique_id;
> + static DEFINE_SPINLOCK(lock);
> + uint64_t x = unique_id ? : NOW();
> +
> + spin_lock(&lock);
> +
> + /* Pseudo-randomize id in order to avoid consumers relying on sequence. */
> + x ^= x << 13;
> + x ^= x >> 7;
> + x ^= x << 17;
> + unique_id = x;
> +
> + spin_unlock(&lock);
> +
> + return x;
> +}
> +
> static int sanitise_domain_config(struct xen_domctl_createdomain *config)
> {
> bool hvm = config->flags & XEN_DOMCTL_CDF_hvm;
> @@ -654,6 +673,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();
>
> /* Holding CDF_* internal flags. */
> d->cdf = flags;
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 90666576c2..1dd8a425f9 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -370,6 +370,9 @@ struct domain
> domid_t domain_id;
>
> unsigned int max_vcpus;
> +
> + uint64_t unique_id; /* Unique domain identifier */
> +
Why not xen_domain_handle_t handle, defined later on? That's meant to be a
UUID, so this feels like a duplicate field.
> struct vcpu **vcpu;
>
> shared_info_t *shared_info; /* shared data area */
Cheers,
Alejandro
next prev parent reply other threads:[~2024-10-23 14:09 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 13:09 [PATCH 0/6] remove libxenctrl usage from xenstored Juergen Gross
2024-10-23 13:10 ` [PATCH 1/6] xen: add a domain unique id to each domain Juergen Gross
2024-10-23 14:08 ` Alejandro Vallejo [this message]
2024-10-23 14:27 ` Juergen Gross
2024-10-31 11:58 ` Alejandro Vallejo
2024-11-01 7:06 ` Jürgen Groß
2024-11-01 12:13 ` Alejandro Vallejo
2024-11-16 10:46 ` Julien Grall
2024-11-18 7:25 ` Jürgen Groß
2024-10-23 13:10 ` [PATCH 2/6] xen: add bitmap to indicate per-domain state changes Juergen Gross
2024-10-31 10:59 ` Jan Beulich
2024-11-01 6:48 ` Jürgen Groß
2024-11-04 9:35 ` Jan Beulich
2024-11-16 11:01 ` Julien Grall
2024-11-18 7:32 ` Jürgen Groß
2024-10-23 13:10 ` [PATCH 3/6] xen: add new domctl get_changed_domain Juergen Gross
2024-10-23 15:55 ` Daniel P. Smith
2024-10-24 9:13 ` Jürgen Groß
2024-10-24 13:35 ` Daniel P. Smith
2024-10-24 13:59 ` Jürgen Groß
2024-10-28 10:50 ` Jan Beulich
2024-10-28 11:02 ` Jürgen Groß
2024-10-31 11:16 ` Jan Beulich
2024-11-01 7:03 ` Jürgen Groß
2024-12-04 10:01 ` Juergen Gross
2024-12-06 9:39 ` Juergen Gross
2024-10-23 13:10 ` [PATCH 4/6] tools/libs: add a new libxenmanage library Juergen Gross
2024-11-22 13:55 ` Anthony PERARD
2024-11-22 15:12 ` Jürgen Groß
2024-11-26 16:44 ` Anthony PERARD
2024-12-02 7:25 ` Jürgen Groß
2024-10-23 13:10 ` [PATCH 5/6] tools: add a dedicated header file for barrier definitions Juergen Gross
2024-11-26 17:28 ` Anthony PERARD
2024-12-02 7:33 ` Jürgen Groß
2024-10-23 13:10 ` [PATCH 6/6] tools/xenstored: use new stable interface instead of libxenctrl Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D538TV4LGFZF.J375ZVYWPIHO@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.