Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12D8CF327B9 for ; Tue, 21 Apr 2026 07:43:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1288455.1568754 (Exim 4.92) (envelope-from ) id 1wF5l1-0005T9-4h; Tue, 21 Apr 2026 07:42:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1288455.1568754; Tue, 21 Apr 2026 07:42:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wF5l0-0005Sy-Uy; Tue, 21 Apr 2026 07:42:54 +0000 Received: by outflank-mailman (input) for mailman id 1288455; Tue, 21 Apr 2026 07:42:53 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wF5kz-0005Nr-OI for xen-devel@lists.xenproject.org; Tue, 21 Apr 2026 07:42:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wF5kz-00G0my-4i for xen-devel@lists.xenproject.org; Tue, 21 Apr 2026 09:42:53 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e72a79-bab6-0a2a0a5309dd-0a2a450a8036-26 for ; Tue, 21 Apr 2026 09:42:53 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69e72a7c-56b3-0a2a450a0019-c387df839c2e-3 for ; Tue, 21 Apr 2026 09:42:53 +0200 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 ADC425BCE1; Tue, 21 Apr 2026 07:42:52 +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 892C0593AF; Tue, 21 Apr 2026 07:42:52 +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 hTRXIHwq52kwNwAAD6G6ig (envelope-from ); Tue, 21 Apr 2026 07:42:52 +0000 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1776757372; 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=H4xDwurhkvE0j1k8kqAZ1un0445rmmWmoyaVKvtmHfs=; b=dKdo7mVNbb2833HOzBH8ax9gOs1Nfz18pBlDL0RE+ngF+aWCzA6q6+EgKEM+onCdc5Gh1u nD8I7lGjymPFmGZD6hFZCFYGBCQOwzgS79/CvfEJRTXCXwSIaE2MYgQItIAV0/cCwGgVeG aKubo8f7B28haR3P6H9biqznReHI/rA= Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=dKdo7mVN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1776757372; 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=H4xDwurhkvE0j1k8kqAZ1un0445rmmWmoyaVKvtmHfs=; b=dKdo7mVNbb2833HOzBH8ax9gOs1Nfz18pBlDL0RE+ngF+aWCzA6q6+EgKEM+onCdc5Gh1u nD8I7lGjymPFmGZD6hFZCFYGBCQOwzgS79/CvfEJRTXCXwSIaE2MYgQItIAV0/cCwGgVeG aKubo8f7B28haR3P6H9biqznReHI/rA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD , Jason Andryuk Subject: [PATCH v2 7/9] tools/xenstored: expand special watch handling with depth feature Date: Tue, 21 Apr 2026 09:42:09 +0200 Message-ID: <20260421074211.308473-8-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421074211.308473-1-jgross@suse.com> References: <20260421074211.308473-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.01 / 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)[]; 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:mid,suse.com:dkim,suse.com:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,amd.com:email]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: ADC425BCE1 X-purgate-ID: tlsNG-4011c0/1776757373-44B678B7-D19C34A6/0/0 X-purgate-type: clean X-purgate-size: 3484 With XENSTORE_SERVER_FEATURE_WATCHDEPTH available, special watch handling needs to be extended: - when a special watch is set with depth = 1, the domid is added to the watch event - it is possible to watch for @releaseDomain/ Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- V2: - remove stray {} addition (Jason Andryuk) --- tools/xenstored/domain.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 7f2fa16cf2..a5258dae6d 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -616,7 +616,12 @@ static void domain_tree_remove(struct domain *domain) walk_node_tree(domain, NULL, "@introduceDomain", &walkfuncs, domain); } -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 = talloc_new(NULL); const struct node *node; @@ -626,9 +631,19 @@ static void fire_special_watches(const char *name) node = read_node_const(NULL, ctx, name); - 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); talloc_free(ctx); @@ -653,7 +668,7 @@ static int destroy_domain(void *_domain) if (domain->interface) unmap_interface(domain->domid, domain->interface); - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", domain->domid, WATCH_BOTH); wrl_domain_destroy(domain); @@ -681,6 +696,8 @@ static int do_check_domain(struct domain *domain, bool *notify, if ((state & XENMANAGE_GETDOMSTATE_STATE_SHUTDOWN) && !domain->shutdown) { domain->shutdown = true; + fire_special_watches("@releaseDomain", domain->domid, + WATCH_DOM); *notify = true; } if (!(state & XENMANAGE_GETDOMSTATE_STATE_DEAD)) @@ -723,7 +740,7 @@ void check_domains(void) ; if (notify) - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", 0, WATCH_NODOM); } static struct domain *find_domain_struct(unsigned int domid) @@ -747,7 +764,7 @@ static void do_check_domains(void) } if (notify) - fire_special_watches("@releaseDomain"); + fire_special_watches("@releaseDomain", 0, WATCH_NODOM); } /* We scan all domains rather than use the information given here. */ @@ -1112,7 +1129,8 @@ static struct domain *introduce_domain(const void *ctx, talloc_steal(domain->conn, domain); 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) -- 2.53.0