[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/7] tools/xenstored: add server feature support


  • To: Juergen Gross <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 24 Jul 2025 18:48:43 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Phdy9LBbjgmEusBukCQ0Bu5G7VwHfIazr3cOoa1UbPA=; b=mMQud1AzlcQk4bpxCaPrlQSihVMCWmK2JuGvMvfJ5nBKDYjVCfkVV4Hts3vMNyq/vBzUj2GxKDAcIK2eWYtoL2LYQDRV50W5pB9AJIIjVQUcYxB+ibTgGeDDV68kvD5fGvN5eChSl7yxFcU+fQVBpnh3YLPFhwSRimKU2M4BNCvy8yaj5cokMUBnklfprXZ4gFWyc/fwhJKF+78U5ctr12H/U50+Rh7x1HRPLbwdcdrdcVjlCm8gxDVVrstGuh5uyqqv4X1uN+lnSc8/ojAvaN4nzaHCZhrIZgTHLdlY5GtkQGEvRe4RpMw1Oxc2rxfOn5N/iV3QO4gAaJQWGA/u6A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dDO0c7diJZDJqisNp1gD7HxXokrRnW/Vh8OHjAPLOKnGps7K+A+M/uRX3ixe0PxJMWYmbCTuDvtyNB/rEcqVr42OhYuxwKQkKAtjoCmJGqDJ570AaXKi7c+4IJgBfJVrjAWK91r3BucntcagxbXdWKdrKAzsYoSCygy+7siy3uYDw4f70Pm0xGxndC8b3WgD6dEp8h66K8Z2WPj4/W4FgnLstIJgw0ZMMEj0+HeZEXWzZ/ad5+ux7a554Xan/KrZxPo0oQpXdMZRClUu59CvfYTJhlgRTkdZChkiVz+lde7xKUnCfUi2mUkoAz6oGcpLvvRwBeI6G0QIllwmzpEr1w==
  • Cc: Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 25 Jul 2025 00:32:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 2025-07-22 10:06, Juergen Gross wrote:
Add per domain server features, which are initialized by the supported
features at domain introduction, or by live update from the migration
stream. This requires to add the DOMAIN_DATA record to the migration
stream, but for now it will only contain the feature word.

Advertise the Xenstore features to guests by setting the appropriate
bits in the ring page.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
  tools/xenstored/domain.c | 71 ++++++++++++++++++++++++++++++++++++----
  tools/xenstored/domain.h |  3 ++
  tools/xenstored/lu.c     | 14 ++++++--
  tools/xenstored/lu.h     |  2 +-
  4 files changed, 80 insertions(+), 10 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index e1d5e8d614..f6d24bc13a 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -32,6 +32,7 @@
  #include "transaction.h"
  #include "watch.h"
  #include "control.h"
+#include "lu.h"
#include <xenevtchn.h>
  #include <xenmanage.h>
@@ -42,6 +43,8 @@
  #include <mini-os/xenbus.h>
  #endif
+#define XENSTORE_FEATURES XENSTORE_SERVER_FEATURE_ERROR
+
  static xenmanage_handle *xm_handle;
  xengnttab_handle **xgt_handle;
  static evtchn_port_t virq_port;
@@ -115,6 +118,9 @@ struct domain
        /* Event channel port */
        evtchn_port_t port;
+ /* Server features supported for this domain. */
+       unsigned int features;
+
        /* Domain path in store. */
        char *path;
