From nobody Thu Oct 30 23:12:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1753951406; cv=none; d=zohomail.com; s=zohoarc; b=l+rlUpPD0MQV257SPZEMyijX+qYTdBjFZ6YlsvZp8Y5Z/+epVVyvFT6Xzibce4eLJaXQ3D+j4ADeNWv02+6xf+fJzPmWHoHh7100KUkVyPU0oSAs6DOmj3owr+2bsjBesw4XCvMsO1psGKTNWoMDMwfwS+f0jdb2tgtw0ucGYKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753951406; 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=zxuwVWDlLAnmbyEtprz8FF0BaKxPp4KdchOH5r/IcTY=; b=iuTOUX/3JSZb15alhJVXLtnLl8Gq1JEtl2D7k8Wm9fFn8gtckkOi1Covg5ue0O287c4xrtwgya7lisih8QXEP6b8V7T5jFAMjnZOMP4RsQ2PSdKwdXbvvpTG2Y1CNdV33pZ6x/jtw2iVxWzbAXFr4vWJ4d8ORZy7hNBPdmJyesE= 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 1753951406822453.93833149730744; Thu, 31 Jul 2025 01:43:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1065075.1430410 (Exim 4.92) (envelope-from ) id 1uhOsc-000721-Lb; Thu, 31 Jul 2025 08:43:14 +0000 Received: by outflank-mailman (output) from mailman id 1065075.1430410; Thu, 31 Jul 2025 08:43:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uhOsc-00071s-IB; Thu, 31 Jul 2025 08:43:14 +0000 Received: by outflank-mailman (input) for mailman id 1065075; Thu, 31 Jul 2025 08:43:13 +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 1uhOsb-0006gC-IT for xen-devel@lists.xenproject.org; Thu, 31 Jul 2025 08:43:13 +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 6252bb66-6dea-11f0-b895-0df219b8e170; Thu, 31 Jul 2025 10:43:08 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5A48F2119C; Thu, 31 Jul 2025 08:43:08 +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 17DE113AB4; Thu, 31 Jul 2025 08:43:08 +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 vH8tBJwsi2jSDAAAD6G6ig (envelope-from ); Thu, 31 Jul 2025 08:43:08 +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: 6252bb66-6dea-11f0-b895-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753951388; 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=zxuwVWDlLAnmbyEtprz8FF0BaKxPp4KdchOH5r/IcTY=; b=sj7yfkFSCaBJrOF4UL5JYZhj4Dla0iBu285uV4/Y6SHsauZBp+zeWbwm3jG+1QndebtrUI dYDpqAA/IaT69gr3Bq3pjcy2hAs5u4z3cBpyr//bV7kPCAWP8Ikh4r3jWf0MiNP7xvfUjz xi162V1AE+9j+d+VVlGAD6wZtBNB1Kw= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1753951388; 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=zxuwVWDlLAnmbyEtprz8FF0BaKxPp4KdchOH5r/IcTY=; b=sj7yfkFSCaBJrOF4UL5JYZhj4Dla0iBu285uV4/Y6SHsauZBp+zeWbwm3jG+1QndebtrUI dYDpqAA/IaT69gr3Bq3pjcy2hAs5u4z3cBpyr//bV7kPCAWP8Ikh4r3jWf0MiNP7xvfUjz xi162V1AE+9j+d+VVlGAD6wZtBNB1Kw= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD , Nick Rosbrook , George Dunlap , Jason Andryuk Subject: [PATCH v3 2/2] tools: allow to limit xenstore features via guest config Date: Thu, 31 Jul 2025 10:42:54 +0200 Message-ID: <20250731084254.25591-3-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250731084254.25591-1-jgross@suse.com> References: <20250731084254.25591-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,amd.com:email,suse.com:mid,suse.com:email]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-Spam-Score: -2.80 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1753951407571116600 Content-Type: text/plain; charset="utf-8" Add a guest config parameter "xenstore_feature_mask" allowing to limit the Xenstore features the guest can see and use. This can be needed in order to allow migrating a guest to a host running a Xenstore version providing less features than the source host. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Acked-by: Nick Rosbrook # tools/golang Reviewed-by: Anthony PERARD --- V2: - fix typo (Jason Andryuk) V3: - use LOGED for error logging (Anthony Perard) - don't leak vm_path in case of error (Anthony Perard) --- docs/man/xl.cfg.5.pod.in | 36 ++++++++++++++++++++++++++++ tools/golang/xenlight/helpers.gen.go | 2 ++ tools/golang/xenlight/types.gen.go | 1 + tools/include/libxl.h | 6 +++++ tools/libs/light/libxl_dom.c | 17 ++++++++++++- tools/libs/light/libxl_types.idl | 1 + tools/xl/xl_parse.c | 3 +++ 7 files changed, 65 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 5362fb0e9a..f0c920b39d 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -714,6 +714,42 @@ If this option is not specified then it will default t= o B. =20 =3Dback =20 +=3Dhead3 Xenstore related settings + +=3Dover 4 + +=3Ditem B + +Specify which Xenstore features are visible for the guest. + +This might be needed when a guest should be able to be migrated to a host +running a Xenstore implementation with less features than the one the guest +is created on. + +The visible features are specified via a binary or of the following +values: + +=3Dover 4 + +=3Ditem B<0x00000001> + +Xenstore is capable to reconnect to a guest. + +=3Ditem B<0x00000002> + +Xenstore will present an error value in case it disconnects due to an error +condition. + +=3Dback + +The features supported by the running Xenstore instance can be retrieved +via the B command in dom0. + +The default value is B<0xffffffff>, meaning that all possible Xenstore +features are visible by the guest. + +=3Dback + =3Dhead2 Devices =20 The following options define the paravirtual, emulated and physical diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index b43aad7d00..667030cbd7 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -1175,6 +1175,7 @@ return fmt.Errorf("converting field Vpmu: %v", err) if err :=3D x.TrapUnmappedAccesses.fromC(&xc.trap_unmapped_accesses);err != =3D nil { return fmt.Errorf("converting field TrapUnmappedAccesses: %v", err) } +x.XenstoreFeatureMask =3D uint32(xc.xenstore_feature_mask) =20 return nil} =20 @@ -1710,6 +1711,7 @@ return fmt.Errorf("converting field Vpmu: %v", err) if err :=3D x.TrapUnmappedAccesses.toC(&xc.trap_unmapped_accesses); err != =3D nil { return fmt.Errorf("converting field TrapUnmappedAccesses: %v", err) } +xc.xenstore_feature_mask =3D C.uint32_t(x.XenstoreFeatureMask) =20 return nil } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 4777f528b5..e26b3cdfc7 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -608,6 +608,7 @@ Altp2MCount uint32 VmtraceBufKb int Vpmu Defbool TrapUnmappedAccesses Defbool +XenstoreFeatureMask uint32 } =20 type DomainBuildInfoTypeUnion interface { diff --git a/tools/include/libxl.h b/tools/include/libxl.h index d6b6e5d2dd..185f74d8a8 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -654,6 +654,12 @@ */ #define LIBXL_HAVE_DT_OVERLAY_DOMAIN 1 =20 +/* + * LIBXL_HAVE_XENSTORE_FEATURE_MASK indicates the presence of + * xenstore_feature_mask in struct libxl_domain_build_info. + */ +#define LIBXL_HAVE_XENSTORE_FEATURE_MASK 1 + /* * libxl memory management * diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c index a61085ca3b..05ebc69534 100644 --- a/tools/libs/light/libxl_dom.c +++ b/tools/libs/light/libxl_dom.c @@ -494,9 +494,24 @@ retry_transaction: if (!xs_transaction_end(ctx->xsh, t, 0)) if (errno =3D=3D EAGAIN) goto retry_transaction; + + if (info->xenstore_feature_mask !=3D ~0U) { + unsigned int features; + + if (xs_get_features_supported(ctx->xsh, &features) && + !xs_set_features_domain(ctx->xsh, domid, + features & info->xenstore_feature_mask= )) { + LOGED(ERROR, domid, "Failed to set Xenstore features"); + rc =3D ERROR_FAIL; + goto out; + } + } + xs_introduce_domain(ctx->xsh, domid, state->store_mfn, state->store_po= rt); + + out: free(vm_path); - return 0; + return rc; } =20 static int set_vnuma_info(libxl__gc *gc, uint32_t domid, diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index fe251649f3..a6030a2dbd 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -739,6 +739,7 @@ libxl_domain_build_info =3D Struct("domain_build_info",[ =20 ("vpmu", libxl_defbool), ("trap_unmapped_accesses", libxl_defbool), + ("xenstore_feature_mask", uint32, {'init_val': '~0U'}), =20 ], dir=3DDIR_IN, copy_deprecated_fn=3D"libxl__domain_build_info_copy_deprecated", diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 28cdbf07c2..90c9386f5b 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1409,6 +1409,9 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_string (config, "pool", &buf, 0)) xlu_cfg_replace_string(config, "pool", &c_info->pool_name, 0); =20 + if (!xlu_cfg_get_long (config, "xenstore_feature_mask", &l, 0)) + b_info->xenstore_feature_mask =3D l; + libxl_domain_build_info_init_type(b_info, c_info->type); =20 if (b_info->type =3D=3D LIBXL_DOMAIN_TYPE_PVH) { --=20 2.43.0