|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] tools/libs/store: add get- and set-feature related functions
commit 5234b61eab0c56c580f7507bb29e37d48520f116
Author: Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Mon Jul 28 13:06:20 2025 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 28 13:06:20 2025 +0200
tools/libs/store: add get- and set-feature related functions
Add functions for getting and setting Xenstore features to libxenstore:
xs_get_features_supported(): return the features supported by the
running Xenstore implementation as defined in xs_wire.h via the
XENSTORE_SERVER_FEATURE_* macros.
xs_get_features_domain(): return the features offered for a specific
domain.
xs_set_features_domain(): set the features available for a specific
domain.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
tools/include/xenstore.h | 13 +++++++++++
tools/libs/store/Makefile | 2 +-
tools/libs/store/libxenstore.map | 6 +++++
tools/libs/store/xs.c | 49 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/tools/include/xenstore.h b/tools/include/xenstore.h
index a442252849..423422dc50 100644
--- a/tools/include/xenstore.h
+++ b/tools/include/xenstore.h
@@ -264,6 +264,19 @@ bool xs_path_is_subpath(const char *parent, const char
*child);
*/
bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
+/* Get the features supported by Xenstore.
+ * Returned as a bitmap of XENSTORE_SERVER_FEATURE_* values.
+ */
+bool xs_get_features_supported(struct xs_handle *h, unsigned int *features);
+
+/* Get the features available for a given domain. */
+bool xs_get_features_domain(struct xs_handle *h, unsigned int domid,
+ unsigned int *features);
+
+/* Set the features available for a given domain. */
+bool xs_set_features_domain(struct xs_handle *h, unsigned int domid,
+ unsigned int features);
+
char *xs_control_command(struct xs_handle *h, const char *cmd,
void *data, unsigned int len);
/* Deprecated: use xs_control_command() instead. */
diff --git a/tools/libs/store/Makefile b/tools/libs/store/Makefile
index 0649cf8307..fed43b0008 100644
--- a/tools/libs/store/Makefile
+++ b/tools/libs/store/Makefile
@@ -2,7 +2,7 @@ XEN_ROOT=$(CURDIR)/../../..
include $(XEN_ROOT)/tools/Rules.mk
MAJOR = 4
-MINOR = 0
+MINOR = 1
version-script := libxenstore.map
ifeq ($(CONFIG_Linux),y)
diff --git a/tools/libs/store/libxenstore.map b/tools/libs/store/libxenstore.map
index 7e6c7bdd30..cd9df86749 100644
--- a/tools/libs/store/libxenstore.map
+++ b/tools/libs/store/libxenstore.map
@@ -39,3 +39,9 @@ VERS_4.0 {
xs_strings_to_perms;
local: *; /* Do not expose anything by default */
};
+VERS_4.1 {
+ global:
+ xs_get_features_supported;
+ xs_get_features_domain;
+ xs_set_features_domain;
+} VERS_4.0;
diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
index cf3266807f..8f4b90a3cf 100644
--- a/tools/libs/store/xs.c
+++ b/tools/libs/store/xs.c
@@ -1407,6 +1407,55 @@ out:
return port;
}
+static bool xs_uint(char *reply, unsigned int *uintval)
+{
+ if (!reply)
+ return false;
+
+ *uintval = strtoul(reply, NULL, 10);
+ free(reply);
+
+ return true;
+}
+
+bool xs_get_features_supported(struct xs_handle *h, unsigned int *features)
+{
+ struct xsd_sockmsg msg = { .type = XS_GET_FEATURE };
+ struct iovec iov[1];
+
+ iov[0].iov_base = &msg;
+ iov[0].iov_len = sizeof(msg);
+
+ return xs_uint(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL), features);
+}
+
+bool xs_get_features_domain(struct xs_handle *h, unsigned int domid,
+ unsigned int *features)
+{
+ return xs_uint(single_with_domid(h, XS_GET_FEATURE, domid), features);
+}
+
+bool xs_set_features_domain(struct xs_handle *h, unsigned int domid,
+ unsigned int features)
+{
+ struct xsd_sockmsg msg = { .type = XS_SET_FEATURE };
+ char domid_str[MAX_STRLEN(domid)];
+ char feat_str[MAX_STRLEN(features)];
+ struct iovec iov[3];
+
+ snprintf(domid_str, sizeof(domid_str), "%u", domid);
+ snprintf(feat_str, sizeof(feat_str), "%u", features);
+
+ iov[0].iov_base = &msg;
+ iov[0].iov_len = sizeof(msg);
+ iov[1].iov_base = domid_str;
+ iov[1].iov_len = strlen(domid_str) + 1;
+ iov[2].iov_base = feat_str;
+ iov[2].iov_len = strlen(feat_str) + 1;
+
+ return xs_bool(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL));
+}
+
char *xs_control_command(struct xs_handle *h, const char *cmd,
void *data, unsigned int len)
{
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |