From nobody Mon Mar 23 19:58:08 2026 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; 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=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773388118420405.64002279156625; Fri, 13 Mar 2026 00:48:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253347.1549622 (Exim 4.92) (envelope-from ) id 1w0xFa-0003ht-NG; Fri, 13 Mar 2026 07:48:02 +0000 Received: by outflank-mailman (output) from mailman id 1253347.1549622; Fri, 13 Mar 2026 07:48:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFa-0003hm-KQ; Fri, 13 Mar 2026 07:48:02 +0000 Received: by outflank-mailman (input) for mailman id 1253347; Fri, 13 Mar 2026 07:48:01 +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 1w0xFZ-0003h2-U2 for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:01 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f4c34d4d-1eb0-11f1-9ccf-f158ae23cfc8; Fri, 13 Mar 2026 08:47:59 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 0D0BC4E3F0; Fri, 13 Mar 2026 07:47:59 +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 CA916403F6; Fri, 13 Mar 2026 07:47:58 +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 KjFkMC7Bs2mpGAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:47:58 +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: f4c34d4d-1eb0-11f1-9ccf-f158ae23cfc8 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 1/8] tools/xenstored: allow domU to get own features Date: Fri, 13 Mar 2026 08:47:44 +0100 Message-ID: <20260313074751.2904215-2-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 0D0BC4E3F0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-ZM-MESSAGEID: 1773388120981154100 Content-Type: text/plain; charset="utf-8" Expand the XS_GET_FEATURE command to allow an unprivileged domain to read its own available features. While this information is available via the related field in the shared page used for communication with Xenstore, user land components of the domU would need special support in the related kernel driver to obtain that data. With supporting the XS_GET_FEATURE for that purpose, only an up to date libxenstore is needed. Signed-off-by: Juergen Gross --- docs/misc/xenstore.txt | 9 +++++---- tools/xenstored/core.c | 3 +-- tools/xenstored/domain.c | 16 +++++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/misc/xenstore.txt b/docs/misc/xenstore.txt index 4eccbc2f7f..8a2c19d116 100644 --- a/docs/misc/xenstore.txt +++ b/docs/misc/xenstore.txt @@ -427,13 +427,14 @@ SET_FEATURE || to set a bit for a feature not being supported by the running Xenstore will be denied. Providing no with the GET_FEATURE command will return the features which are supported - by Xenstore. + by Xenstore for the domain issuing the command. =20 SET_FEATURE for a domain will be rejected after the INTRODUCE - command for this domain has been sent to xenstored. + command for this domain has been sent to xenstored. This has the + effect that dom0 will always have all supported features enabled. =20 - xenstored prevents the use of GET_FEATURE and SET_FEATURE other - than by dom0. + xenstored prevents the use of GET_FEATURE with a domid specified + and SET_FEATURE other than by dom0. =20 GET_QUOTA [[|]|] | SET_QUOTA [|]|| diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index e283d47184..09f1390f14 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -2030,8 +2030,7 @@ static struct { { "SET_TARGET", do_set_target, XS_FLAG_PRIV }, [XS_RESET_WATCHES] =3D { "RESET_WATCHES", do_reset_watches }, [XS_DIRECTORY_PART] =3D { "DIRECTORY_PART", send_directory_part }, - [XS_GET_FEATURE] =3D - { "GET_FEATURE", do_get_feature, XS_FLAG_PRIV }, + [XS_GET_FEATURE] =3D { "GET_FEATURE", do_get_feature }, [XS_SET_FEATURE] =3D { "SET_FEATURE", do_set_feature, XS_FLAG_PRIV }, [XS_GET_QUOTA] =3D diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index c0bc8a3eb7..ebeced3228 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1293,17 +1293,23 @@ int do_get_feature(const void *ctx, struct connecti= on *conn, char *result; =20 n_args =3D get_strings(in, vec, ARRAY_SIZE(vec)); - if (n_args > 1) - return EINVAL; =20 - if (n_args =3D=3D 1) { + if (!n_args) { + features =3D conn->domain ? conn->domain->features + : XENSTORE_FEATURES; + } else { + if (domain_is_unprivileged(conn)) + return EACCES; + + if (n_args > 1) + return EINVAL; + domid =3D atoi(vec[0]); domain =3D find_or_alloc_existing_domain(domid); if (!domain) return ENOENT; features =3D domain->features; - } else - features =3D XENSTORE_FEATURES; + } =20 result =3D talloc_asprintf(ctx, "%u", features); if (!result) --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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; 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=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 177338810554189.98860258841432; Fri, 13 Mar 2026 00:48:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253348.1549630 (Exim 4.92) (envelope-from ) id 1w0xFf-0003yl-TX; Fri, 13 Mar 2026 07:48:07 +0000 Received: by outflank-mailman (output) from mailman id 1253348.1549630; Fri, 13 Mar 2026 07:48:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFf-0003ye-QS; Fri, 13 Mar 2026 07:48:07 +0000 Received: by outflank-mailman (input) for mailman id 1253348; Fri, 13 Mar 2026 07:48:06 +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 1w0xFe-0003h2-MZ for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:06 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2a07:de40:b251:101:10:150:64:1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f7db8808-1eb0-11f1-9ccf-f158ae23cfc8; Fri, 13 Mar 2026 08:48:04 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 922454E3F0; Fri, 13 Mar 2026 07:48:04 +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 5B0DF403F6; Fri, 13 Mar 2026 07:48:04 +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 jIcPFTTBs2mtGAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:04 +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: f7db8808-1eb0-11f1-9ccf-f158ae23cfc8 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH 2/8] docs: clarify Xenstore watch depth feature Date: Fri, 13 Mar 2026 08:47:45 +0100 Message-ID: <20260313074751.2904215-3-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 922454E3F0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-ZM-MESSAGEID: 1773388107055158500 Content-Type: text/plain; charset="utf-8" Make it explicit that for watching the @releaseDomain/ special node, the XENSTORE_SERVER_FEATURE_WATCHDEPTH is needed. Signed-off-by: Juergen Gross --- docs/misc/xenstore.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/misc/xenstore.txt b/docs/misc/xenstore.txt index 8a2c19d116..dba6471387 100644 --- a/docs/misc/xenstore.txt +++ b/docs/misc/xenstore.txt @@ -266,7 +266,8 @@ WATCH ||[|]? decimal value of 0 or larger): it denotes the directory levels below to consider for a match ("0" would not match for a child of , "1" would match only for a direct child, - etc.). + etc.). The depth specification is possible only, if the + XENSTORE_SERVER_FEATURE_WATCHDEPTH feature is available. =20 can be a to watch or @. In the latter case may have any syntax but it matches @@ -284,6 +285,8 @@ WATCH ||[|]? values are not supported. For @releaseDomain it is possible to watch only for a specific domain by specifying @releaseDomain/ for the path. + This requires the XENSTORE_SERVER_FEATURE_WATCHDEPTH to be + available. =20 When a watch is first set up it is triggered once straight away, with equal to . Watches may be triggered --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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=1773388122; cv=none; d=zohomail.com; s=zohoarc; b=FSR6bd6hs4k9cmPOYigWXH6zOVv+YfmcZ0kVCJgyNQe/q+AiMcQwAeGHcZOv2IASjj6HzfE5ZRbqHZ6MZvZUMZuIzOYYmSsVugCIQo/gd4aKNUWO3AcrfVDkhRHX3H603uABBVdPAL+RfqkNFe73aKAjq0j1mhcn2rMxytp9Kb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773388122; 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=pOMNch7LDMhlMuA7/SnfhE7VtklPTC8Mp2JthrXp6FM=; b=NJ3EPnToLV2ERv2giZW0hKqoqj0rP5+x2J+TcUfg5wYraV8rVIkc92QG8teTxEUXgIP1ESrFcztKMVFjrWGyob+1Eos12r+AFlYbPrFRY8fer0kD6oZ11u7afHgsEQLprVSSt/MLX5jLDTNs4MouwTHY48+VZh5H1k549lFRivI= 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 1773388122974384.62616378485427; Fri, 13 Mar 2026 00:48:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253351.1549639 (Exim 4.92) (envelope-from ) id 1w0xFl-0004GZ-4P; Fri, 13 Mar 2026 07:48:13 +0000 Received: by outflank-mailman (output) from mailman id 1253351.1549639; Fri, 13 Mar 2026 07:48:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFl-0004GS-1k; Fri, 13 Mar 2026 07:48:13 +0000 Received: by outflank-mailman (input) for mailman id 1253351; Fri, 13 Mar 2026 07:48:11 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFj-0003TG-DM for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:11 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fb1de7e2-1eb0-11f1-b164-2bf370ae4941; Fri, 13 Mar 2026 08:48:10 +0100 (CET) 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 0BB825CEF2; Fri, 13 Mar 2026 07:48:10 +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 DEF51403F6; Fri, 13 Mar 2026 07:48:09 +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 x6BCNTnBs2m1GAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:09 +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: fb1de7e2-1eb0-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388090; 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=pOMNch7LDMhlMuA7/SnfhE7VtklPTC8Mp2JthrXp6FM=; b=mv1paiadsjWVfW8yV3KF2x9/U5KPiDFrjBM2mhfK5Q4HkuKa1iyPzd/jP/OfeK3S7RTIHN ukbOc+khzCJbf4bjLfGAPF1RU+38nrQ/DEQ3OlxjLMScnnRH2BACo660X1Ro5qIhc+ShkW zF2PEdbxVZbnAqRp3rGbN2H1t71x97M= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388090; 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=pOMNch7LDMhlMuA7/SnfhE7VtklPTC8Mp2JthrXp6FM=; b=mv1paiadsjWVfW8yV3KF2x9/U5KPiDFrjBM2mhfK5Q4HkuKa1iyPzd/jP/OfeK3S7RTIHN ukbOc+khzCJbf4bjLfGAPF1RU+38nrQ/DEQ3OlxjLMScnnRH2BACo660X1Ro5qIhc+ShkW zF2PEdbxVZbnAqRp3rGbN2H1t71x97M= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD , Julien Grall Subject: [PATCH 3/8] tools/libs/store: add support to use watches with a depth parameter Date: Fri, 13 Mar 2026 08:47:46 +0100 Message-ID: <20260313074751.2904215-4-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid,suse.com:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773388126944154100 Content-Type: text/plain; charset="utf-8" Add a new xs_watch_depth() function to libxenstore allowing to limit the scope of a Xenstore watch. It can be used only in case Xenstore is supporting the XENSTORE_SERVER_FEATURE_WATCHDEPTH feature. For convenience add a xs_watch_try_depth() wrapper, which will call xs_watch_depth() if supported and xs_watch() otherwise. Cache the supported features of Xenstore in order not having to get them from Xenstore for each call of one of the new functions. Signed-off-by: Juergen Gross --- docs/man/xl.cfg.5.pod.in | 6 ++ tools/include/xenstore.h | 16 +++++ tools/libs/store/libxenstore.map | 2 + tools/libs/store/xs.c | 116 ++++++++++++++++++++++++++----- xen/include/public/io/xs_wire.h | 2 + 5 files changed, 123 insertions(+), 19 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 3aac0bc4fb..2f77016ecf 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -740,6 +740,12 @@ Xenstore is capable to reconnect to a guest. Xenstore will present an error value in case it disconnects due to an error condition. =20 +=3Ditem B<0x00000004> + +Xenstore supports to set watches with a limited depth (depth 0 matches +only the watched node, depth 1 matches the node and its direct children, +etc.). + =3Dback =20 The features supported by the running Xenstore instance can be retrieved diff --git a/tools/include/xenstore.h b/tools/include/xenstore.h index 6b661e5895..8a6afd97f5 100644 --- a/tools/include/xenstore.h +++ b/tools/include/xenstore.h @@ -177,6 +177,22 @@ bool xs_set_permissions(struct xs_handle *h, xs_transa= ction_t t, */ bool xs_watch(struct xs_handle *h, const char *path, const char *token); =20 +/* Same as xs_watch(), but with limiting the matching for modified + * children to a specified depth (depth 0 only matches the node itself, + * depth 1 will additionally match direct children of the node, etc.). + * Only supported if the XENSTORE_SERVER_FEATURE_WATCHDEPTH (4) is set + * in the returned features of xs_get_features_supported(). + */ +bool xs_watch_depth(struct xs_handle *h, const char *path, const char *tok= en, + unsigned int depth); + +/* If supported, same as xs_watch_depth(), use xs_watch() otherwise. + * As a result watches might trigger for nodes below the watched path, too. + * Not to be used for special watches! + */ +bool xs_watch_try_depth(struct xs_handle *h, const char *path, + const char *token, unsigned int depth); + /* Return the FD to poll on to see if a watch has fired. */ int xs_fileno(struct xs_handle *h); =20 diff --git a/tools/libs/store/libxenstore.map b/tools/libs/store/libxenstor= e.map index a08ddd549f..7067068998 100644 --- a/tools/libs/store/libxenstore.map +++ b/tools/libs/store/libxenstore.map @@ -52,4 +52,6 @@ VERS_4.2 { xs_set_global_quota; xs_get_domain_quota; xs_set_domain_quota; + xs_watch_depth; + xs_watch_try_depth; } VERS_4.1; diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c index dda37f7526..0bea464a33 100644 --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -984,37 +984,29 @@ bool xs_restrict(struct xs_handle *h, unsigned domid) return false; } =20 -/* Watch a node for changes (poll on fd to detect, or call read_watch()). - * When the node (or any child) changes, fd will become readable. - * Token is returned when watch is read, to allow matching. - * Returns false on failure. - */ -bool xs_watch(struct xs_handle *h, const char *path, const char *token) +static bool xs_watch_helper(struct xs_handle *h) { - struct xsd_sockmsg msg =3D { .type =3D XS_WATCH }; - struct iovec iov[3]; - #ifdef USE_PTHREAD + sigset_t set, old_set; + pthread_attr_t attr; + static size_t stack_size; +#ifdef USE_DLSYM + size_t (*getsz)(pthread_attr_t *attr); +#endif + #define DEFAULT_THREAD_STACKSIZE (16 * 1024) /* NetBSD doesn't have PTHREAD_STACK_MIN. */ #ifndef PTHREAD_STACK_MIN # define PTHREAD_STACK_MIN 0 #endif =20 -#define READ_THREAD_STACKSIZE \ - ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ +#define READ_THREAD_STACKSIZE \ + ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE) =20 /* We dynamically create a reader thread on demand. */ mutex_lock(&h->request_mutex); if (!h->read_thr_exists) { - sigset_t set, old_set; - pthread_attr_t attr; - static size_t stack_size; -#ifdef USE_DLSYM - size_t (*getsz)(pthread_attr_t *attr); -#endif - if (pthread_attr_init(&attr) !=3D 0) { mutex_unlock(&h->request_mutex); return false; @@ -1050,16 +1042,89 @@ bool xs_watch(struct xs_handle *h, const char *path= , const char *token) mutex_unlock(&h->request_mutex); #endif =20 + return true; +} + +/* Watch a node for changes (poll on fd to detect, or call read_watch()). + * When the node (or any child) changes, fd will become readable. + * Token is returned when watch is read, to allow matching. + * Returns false on failure. + */ +bool xs_watch(struct xs_handle *h, const char *path, const char *token) +{ + struct xsd_sockmsg msg =3D { .type =3D XS_WATCH }; + struct iovec iov[3]; + + if (!xs_watch_helper(h)) + return false; + + iov[0].iov_base =3D &msg; + iov[0].iov_len =3D sizeof(msg); + iov[1].iov_base =3D (void *)path; + iov[1].iov_len =3D strlen(path) + 1; + iov[2].iov_base =3D (void *)token; + iov[2].iov_len =3D strlen(token) + 1; + + return xs_bool(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL)); +} + +/* Same as xs_watch(), but with limiting the matching for modified + * children to a specified depth (depth 0 only matches the node itself, + * depth 1 will additionally match direct children of the node, etc.). + * Only supported if the XENSTORE_SERVER_FEATURE_WATCHDEPTH (4) is set + * in the returned features of xs_get_features_supported(). + */ +bool xs_watch_depth(struct xs_handle *h, const char *path, const char *tok= en, + unsigned int depth) +{ + struct xsd_sockmsg msg =3D { .type =3D XS_WATCH }; + struct iovec iov[4]; + char depthstr[MAX_STRLEN(depth)]; + static bool depth_supported; + + if (!xs_watch_helper(h)) + return false; + + if (!depth_supported) { + unsigned int features; + + if (!xs_get_features_supported(h, &features)) + return false; + if (!(features & XENSTORE_SERVER_FEATURE_WATCHDEPTH)) + return false; + depth_supported =3D true; + } + + snprintf(depthstr, sizeof(depthstr), "%u", depth); + iov[0].iov_base =3D &msg; iov[0].iov_len =3D sizeof(msg); iov[1].iov_base =3D (void *)path; iov[1].iov_len =3D strlen(path) + 1; iov[2].iov_base =3D (void *)token; iov[2].iov_len =3D strlen(token) + 1; + iov[3].iov_base =3D depthstr; + iov[3].iov_len =3D strlen(depthstr) + 1; =20 return xs_bool(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL)); } =20 +/* If supported, same as xs_watch_depth(), use xs_watch() otherwise. + * As a result watches might trigger for nodes below the watched path, too. + * Not to be used for special watches! + */ +bool xs_watch_try_depth(struct xs_handle *h, const char *path, + const char *token, unsigned int depth) +{ + unsigned int features; + + if (xs_get_features_supported(h, &features) && + (features & XENSTORE_SERVER_FEATURE_WATCHDEPTH) && + xs_watch_depth(h, path, token, depth)) + return true; + + return xs_watch(h, path, token); +} =20 /* Clear the pipe token if there are no more pending watchs. * We suppose the watch_mutex is already taken. @@ -1420,13 +1485,26 @@ static bool xs_uint(char *reply, unsigned int *uint= val) =20 bool xs_get_features_supported(struct xs_handle *h, unsigned int *features) { + static unsigned int own_features =3D 0; + static bool features_valid =3D false; struct xsd_sockmsg msg =3D { .type =3D XS_GET_FEATURE }; struct iovec iov[1]; =20 + if (features_valid) { + *features =3D own_features; + return true; + } + iov[0].iov_base =3D &msg; iov[0].iov_len =3D sizeof(msg); =20 - return xs_uint(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL), features); + if (!xs_uint(xs_talkv(h, iov, ARRAY_SIZE(iov), NULL), &own_features)) + return false; + + features_valid =3D true; + *features =3D own_features; + + return true; } =20 bool xs_get_features_domain(struct xs_handle *h, unsigned int domid, diff --git a/xen/include/public/io/xs_wire.h b/xen/include/public/io/xs_wir= e.h index d2e2b8b9eb..2e763bc877 100644 --- a/xen/include/public/io/xs_wire.h +++ b/xen/include/public/io/xs_wire.h @@ -124,6 +124,8 @@ struct xenstore_domain_interface { #define XENSTORE_SERVER_FEATURE_RECONNECTION 1 /* The presence of the "error" field in the ring page */ #define XENSTORE_SERVER_FEATURE_ERROR 2 +/* The XS_WATCH command can be used with a parameter */ +#define XENSTORE_SERVER_FEATURE_WATCHDEPTH 4 =20 /* Valid values for the connection field */ #define XENSTORE_CONNECTED 0 /* the steady-state */ --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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; 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=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773388113962669.4305521749094; Fri, 13 Mar 2026 00:48:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253354.1549650 (Exim 4.92) (envelope-from ) id 1w0xFq-0004jd-Kx; Fri, 13 Mar 2026 07:48:18 +0000 Received: by outflank-mailman (output) from mailman id 1253354.1549650; Fri, 13 Mar 2026 07:48:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFq-0004jW-Fq; Fri, 13 Mar 2026 07:48:18 +0000 Received: by outflank-mailman (input) for mailman id 1253354; Fri, 13 Mar 2026 07:48:16 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFo-0003TG-G4 for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:16 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2a07:de40:b251:101:10:150:64:1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fe548862-1eb0-11f1-b164-2bf370ae4941; Fri, 13 Mar 2026 08:48:15 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id 79DA24D656; Fri, 13 Mar 2026 07:48:15 +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 5794B403F6; Fri, 13 Mar 2026 07:48:15 +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 NQ08FD/Bs2m5GAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:15 +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: fe548862-1eb0-11f1-b164-2bf370ae4941 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 4/8] tools/xenstored: add depth information to watches Date: Fri, 13 Mar 2026 08:47:47 +0100 Message-ID: <20260313074751.2904215-5-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 79DA24D656 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-ZM-MESSAGEID: 1773388114983158500 Content-Type: text/plain; charset="utf-8" Add the depth for matching subdirectories of a watch to the watch handling. A depth value of -1 is used for the current model of no limit. Signed-off-by: Juergen Gross --- tools/xenstored/lu.c | 3 ++ tools/xenstored/watch.c | 110 ++++++++++++++++++++++++++++------------ tools/xenstored/watch.h | 1 + 3 files changed, 81 insertions(+), 33 deletions(-) diff --git a/tools/xenstored/lu.c b/tools/xenstored/lu.c index eaffdbc69e..7d9f086a59 100644 --- a/tools/xenstored/lu.c +++ b/tools/xenstored/lu.c @@ -183,6 +183,9 @@ void lu_read_state(void) case XS_STATE_TYPE_WATCH: read_state_watch(ctx, state.buf); break; + case XS_STATE_TYPE_WATCH_EXT: + read_state_watch_ext(ctx, state.buf); + break; case XS_STATE_TYPE_TA: xprintf("live-update: ignore transaction record\n"); break; diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c index 36e4d33f22..3f1049911b 100644 --- a/tools/xenstored/watch.c +++ b/tools/xenstored/watch.c @@ -39,26 +39,35 @@ struct watch /* Offset into path for skipping prefix (used for relative paths). */ unsigned int prefix_len; =20 + int depth; /* -1: no depth limit. */ char *token; char *node; }; =20 /* Is child a subnode of parent, or equal? */ -static bool is_child(const char *child, const char *parent) +static bool is_child(const char *child, const char *parent, int depth) { - unsigned int len =3D strlen(parent); - - /* - * / should really be "" for this algorithm to work, but that's a - * usability nightmare. - */ - if (streq(parent, "/")) - return true; + unsigned int len =3D strlen(parent); /* len =3D=3D 1 if parent is "/". */ + unsigned int sub_levels =3D (len =3D=3D 1) ? 1 : 0; =20 if (strncmp(child, parent, len) !=3D 0) return false; =20 - return child[len] =3D=3D '/' || child[len] =3D=3D '\0'; + if (child[len] !=3D '/' && child[len] !=3D '\0' && len > 1) + return false; + + if (depth < 0 || child[len] =3D=3D '\0') + return true; + + while (sub_levels <=3D depth) { + if (child[len] =3D=3D '\0') + return true; + if (child[len] =3D=3D '/') + sub_levels++; + len++; + } + + return false; } =20 static const char *get_watch_path(const struct watch *watch, const char *n= ame) @@ -145,7 +154,7 @@ void fire_watches(struct connection *conn, const void *= ctx, const char *name, get_watch_path(watch, name), watch->token); } else { - if (is_child(name, watch->node)) + if (is_child(name, watch->node, watch->depth)) send_event(req, i, get_watch_path(watch, name), watch->token); @@ -170,7 +179,7 @@ static int check_watch_path(struct connection *conn, co= nst void *ctx, } =20 static struct watch *add_watch(struct connection *conn, const char *path, - const char *token, bool relative, + const char *token, int depth, bool relative, bool no_quota_check) { struct watch *watch; @@ -178,6 +187,7 @@ static struct watch *add_watch(struct connection *conn,= const char *path, watch =3D talloc(conn, struct watch); if (!watch) goto nomem; + watch->depth =3D depth; watch->node =3D talloc_strdup(watch, path); watch->token =3D talloc_strdup(watch, token); if (!watch->node || !watch->token) @@ -204,6 +214,7 @@ int do_watch(const void *ctx, struct connection *conn, = struct buffered_data *in) { struct watch *watch; const char *vec[2]; + int depth =3D -1; bool relative; =20 if (get_strings(in, vec, ARRAY_SIZE(vec)) !=3D ARRAY_SIZE(vec)) @@ -223,7 +234,7 @@ int do_watch(const void *ctx, struct connection *conn, = struct buffered_data *in) if (domain_check_quota_add(conn->domain, ACC_WATCH, 1)) return ENOSPC; =20 - watch =3D add_watch(conn, vec[0], vec[1], relative, false); + watch =3D add_watch(conn, vec[0], vec[1], depth, relative, false); if (!watch) return errno; =20 @@ -287,28 +298,47 @@ const char *dump_state_watches(FILE *fp, struct conne= ction *conn, const char *ret =3D NULL; struct watch *watch; struct xs_state_watch sw; + struct xs_state_watch_ext swe; struct xs_state_record_header head; const char *path; - - head.type =3D XS_STATE_TYPE_WATCH; + size_t path_len, token_len; =20 list_for_each_entry(watch, &conn->watches, list) { - head.length =3D sizeof(sw); - - sw.conn_id =3D conn_id; path =3D get_watch_path(watch, watch->node); - sw.path_length =3D strlen(path) + 1; - sw.token_length =3D strlen(watch->token) + 1; - head.length +=3D sw.path_length + sw.token_length; + path_len =3D strlen(path) + 1; + token_len =3D strlen(watch->token) + 1; + + if (watch->depth >=3D 0) { + head.type =3D XS_STATE_TYPE_WATCH_EXT; + head.length =3D sizeof(swe); + swe.conn_id =3D conn_id; + swe.path_length =3D path_len; + swe.token_length =3D token_len; + swe.depth =3D watch->depth; + } else { + head.type =3D XS_STATE_TYPE_WATCH; + head.length =3D sizeof(sw); + sw.conn_id =3D conn_id; + sw.path_length =3D path_len; + sw.token_length =3D token_len; + } + + head.length +=3D path_len + token_len; head.length =3D ROUNDUP(head.length, 3); if (fwrite(&head, sizeof(head), 1, fp) !=3D 1) return "Dump watch state error"; - if (fwrite(&sw, sizeof(sw), 1, fp) !=3D 1) - return "Dump watch state error"; =20 - if (fwrite(path, sw.path_length, 1, fp) !=3D 1) + if (watch->depth >=3D 0) { + if (fwrite(&swe, sizeof(sw), 1, fp) !=3D 1) + return "Dump watch state ext error"; + } else { + if (fwrite(&sw, sizeof(sw), 1, fp) !=3D 1) + return "Dump watch state error"; + } + + if (fwrite(path, path_len, 1, fp) !=3D 1) return "Dump watch path error"; - if (fwrite(watch->token, sw.token_length, 1, fp) !=3D 1) + if (fwrite(watch->token, token_len, 1, fp) !=3D 1) return "Dump watch token error"; =20 ret =3D dump_state_align(fp); @@ -319,27 +349,41 @@ const char *dump_state_watches(FILE *fp, struct conne= ction *conn, return ret; } =20 -void read_state_watch(const void *ctx, const void *state) +static void process_state_watch(const void *ctx, unsigned int conn_id, + const char *path, const char *token, + int depth) { - const struct xs_state_watch *sw =3D state; struct connection *conn; - const char *path, *token; bool relative; =20 - conn =3D get_connection_by_id(sw->conn_id); + conn =3D get_connection_by_id(conn_id); if (!conn) barf("connection not found for read watch"); =20 - path =3D (char *)sw->data; - token =3D path + sw->path_length; - /* Don't check success, we want the relative information only. */ check_watch_path(conn, ctx, &path, &relative); if (!path) barf("allocation error for read watch"); =20 - if (!add_watch(conn, path, token, relative, true)) + if (!add_watch(conn, path, token, depth, relative, true)) barf("error adding watch"); + +} + +void read_state_watch(const void *ctx, const void *state) +{ + const struct xs_state_watch *sw =3D state; + + process_state_watch(ctx, sw->conn_id, (char *)sw->data, + (char *)sw->data + sw->path_length, -1); +} + +void read_state_watch_ext(const void *ctx, const void *state) +{ + const struct xs_state_watch_ext *swe =3D state; + + process_state_watch(ctx, swe->conn_id, (char *)swe->data, + (char *)swe->data + swe->path_length, swe->depth); } =20 /* diff --git a/tools/xenstored/watch.h b/tools/xenstored/watch.h index d9ac6a334a..afdfdc6b2f 100644 --- a/tools/xenstored/watch.h +++ b/tools/xenstored/watch.h @@ -37,5 +37,6 @@ const char *dump_state_watches(FILE *fp, struct connectio= n *conn, unsigned int conn_id); =20 void read_state_watch(const void *ctx, const void *state); +void read_state_watch_ext(const void *ctx, const void *state); =20 #endif /* _XENSTORED_WATCH_H */ --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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; 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=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17733881207831000.7712990466556; Fri, 13 Mar 2026 00:48:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253364.1549659 (Exim 4.92) (envelope-from ) id 1w0xFu-0005Ba-Vr; Fri, 13 Mar 2026 07:48:22 +0000 Received: by outflank-mailman (output) from mailman id 1253364.1549659; Fri, 13 Mar 2026 07:48:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFu-0005Ah-No; Fri, 13 Mar 2026 07:48:22 +0000 Received: by outflank-mailman (input) for mailman id 1253364; Fri, 13 Mar 2026 07:48:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFt-0003TG-OP for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:21 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0192254f-1eb1-11f1-b164-2bf370ae4941; Fri, 13 Mar 2026 08:48:21 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id E69B94E3F0; Fri, 13 Mar 2026 07:48:20 +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 C5051403F6; Fri, 13 Mar 2026 07:48:20 +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 7LTxLkTBs2nAGAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:20 +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: 0192254f-1eb1-11f1-b164-2bf370ae4941 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 5/8] tools/xenstored: add depth handling to XS_WATCH Date: Fri, 13 Mar 2026 08:47:48 +0100 Message-ID: <20260313074751.2904215-6-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: E69B94E3F0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-ZM-MESSAGEID: 1773388122696158500 Content-Type: text/plain; charset="utf-8" In case XENSTORE_SERVER_FEATURE_WATCHDEPTH is set, allow XS_WATCH to have "depth" as 3rd parameter. Signed-off-by: Juergen Gross --- tools/xenstored/domain.c | 8 ++++++++ tools/xenstored/domain.h | 2 ++ tools/xenstored/watch.c | 11 +++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index ebeced3228..866c0aa908 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -387,6 +387,14 @@ void wrl_apply_debit_trans_commit(struct connection *c= onn) wrl_apply_debit_actual(conn->domain); } =20 +bool feature_available(const struct connection *conn, unsigned int feature) +{ + if (!conn->domain) + return XENSTORE_FEATURES & feature; + + return conn->domain->features & feature; +} + static unsigned int domain_get_soft_quota(struct domain *d, enum accitem w= hat) { if (d && d->acc[what].val[Q_IDX_SOFT] !=3D Q_VAL_DISABLED) diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h index 6a06b0d1af..15d8f1a5b2 100644 --- a/tools/xenstored/domain.h +++ b/tools/xenstored/domain.h @@ -192,4 +192,6 @@ struct hashtable *domain_check_acc_init(void); void domain_check_acc_add(const struct node *node, struct hashtable *domai= ns); void domain_check_acc(struct hashtable *domains); =20 +bool feature_available(const struct connection *conn, unsigned int feature= ); + #endif /* _XENSTORED_DOMAIN_H */ diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c index 3f1049911b..5de386370d 100644 --- a/tools/xenstored/watch.c +++ b/tools/xenstored/watch.c @@ -213,11 +213,18 @@ static struct watch *add_watch(struct connection *con= n, const char *path, int do_watch(const void *ctx, struct connection *conn, struct buffered_dat= a *in) { struct watch *watch; - const char *vec[2]; + const char *vec[3]; + unsigned int n_pars; int depth =3D -1; bool relative; =20 - if (get_strings(in, vec, ARRAY_SIZE(vec)) !=3D ARRAY_SIZE(vec)) + n_pars =3D get_strings(in, vec, ARRAY_SIZE(vec)); + if (n_pars =3D=3D 3 && + feature_available(conn, XENSTORE_SERVER_FEATURE_WATCHDEPTH)) { + depth =3D atoi(vec[2]); + if (depth < 0) + return EINVAL; + } else if (n_pars !=3D 2) return EINVAL; =20 errno =3D check_watch_path(conn, ctx, &(vec[0]), &relative); --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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=1773388128; cv=none; d=zohomail.com; s=zohoarc; b=Lk2kKJuQJ72RxJxVNug3cCfJia/xEkVeTwmyzjXIsZE/DrrWd+eZ9FslgnznA7VABvnPVY0xWAwIOlt325S3gT9YLd52EYIqn4EsTacY66/oHnKx5cBsNTnn/8BQ+/HgIXPSlrtpjhEWLVrRAPICctqd8jy9E3lc4rzRyiHylkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773388128; 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=h47Wy2/aIsr5uL9mIHAZhtR7cjBvlkykAr4Iab8gBlE=; b=BacY/3+JuTUKaEqSjd5RzuHnczcQd9Ji2e9OW4AYOr2rgv8NYK3V6kt0XHF591EgTeJLftiL5m9ARAAft5+NEhzbavrN04m5nvmgiWLxE7iKtFb1o4Qa8EVw05R9zAe+nwG+gOTZVp9t+QwpqxR9qrqPIzYFTFICokQ5zbSeK78= 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 1773388128103152.92228847788783; Fri, 13 Mar 2026 00:48:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253371.1549667 (Exim 4.92) (envelope-from ) id 1w0xG1-0005ZX-48; Fri, 13 Mar 2026 07:48:29 +0000 Received: by outflank-mailman (output) from mailman id 1253371.1549667; Fri, 13 Mar 2026 07:48:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xG1-0005ZK-15; Fri, 13 Mar 2026 07:48:29 +0000 Received: by outflank-mailman (input) for mailman id 1253371; Fri, 13 Mar 2026 07:48:27 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xFz-0003TG-Gi for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:27 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 04da738e-1eb1-11f1-b164-2bf370ae4941; Fri, 13 Mar 2026 08:48:26 +0100 (CET) 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-out1.suse.de (Postfix) with ESMTPS id 59CFD4D656; Fri, 13 Mar 2026 07:48:26 +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 3AB7C403F6; Fri, 13 Mar 2026 07:48:26 +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 ESM7DUrBs2nVGAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:26 +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: 04da738e-1eb1-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388106; 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=h47Wy2/aIsr5uL9mIHAZhtR7cjBvlkykAr4Iab8gBlE=; b=MhtAHwKXqc3JN+tOPK19oGJl6h4eekw1GpDYzkcQIdE2ZH4KisVZgAEtQ2MrZBfw4LwVIQ 7GyZRDsoT4nzTrjm+lE5OVyd/MxwogcENtORAlue2VlfHmq5OyN+X1AZIJoNcLTzZBO7Ak KUksYaJY6OFzhh7eA7lMX+jPtS4BJPM= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388106; 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=h47Wy2/aIsr5uL9mIHAZhtR7cjBvlkykAr4Iab8gBlE=; b=MhtAHwKXqc3JN+tOPK19oGJl6h4eekw1GpDYzkcQIdE2ZH4KisVZgAEtQ2MrZBfw4LwVIQ 7GyZRDsoT4nzTrjm+lE5OVyd/MxwogcENtORAlue2VlfHmq5OyN+X1AZIJoNcLTzZBO7Ak KUksYaJY6OFzhh7eA7lMX+jPtS4BJPM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 6/8] tools/xenstored: replace the fire_watches() exact parameter Date: Fri, 13 Mar 2026 08:47:49 +0100 Message-ID: <20260313074751.2904215-7-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773388128796158500 Content-Type: text/plain; charset="utf-8" Today fire_watches() has the boolean "exact" parameter specifying how the matching of the modified node with registered watches is to be handled (only the exact node name is matching or all nodes being in the subtree beneath the watched node). For the handling of / watch events 2 additional matching possibility needs to be added, as those events should only be delivered to clients having requested such events, either by watching with the depth=3D1 parameter, or by directly watching for /, while the traditional special watch events should NOT delivered to those watchers. For this purpose rename the "exact" parameter to "match" and make it an enum with four possible values. Signed-off-by: Juergen Gross --- tools/xenstored/core.c | 12 +++++----- tools/xenstored/transaction.c | 14 +++++++----- tools/xenstored/transaction.h | 4 +++- tools/xenstored/watch.c | 42 +++++++++++++++++++++++++---------- tools/xenstored/watch.h | 9 +++++++- 5 files changed, 55 insertions(+), 26 deletions(-) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index 09f1390f14..109e319f8c 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -1612,7 +1612,7 @@ static int do_write(const void *ctx, struct connectio= n *conn, return errno; } =20 - fire_watches(conn, ctx, name, node, false, NULL); + fire_watches(conn, ctx, name, node, MATCH_SUBTREE, NULL); send_ack(conn, XS_WRITE); =20 return 0; @@ -1636,7 +1636,7 @@ static int do_mkdir(const void *ctx, struct connectio= n *conn, node =3D create_node(conn, ctx, name, NULL, 0); if (!node) return errno; - fire_watches(conn, ctx, name, node, false, NULL); + fire_watches(conn, ctx, name, node, MATCH_SUBTREE, NULL); } send_ack(conn, XS_MKDIR); =20 @@ -1682,7 +1682,7 @@ static int delnode_sub(const void *ctx, struct connec= tion *conn, struct node *node, void *arg) { const char *root =3D arg; - bool watch_exact; + enum watch_match watch_match; int ret; const char *db_name; =20 @@ -1702,8 +1702,8 @@ static int delnode_sub(const void *ctx, struct connec= tion *conn, * This fine as we are single threaded and the next possible read will * be handled only after the node has been really removed. */ - watch_exact =3D strcmp(root, node->name); - fire_watches(conn, ctx, node->name, node, watch_exact, NULL); + watch_match =3D strcmp(root, node->name) ? MATCH_EXACT : MATCH_SUBTREE; + fire_watches(conn, ctx, node->name, node, watch_match, NULL); =20 return WALK_TREE_RM_CHILDENTRY; } @@ -1857,7 +1857,7 @@ static int do_set_perms(const void *ctx, struct conne= ction *conn, if (write_node(conn, node, NODE_MODIFY, false)) return errno; =20 - fire_watches(conn, ctx, name, node, false, &old_perms); + fire_watches(conn, ctx, name, node, MATCH_SUBTREE, &old_perms); send_ack(conn, XS_SET_PERMS); =20 return 0; diff --git a/tools/xenstored/transaction.c b/tools/xenstored/transaction.c index ccf93a1132..7e15aa8a2c 100644 --- a/tools/xenstored/transaction.c +++ b/tools/xenstored/transaction.c @@ -134,7 +134,7 @@ struct accessed_node =20 /* Watch event flags. */ bool fire_watch; - bool watch_exact; + enum watch_match watch_match; }; =20 struct transaction @@ -327,8 +327,10 @@ err: * A watch event should be fired for a node modified inside a transaction. * Set the corresponding information. A non-exact event is replacing an ex= act * one, but not the other way round. + * No special watch handling needed here, so MATCH_DEPTH is no issue. */ -void queue_watches(struct connection *conn, const char *name, bool watch_e= xact) +void queue_watches(struct connection *conn, const char *name, + enum watch_match watch_match) { struct accessed_node *i; =20 @@ -340,9 +342,9 @@ void queue_watches(struct connection *conn, const char = *name, bool watch_exact) =20 if (!i->fire_watch) { i->fire_watch =3D true; - i->watch_exact =3D watch_exact; - } else if (!watch_exact) { - i->watch_exact =3D false; + i->watch_match =3D watch_match; + } else if (watch_match =3D=3D MATCH_SUBTREE) { + i->watch_match =3D MATCH_SUBTREE; } } =20 @@ -419,7 +421,7 @@ static int finalize_transaction(struct connection *conn, db_delete(conn, i->node, NULL); } if (i->fire_watch) - fire_watches(conn, trans, i->node, NULL, i->watch_exact, + fire_watches(conn, trans, i->node, NULL, i->watch_match, i->perms.p ? &i->perms : NULL); =20 list_del(&i->list); diff --git a/tools/xenstored/transaction.h b/tools/xenstored/transaction.h index 90435b4fc9..b4f5f757e2 100644 --- a/tools/xenstored/transaction.h +++ b/tools/xenstored/transaction.h @@ -18,6 +18,7 @@ #ifndef _XENSTORED_TRANSACTION_H #define _XENSTORED_TRANSACTION_H #include "core.h" +#include "watch.h" =20 enum node_access_type { NODE_ACCESS_READ, @@ -44,7 +45,8 @@ int __must_check access_node(struct connection *conn, str= uct node *node, enum node_access_type type, const char **db_n= ame); =20 /* Queue watches for a modified node. */ -void queue_watches(struct connection *conn, const char *name, bool watch_e= xact); +void queue_watches(struct connection *conn, const char *name, + enum watch_match watch_match); =20 /* Prepend the transaction to name if appropriate. */ const char *transaction_prepend(struct connection *conn, const char *name); diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c index 5de386370d..342b283285 100644 --- a/tools/xenstored/watch.c +++ b/tools/xenstored/watch.c @@ -128,7 +128,8 @@ static bool watch_permitted(struct connection *conn, co= nst void *ctx, * watch event, too. */ void fire_watches(struct connection *conn, const void *ctx, const char *na= me, - const struct node *node, bool exact, struct node_perms *perms) + const struct node *node, enum watch_match match, + struct node_perms *perms) { struct connection *i; struct buffered_data *req; @@ -136,7 +137,7 @@ void fire_watches(struct connection *conn, const void *= ctx, const char *name, =20 /* During transactions, don't fire watches, but queue them. */ if (conn && conn->transaction) { - queue_watches(conn, name, exact); + queue_watches(conn, name, match); return; } =20 @@ -148,17 +149,34 @@ void fire_watches(struct connection *conn, const void= *ctx, const char *name, continue; =20 list_for_each_entry(watch, &i->watches, list) { - if (exact) { - if (streq(name, watch->node)) - send_event(req, i, - get_watch_path(watch, name), - watch->token); - } else { - if (is_child(name, watch->node, watch->depth)) - send_event(req, i, - get_watch_path(watch, name), - watch->token); + bool send =3D false; + + switch (match) { + case MATCH_EXACT: + send =3D streq(name, watch->node); + break; + + case MATCH_SUBTREE: + send =3D is_child(name, watch->node, + watch->depth); + break; + + case MATCH_DEPTH: + send =3D streq(name, watch->node) || + (watch->depth > 0 && + is_child(name, watch->node, + watch->depth)); + break; + + case MATCH_NODEPTH: + send =3D streq(name, watch->node) && + watch->depth < 0; + break; } + + if (send) + send_event(req, i, get_watch_path(watch, name), + watch->token); } } } diff --git a/tools/xenstored/watch.h b/tools/xenstored/watch.h index afdfdc6b2f..692343389f 100644 --- a/tools/xenstored/watch.h +++ b/tools/xenstored/watch.h @@ -27,8 +27,15 @@ int do_unwatch(const void *ctx, struct connection *conn, struct buffered_data *in); =20 /* Fire all watches: !exact means all the children are affected (ie. rm). = */ +enum watch_match { + MATCH_EXACT, + MATCH_SUBTREE, + MATCH_DEPTH, /* watches with depth > 0, MATCH_SUBTREE semantics */ + MATCH_NODEPTH /* watches with no depth, MATCH_EXACT semantics */ +}; + void fire_watches(struct connection *conn, const void *tmp, const char *na= me, - const struct node *node, bool exact, + const struct node *node, enum watch_match match, struct node_perms *perms); =20 void conn_delete_all_watches(struct connection *conn); --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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=1773388138; cv=none; d=zohomail.com; s=zohoarc; b=lljphT+R50XUJ2ke8Te2J1Lu2DEViNsV1epLQKko4CrvrUDolMbhCxxehm39mJiakfnXAjcDRL1BNNZFdDKqjM600ALsmaQHRUM+wG5RWq+WUGQnO+CDXIXzG4DSagWXAHPwvv/nyZzH40pzetxztMB1p/5BbsHmnlfNvkzYY0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773388138; 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=Wtc5vtg54h365QFdm8hm6MolP6XIgjTyDkWMll2qEbc=; b=D41EulaqWa59A0UG+K+w2OYzCK6G4WroX5Cbr9Yuqx1x6FKJxAmnDSmC/bvgumjtEvhd+UkD5twLqYJv3jjrV7jRsWNxlnUM4+KgfZKXiy0ivoW/ZUpHan6QNNFUIaLEv5/QgeROC13sITdoq6EDe2DFuw/d9NXazk/nx7MjRqM= 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 1773388138661204.79808104914503; Fri, 13 Mar 2026 00:48:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253379.1549676 (Exim 4.92) (envelope-from ) id 1w0xG7-000675-B4; Fri, 13 Mar 2026 07:48:35 +0000 Received: by outflank-mailman (output) from mailman id 1253379.1549676; Fri, 13 Mar 2026 07:48:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xG7-00066v-7A; Fri, 13 Mar 2026 07:48:35 +0000 Received: by outflank-mailman (input) for mailman id 1253379; Fri, 13 Mar 2026 07:48:33 +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 1w0xG5-0003h2-Mc for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:33 +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 081c0d37-1eb1-11f1-9ccf-f158ae23cfc8; Fri, 13 Mar 2026 08:48:32 +0100 (CET) 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 C46755CF3A; Fri, 13 Mar 2026 07:48:31 +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 A3F84403F6; Fri, 13 Mar 2026 07:48:31 +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 jozfJk/Bs2nxGAAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48:31 +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: 081c0d37-1eb1-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388111; 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=Wtc5vtg54h365QFdm8hm6MolP6XIgjTyDkWMll2qEbc=; b=IFXiqIDBBFWrVLnDa2TDp0llCHTngEsRKlAA6/8Goi95/zxhfJW0wSvjmYPXIp5XYeH4ya 6IF+YyI2lywmpGm/crQt+24oJBhu4IaP6cNtClfIKibfr/XbV7ohmzD+BsywkdEGjPZWfL uCcRGjbycsgRz9o9i/CSmI+ae4yUhII= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388111; 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=Wtc5vtg54h365QFdm8hm6MolP6XIgjTyDkWMll2qEbc=; b=IFXiqIDBBFWrVLnDa2TDp0llCHTngEsRKlAA6/8Goi95/zxhfJW0wSvjmYPXIp5XYeH4ya 6IF+YyI2lywmpGm/crQt+24oJBhu4IaP6cNtClfIKibfr/XbV7ohmzD+BsywkdEGjPZWfL uCcRGjbycsgRz9o9i/CSmI+ae4yUhII= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 7/8] tools/xenstored: expand special watch handling with depth feature Date: Fri, 13 Mar 2026 08:47:50 +0100 Message-ID: <20260313074751.2904215-8-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773388140780158500 Content-Type: text/plain; charset="utf-8" With XENSTORE_SERVER_FEATURE_WATCHDEPTH available, special watch handling needs to be extended: - when a special watch is set with depth =3D 1, the domid is added to the watch event - it is possible to watch for @releaseDomain/ Signed-off-by: Juergen Gross --- tools/xenstored/domain.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 866c0aa908..1fe8abbea9 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -613,7 +613,12 @@ static void domain_tree_remove(struct domain *domain) walk_node_tree(domain, NULL, "@introduceDomain", &walkfuncs, domain); } =20 -static void fire_special_watches(const char *name) +#define WATCH_NODOM 1 /* Fire watches without extension. */ +#define WATCH_DOM 2 /* Fire watches with extension. */ +#define WATCH_BOTH (WATCH_NODOM | WATCH_DOM) + +static void fire_special_watches(const char *name, unsigned int domid, + unsigned int watchdom_flag) { void *ctx =3D talloc_new(NULL); const struct node *node; @@ -623,9 +628,19 @@ static void fire_special_watches(const char *name) =20 node =3D read_node_const(NULL, ctx, name); =20 - if (node) - fire_watches(NULL, ctx, name, node, true, NULL); - else + if (node) { + if (watchdom_flag & WATCH_NODOM) + fire_watches(NULL, ctx, name, node, MATCH_NODEPTH, + NULL); + if (watchdom_flag & WATCH_DOM) { + char name_dom[24]; /* max. "@introduceDomain/domid" */ + + snprintf(name_dom, sizeof(name_dom), + "%s/%u", name, domid); + fire_watches(NULL, ctx, name_dom, node, MATCH_DEPTH, + NULL); + } + } else log("special node %s not found\n", name); =20 talloc_free(ctx); @@ -650,7 +665,7 @@ static int destroy_domain(void *_domain) if (domain->interface) unmap_interface(domain->domid, domain->interface); =20 - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", domain->domid, WATCH_BOTH); =20 wrl_domain_destroy(domain); =20 @@ -678,10 +693,13 @@ static int do_check_domain(struct domain *domain, boo= l *notify, if ((state & XENMANAGE_GETDOMSTATE_STATE_SHUTDOWN) && !domain->shutdown) { domain->shutdown =3D true; + fire_special_watches("@releaseDomain", domain->domid, + WATCH_DOM); *notify =3D true; } - if (!(state & XENMANAGE_GETDOMSTATE_STATE_DEAD)) + if (!(state & XENMANAGE_GETDOMSTATE_STATE_DEAD)) { return 0; + } } if (domain->conn) { /* domain is a talloc child of domain->conn. */ @@ -720,7 +738,7 @@ void check_domains(void) ; =20 if (notify) - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", 0, WATCH_NODOM); } =20 static struct domain *find_domain_struct(unsigned int domid) @@ -744,7 +762,7 @@ static void do_check_domains(void) } =20 if (notify) - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", 0, WATCH_NODOM); } =20 /* We scan all domains rather than use the information given here. */ @@ -1097,7 +1115,8 @@ static struct domain *introduce_domain(const void *ct= x, talloc_steal(domain->conn, domain); =20 if (!is_priv_domain && !restore) - fire_special_watches("@introduceDomain"); + fire_special_watches("@introduceDomain", domid, + WATCH_BOTH); } else { /* Use XS_INTRODUCE for recreating the xenbus event-channel. */ if (domain->port) --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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=1773388717; cv=none; d=zohomail.com; s=zohoarc; b=CC5R5u6StbCYD1Tqq+xrLvH+An069EVNEU+/i2d+c9H1BqpW+uQW7J7pdHOrczMpYdDwTMI7AHXo7/ndVEu4nKbKln8Ww/rhoULGinjmUaISmd3pauMhlz+xdeY94l4LPJkGeRuVjSlOsLGCOSWh2m5RcCB91HfgBsYXM729vuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773388717; 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=yQy01lSorBeCu75rYkVAGdbd34BdLsmg0CaWqBI6wwU=; b=NAc+MF68rq7OPK4lngDHDb2OWY3p7Xt7Jz/6xYcA7HuMIoA4U8s25r7XizI6Cb1uK7rW2ok6hj4EiZvSDPz3bOvjQQ/7tLjSRph6J2exxS9ctECj69HelCdUMysBHP/sl3/OOM8NOk6/IW+S0/WLnnlJxGb8yvEjgAcZx6TMF7M= 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 1773388717086404.5436921575549; Fri, 13 Mar 2026 00:58:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1253419.1549686 (Exim 4.92) (envelope-from ) id 1w0xPT-0000TD-Cr; Fri, 13 Mar 2026 07:58:15 +0000 Received: by outflank-mailman (output) from mailman id 1253419.1549686; Fri, 13 Mar 2026 07:58:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xPT-0000T6-8i; Fri, 13 Mar 2026 07:58:15 +0000 Received: by outflank-mailman (input) for mailman id 1253419; Fri, 13 Mar 2026 07:58:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w0xGB-0003TG-If for xen-devel@lists.xenproject.org; Fri, 13 Mar 2026 07:48:39 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0b5917f6-1eb1-11f1-b164-2bf370ae4941; Fri, 13 Mar 2026 08:48:37 +0100 (CET) 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 43F825CF3C; Fri, 13 Mar 2026 07:48: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 1AD62403F6; Fri, 13 Mar 2026 07:48: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 ppJ+BVXBs2k1GQAAD6G6ig (envelope-from ); Fri, 13 Mar 2026 07:48: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: 0b5917f6-1eb1-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388117; 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=yQy01lSorBeCu75rYkVAGdbd34BdLsmg0CaWqBI6wwU=; b=WAhxk8oYy6gXZ9sygI9gnvp/GZUEehkI3dIR1RA84eQnixk7QKXRsPC3ZI7CNRt+ywvdxg JBPjvp/cfbVAy2H+Bv5+ItFrO8Kt90uXE1/tr9ULU5MgT/JNCHwcPs99z0mE5q8lPiU0Nb SWoPcVXUSXyOpaOQWnpIbmgJ6PeTGrs= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773388117; 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=yQy01lSorBeCu75rYkVAGdbd34BdLsmg0CaWqBI6wwU=; b=WAhxk8oYy6gXZ9sygI9gnvp/GZUEehkI3dIR1RA84eQnixk7QKXRsPC3ZI7CNRt+ywvdxg JBPjvp/cfbVAy2H+Bv5+ItFrO8Kt90uXE1/tr9ULU5MgT/JNCHwcPs99z0mE5q8lPiU0Nb SWoPcVXUSXyOpaOQWnpIbmgJ6PeTGrs= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 8/8] tools/xenstored: make XENSTORE_SERVER_FEATURE_WATCHDEPTH available Date: Fri, 13 Mar 2026 08:47:51 +0100 Message-ID: <20260313074751.2904215-9-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.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)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[4]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773388719482158500 Content-Type: text/plain; charset="utf-8" Add XENSTORE_SERVER_FEATURE_WATCHDEPTH to the available features now that all needed support has been added. Signed-off-by: Juergen Gross --- tools/xenstored/domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 1fe8abbea9..d02ac247c5 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -43,7 +43,8 @@ #include #endif =20 -#define XENSTORE_FEATURES XENSTORE_SERVER_FEATURE_ERROR +#define XENSTORE_FEATURES (XENSTORE_SERVER_FEATURE_ERROR | \ + XENSTORE_SERVER_FEATURE_WATCHDEPTH) =20 static xenmanage_handle *xm_handle; xengnttab_handle **xgt_handle; --=20 2.53.0 From nobody Mon Mar 23 19:58:08 2026 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=1773932824; cv=none; d=zohomail.com; s=zohoarc; b=QEcZ4H4AhJcAi2ffcyID6x7hGMupMtn4cJZtV0iKEXymNQPyz8E7OpVBcBu2CnCL6lgImA4XDmivZ6sTq/8dIoc4H3WxjprEUt1yVPpIhp/aLVxIZ7heF6of7DgMdJmioq+TJYvWiXUVU0Jlz7RY2Sgp152ZrEnhDxWCFT0NJ4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773932824; 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=igSCQ4R7W3BM61Lrna0U8D/RNVuugNOT+EHqmQFTBoc=; b=FiyABR4xuREzi+2XzgS9WAhvoGwerXLrSgliP94p2WkDFfJ21CjvNn7CZq/pKfXtvHQXJMpC2rG3hy5afQD/eaDWYMDIz2aSn+7HaIFer0VMmDv6FWWqQ3pd/UPoOH/oxWMcUA9fBjsZ9NcejsNFLVOXuNbPeu23/s77aYQCA1g= 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 1773932824178664.4275122440715; Thu, 19 Mar 2026 08:07:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1257292.1551711 (Exim 4.92) (envelope-from ) id 1w3ExL-0003IJ-R9; Thu, 19 Mar 2026 15:06:39 +0000 Received: by outflank-mailman (output) from mailman id 1257292.1551711; Thu, 19 Mar 2026 15:06:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3ExL-0003IC-OG; Thu, 19 Mar 2026 15:06:39 +0000 Received: by outflank-mailman (input) for mailman id 1257292; Thu, 19 Mar 2026 15:06:39 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w3ExK-0003I6-Tk for xen-devel@lists.xenproject.org; Thu, 19 Mar 2026 15:06:39 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3a0b8fbe-23a5-11f1-b164-2bf370ae4941; Thu, 19 Mar 2026 16:06:37 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 0C7295BDB7; Thu, 19 Mar 2026 15: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 E0E124273B; Thu, 19 Mar 2026 15:06:36 +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 n6+sNfwQvGlTIAAAD6G6ig (envelope-from ); Thu, 19 Mar 2026 15:06:36 +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: 3a0b8fbe-23a5-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773932797; 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=igSCQ4R7W3BM61Lrna0U8D/RNVuugNOT+EHqmQFTBoc=; b=sYrczV8iG+iM9wjce9AeFVYPvSIjtxxk8A1Hezmi2ituXo0aQYRQYqk2juKLknJXI2zHxX 9gbH7iCCYotK7y+Mnoy5u8btnat0WsZf/D/6zjcRh4YVi6ks8OsFh0JcS3BSLbSKcas1PD cVWoCLzH+QzA7DH7H8GNjMnhjKQEVVA= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=sYrczV8i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1773932797; 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=igSCQ4R7W3BM61Lrna0U8D/RNVuugNOT+EHqmQFTBoc=; b=sYrczV8iG+iM9wjce9AeFVYPvSIjtxxk8A1Hezmi2ituXo0aQYRQYqk2juKLknJXI2zHxX 9gbH7iCCYotK7y+Mnoy5u8btnat0WsZf/D/6zjcRh4YVi6ks8OsFh0JcS3BSLbSKcas1PD cVWoCLzH+QzA7DH7H8GNjMnhjKQEVVA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 9/8] tools/xs-clients: support depth with xenstore-watch Date: Thu, 19 Mar 2026 16:06:23 +0100 Message-ID: <20260319150626.436719-1-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313074751.2904215-1-jgross@suse.com> References: <20260313074751.2904215-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:dkim,suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Queue-Id: 0C7295BDB7 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1773932826177158500 Content-Type: text/plain; charset="utf-8" Add a "-d " parameter to xenstore-watch, allowing to specify the depth parameter of the XS_WATCH command. Using "-d" without support of depth by xenstored will refuse to set the watch(es). Signed-off-by: Juergen Gross --- tools/xs-clients/xenstore_client.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/xs-clients/xenstore_client.c b/tools/xs-clients/xenstore= _client.c index 9a25704b91..4a14cb334f 100644 --- a/tools/xs-clients/xenstore_client.c +++ b/tools/xs-clients/xenstore_client.c @@ -445,7 +445,7 @@ do_watch(struct xs_handle *xsh, int max_events) static int perform(enum mode mode, int optind, int argc, char **argv, struct xs_handl= e *xsh, xs_transaction_t xth, int prefix, int tidy, int upto, int recurse,= int nr_watches, - int raw) + int raw, int depth) { switch (mode) { case MODE_ls: @@ -627,8 +627,11 @@ perform(enum mode mode, int optind, int argc, char **a= rgv, struct xs_handle *xsh for (; argv[optind]; optind++) { const char *w =3D argv[optind]; =20 - if (!xs_watch(xsh, w, w)) + if (depth < 0 && !xs_watch(xsh, w, w)) errx(1, "Unable to add watch on %s\n", w); + if (depth >=3D 0 && !xs_watch_depth(xsh, w, w, depth)) + errx(1, "Unable to add watch on %s with depth %d\n", w, + depth); } do_watch(xsh, nr_watches); } @@ -676,6 +679,7 @@ main(int argc, char **argv) int nr_watches =3D -1; int transaction; int raw =3D 0; + int depth =3D -1; struct winsize ws; enum mode mode; =20 @@ -709,10 +713,11 @@ main(int argc, char **argv) {"recurse", 0, 0, 'r'}, /* MODE_chmod */ {"number", 1, 0, 'n'}, /* MODE_watch */ {"raw", 0, 0, 'R'}, /* MODE_read || MODE_write */ + {"depth", 1, 0, 'd'}, /* MODE_watch */ {0, 0, 0, 0} }; =20 - c =3D getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:R", + c =3D getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:Rd:", long_options, &index); if (c =3D=3D -1) break; @@ -766,6 +771,12 @@ main(int argc, char **argv) else usage(1, mode, switch_argv, argv[0]); break; + case 'd': + if ( mode =3D=3D MODE_watch ) + depth =3D atoi(optarg); + else + usage(1, mode, switch_argv, argv[0]); + break; } } =20 @@ -819,7 +830,7 @@ again: errx(1, "couldn't start transaction"); } =20 - ret =3D perform(mode, optind, argc - switch_argv, argv + switch_argv, = xsh, xth, prefix, tidy, upto, recurse, nr_watches, raw); + ret =3D perform(mode, optind, argc - switch_argv, argv + switch_argv, = xsh, xth, prefix, tidy, upto, recurse, nr_watches, raw, depth); =20 if (transaction && !xs_transaction_end(xsh, xth, ret)) { if (ret =3D=3D 0 && errno =3D=3D EAGAIN) { --=20 2.53.0