On 2025-03-14 08:18, Juergen Gross wrote:
Use the new unique_id of a domain in order to detect that a domain
has been replaced with another one reusing the doamin-id of the old
domain.

While changing the related code, switch from "dom_invalid" to
"dom_valid" in order to avoid double negation and use "bool" as type
for it.

Signed-off-by: Juergen Gross <jgr...@suse.com>
---
V8:
- new patch
V9:
- adapt to different LU-record layout
- "dom_invalid" -> "dom_valid" (Jason Andryuk)

Thanks.

Reviewed-by: Jason Andryuk <jason.andr...@amd.com>

One thought below.

---
  tools/xenstored/domain.c         | 65 ++++++++++++++++++++++++++------
  tools/xenstored/xenstore_state.h |  3 +-
  2 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index a6506a5bb2..fc0992d3a5 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c

@@ -1778,6 +1811,14 @@ void read_state_connection(const void *ctx, const void 
*state)
        conn->conn_id = sc->conn_id;
read_state_buffered_data(ctx, conn, sc);
+
+       /* Validity of unique_id will be tested by check_domains() later. */
+       if ((sc->fields & XS_STATE_CONN_FIELDS_UNIQ_ID) && domain) {

Is it worth adding a sanity check for the other bits in sc->fields == 0? And a check domain != NULL when XS_STATE_CONN_FIELDS_UNIQ_ID is set?

Regards,
Jason

+               unsigned long off;
+
+               off = sizeof(*sc) + sc->data_in_len + sc->data_out_len;
+               domain->unique_id = *(uint64_t *)(state + ROUNDUP(off, 3));
+       }
  }

Reply via email to