@@ -799,6 +805,7 @@ static struct domain *alloc_domain(const void *context, unsigned int domid,
        domain->unique_id = unique_id;
        domain->generation = generation;
        domain->introduced = false;
+       domain->features = XENSTORE_FEATURES;
if (hashtable_add(domhash, &domain->domid, domain)) {
                talloc_free(domain);
@@ -992,7 +999,8 @@ void ignore_connection(struct connection *conn, unsigned 
int err)
  {
        trace("CONN %p ignored, reason %u\n", conn, err);
- if (conn->domain && conn->domain->interface)
+       if (conn->domain && conn->domain->interface &&
+           (conn->domain->features & XENSTORE_SERVER_FEATURE_ERROR))
                conn->domain->interface->error = err;
conn->is_ignored = true;
@@ -1078,11 +1086,14 @@ int do_introduce(const void *ctx, struct connection 
*conn,
domain_conn_reset(domain); - if (domain->interface != NULL &&
-           domain->interface->connection == XENSTORE_RECONNECT) {
-               /* Notify the domain that xenstore is available */
-               domain->interface->connection = XENSTORE_CONNECTED;
-               xenevtchn_notify(xce_handle, domain->port);
+       if (domain->interface != NULL) {
+               domain->interface->server_features = domain->features;
+
+               if (domain->interface->connection == XENSTORE_RECONNECT) {
+                       /* Notify the domain that xenstore is available */
+                       domain->interface->connection = XENSTORE_CONNECTED;
+                       xenevtchn_notify(xce_handle, domain->port);
+               }
        }
send_ack(conn, XS_INTRODUCE);
@@ -1849,6 +1860,54 @@ void read_state_connection(const void *ctx, const void 
*state)
        }
  }
+static int dump_state_domain(const void *k, void *v, void *arg)
+{
+       struct domain *domain = v;
+       FILE *fp = arg;
+       struct xs_state_domain sd;
+       struct xs_state_record_header head;
+
+       head.type = XS_STATE_TYPE_DOMAIN;
+       head.length = sizeof(sd);
+       memset(&sd, 0, sizeof(sd));
+       sd.domain_id = domain->domid;
+
+       if (lu_status->version > 1)

Is this why you expose lu_state below?  I can't find any other use.

Are you guaranteed lu_status != NULL?

+               sd.features = domain->features;
+
+       if (fwrite(&head, sizeof(head), 1, fp) != 1)
+               return 1;
+       if (fwrite(&sd, sizeof(sd), 1, fp) != 1)
+               return 1;
+       if (dump_state_align(fp))
+               return 1;
+
+       return 0;
+}
+
+const char *dump_state_domains(FILE *fp)
+{
+       const char *ret = NULL;
+
+       if (hashtable_iterate(domhash, dump_state_domain, fp))
+               ret = "Dump domain error";
+
+       return ret;
+}
+
+void read_state_domain(const void *ctx, const void *state, unsigned int 
version)
+{
+       const struct xs_state_domain *sd = state;
+       struct domain *domain;
+
+       domain = find_domain_struct(sd->domain_id);
+       if (!domain)
+               barf("referenced domain not found");
+
+       if (version > 1)
+               domain->features = sd->features;
+}
+
  struct domain_acc {
        unsigned int domid;
        int nodes;
diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h
index 844ac11510..8bfaca8f90 100644
--- a/tools/xenstored/domain.h
+++ b/tools/xenstored/domain.h
@@ -162,8 +162,11 @@ void wrl_apply_debit_direct(struct connection *conn);
  void wrl_apply_debit_trans_commit(struct connection *conn);
const char *dump_state_connections(FILE *fp);
+const char *dump_state_domains(FILE *fp);
void read_state_connection(const void *ctx, const void *state);
+void read_state_domain(const void *ctx, const void *state,
+                      unsigned int version);
struct hashtable *domain_check_acc_init(void);
  void domain_check_acc_add(const struct node *node, struct hashtable *domains);
diff --git a/tools/xenstored/lu.c b/tools/xenstored/lu.c
index 2c6adecb56..77e0d377c5 100644
--- a/tools/xenstored/lu.c
+++ b/tools/xenstored/lu.c
@@ -21,6 +21,8 @@
  #include "lu.h"
  #include "watch.h"
+struct live_update *lu_status;

This is where you expose lu_status.

Thanks,
Jason

+
  #ifndef NO_LIVE_UPDATE
struct lu_dump_state {
@@ -30,8 +32,6 @@ struct lu_dump_state {
        char *filename;
  };
-struct live_update *lu_status;
-
  static int lu_destroy(void *data)
  {
        lu_status = NULL;



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.