From nobody Fri Oct 31 04:01:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1753193219; cv=none; d=zohomail.com; s=zohoarc; b=l1v9Q0NxlBBoI0wzSUYVrTUcRpbCnnx0nS/lgVJ50LKuhB4tVJ/JkrH5haQAu466OLsJGaFyImc9HInCF7TURDq0X1gUrr6lO15t6jffrs1U9fqjZsyIB4AmX/zvrTGVo1mTGIkv+t2hnZiE/dASnw3Do252XO2ZkfjNM1enKsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753193219; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hwQcdaQXyhmu4Exu8gwLl3uTdn0YZ/pu3cUIggmc++Q=; b=QF+2jqoJzRDdWBbp0AVPcUxXqFd5pINSxRd19X/9mJYNpvHpEKwz/LCccs31IRFpcjGAT85w9wD4kHRV8iF69df4sTmjMr4UF11eeATwtXADmewlFZ9jtqkjSG4fS6rmDR9vUSY5KPmcsG95AA/Kyv+1lDe3z6IrxxNjThn/198= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1753193219235449.44981983015623; Tue, 22 Jul 2025 07:06:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1052672.1421410 (Exim 4.92) (envelope-from ) id 1ueDdh-0005CI-7G; Tue, 22 Jul 2025 14:06:41 +0000 Received: by outflank-mailman (output) from mailman id 1052672.1421410; Tue, 22 Jul 2025 14:06:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ueDdh-0005CB-4P; Tue, 22 Jul 2025 14:06:41 +0000 Received: by outflank-mailman (input) for mailman id 1052672; Tue, 22 Jul 2025 14:06:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ueDdg-0005C5-7c for xen-devel@lists.xenproject.org; Tue, 22 Jul 2025 14:06:40 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 155a89e4-6705-11f0-b894-0df219b8e170; Tue, 22 Jul 2025 16:06:38 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AB75A1F7D7; Tue, 22 Jul 2025 14:06:37 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 82EEB13A32; Tue, 22 Jul 2025 14:06:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mgNsHu2af2i5IAAAD6G6ig (envelope-from ); Tue, 22 Jul 2025 14:06:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 155a89e4-6705-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753193197; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hwQcdaQXyhmu4Exu8gwLl3uTdn0YZ/pu3cUIggmc++Q=; b=FyCpdLbx9XzAC3pneFkfuxAX4pxfzsrpMBDnjScuz/WoSxdV8dgHaBJf5RDtbFaF6yb7vE m37BjeblLil6eOpEn7eADTMBPOexJXwLeIeYwYyhneJTKVJn4au7ZEI/EZKu9mAxpr7uEc rHx5oj2N1JZG2pEqHK+dE3xQ4W9SWWk= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753193197; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hwQcdaQXyhmu4Exu8gwLl3uTdn0YZ/pu3cUIggmc++Q=; b=FyCpdLbx9XzAC3pneFkfuxAX4pxfzsrpMBDnjScuz/WoSxdV8dgHaBJf5RDtbFaF6yb7vE m37BjeblLil6eOpEn7eADTMBPOexJXwLeIeYwYyhneJTKVJn4au7ZEI/EZKu9mAxpr7uEc rHx5oj2N1JZG2pEqHK+dE3xQ4W9SWWk= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 1/7] tools/libs/store: add get- and set-feature related functions Date: Tue, 22 Jul 2025 16:06:22 +0200 Message-ID: <20250722140628.28947-2-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250722140628.28947-1-jgross@suse.com> References: <20250722140628.28947-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_THREE(0.00)[4]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1753193221560116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Jason Andryuk --- 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); =20 +/* 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=3D$(CURDIR)/../../.. include $(XEN_ROOT)/tools/Rules.mk =20 MAJOR =3D 4 -MINOR =3D 0 +MINOR =3D 1 version-script :=3D libxenstore.map =20 ifeq ($(CONFIG_Linux),y) diff --git a/tools/libs/store/libxenstore.map b/tools/libs/store/libxenstor= e.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; } =20 +static bool xs_uint(char *reply, unsigned int *uintval) +{ + if (!reply) + return false; + + *uintval =3D strtoul(reply, NULL, 10); + free(reply); + + return true; +} + +bool xs_get_features_supported(struct xs_handle *h, unsigned int *features) +{ + struct xsd_sockmsg msg =3D { .type =3D XS_GET_FEATURE }; + struct iovec iov[1]; + + iov[0].iov_base =3D &msg; + iov[0].iov_len =3D 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 =3D { .type =3D 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 =3D &msg; + iov[0].iov_len =3D sizeof(msg); + iov[1].iov_base =3D domid_str; + iov[1].iov_len =3D strlen(domid_str) + 1; + iov[2].iov_base =3D feat_str; + iov[2].iov_len =3D 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) { --=20 2.43.0