From nobody Wed Dec 4 19:30:36 2024 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=1729689095; cv=none; d=zohomail.com; s=zohoarc; b=SfB0tNHl1TJDqVtgDMrbt6Im6I2CPhTu78EA9LP5/FP6hgHXUD6uC2sJP1ucU2usRt21fQU6VI4Str7Lwah5Ej8BJU0M37zvlbHG1Gy9VjjYFQWFwS2Ij6nJmQMcNQhnMCZVZ8Hdgp0/Xrb544Kc8Z4pX9tAW6aFJMiIkGyFe7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729689095; 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=E987LsdlIgzKQbdEFTgOeCDvrDTXQ5jG9XVD9+qlAzk=; b=AWDrvkgz5GuNyPQzARGPJL3J9KjII5Y0/oH+3nSPxrua2H9M1kPeMpRHE68Fe3DdzF0aHCjb5kf4U5bF82uq3OR2mortPiGnY7vvXJvNwoz/cF9inKiXW7uKL/6COe0hT8Pst5LSoxpUtyleCaSpXGZcjdpQJ5nvJdNezEpPbdI= 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 172968909564561.7565722019649; Wed, 23 Oct 2024 06:11:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.824615.1238809 (Exim 4.92) (envelope-from ) id 1t3b8Q-0000AO-8B; Wed, 23 Oct 2024 13:10:46 +0000 Received: by outflank-mailman (output) from mailman id 824615.1238809; Wed, 23 Oct 2024 13:10:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t3b8Q-0000AB-5P; Wed, 23 Oct 2024 13:10:46 +0000 Received: by outflank-mailman (input) for mailman id 824615; Wed, 23 Oct 2024 13:10:44 +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 1t3b8O-0006Ra-It for xen-devel@lists.xenproject.org; Wed, 23 Oct 2024 13:10:44 +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 34f4c3fd-9140-11ef-99a3-01e77a169b0f; Wed, 23 Oct 2024 15:10:42 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 26F581FDA3; Wed, 23 Oct 2024 13:10:42 +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 E969713A63; Wed, 23 Oct 2024 13:10:41 +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 J8SFN9H1GGf7dwAAD6G6ig (envelope-from ); Wed, 23 Oct 2024 13:10:41 +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: 34f4c3fd-9140-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1729689042; 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=E987LsdlIgzKQbdEFTgOeCDvrDTXQ5jG9XVD9+qlAzk=; b=JTVYA1wSacsKybqp0fWSSRubXG1XKGyhEDETDfw3xbdSxZXFlQ4EemOFZnEoZZHeOhwmI5 Z4BXftGSJIGvNBwPENvX4CUv/TR3TSyVGO7qqUBtzgbsHSKA+oU+drHQm8Qb3TeiDEAC+Y 4cpUTLm+65lTGl5F0zW27vwSvD9CXMQ= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1729689042; 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=E987LsdlIgzKQbdEFTgOeCDvrDTXQ5jG9XVD9+qlAzk=; b=JTVYA1wSacsKybqp0fWSSRubXG1XKGyhEDETDfw3xbdSxZXFlQ4EemOFZnEoZZHeOhwmI5 Z4BXftGSJIGvNBwPENvX4CUv/TR3TSyVGO7qqUBtzgbsHSKA+oU+drHQm8Qb3TeiDEAC+Y 4cpUTLm+65lTGl5F0zW27vwSvD9CXMQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD , Samuel Thibault , Julien Grall Subject: [PATCH 6/6] tools/xenstored: use new stable interface instead of libxenctrl Date: Wed, 23 Oct 2024 15:10:05 +0200 Message-ID: <20241023131005.32144-7-jgross@suse.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023131005.32144-1-jgross@suse.com> References: <20241023131005.32144-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Level: X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1729689096000116600 Content-Type: text/plain; charset="utf-8" Replace the current use of the unstable xc_domain_getinfo_single() interface with the stable domctl XEN_DOMCTL_get_domain_state call via the new libxenmanage library. This will remove the last usage of libxenctrl by Xenstore, so update the library dependencies accordingly. For now only do a direct replacement without using the functionality of obtaining information about domains having changed the state. Signed-off-by: Juergen Gross --- V1: - use library instead of direct hypercall, only replace current libxenctrl use case Please note that this patch can be committed only after the related Mini-OS patch "config: add support for libxenmanage" has gone in AND the Mini-OS commit-id has been updated in Config.mk accordingly! --- stubdom/Makefile | 8 ++--- stubdom/mini-os.mk | 1 + tools/xenstored/Makefile | 2 +- tools/xenstored/Makefile.common | 2 +- tools/xenstored/core.h | 1 - tools/xenstored/domain.c | 52 ++++++++++++--------------------- tools/xenstored/lu.c | 1 + tools/xenstored/lu_daemon.c | 1 + 8 files changed, 28 insertions(+), 40 deletions(-) diff --git a/stubdom/Makefile b/stubdom/Makefile index 2a81af28a1..ca800b243c 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -307,7 +307,7 @@ endif # libraries under tools/libs ####### =20 -STUB_LIBS :=3D toolcore toollog evtchn gnttab call foreignmemory devicemod= el ctrl guest +STUB_LIBS :=3D toolcore toollog evtchn gnttab call foreignmemory devicemod= el ctrl guest manage =20 LIBDEP_guest :=3D cross-zlib =20 @@ -465,7 +465,7 @@ grub: cross-polarssl grub-upstream $(CROSS_ROOT) grub-$= (XEN_TARGET_ARCH)-minios- # xenstore ########## =20 -xenstore-minios.gen.cfg: APP_LIBS =3D gnttab evtchn toollog ctrl +xenstore-minios.gen.cfg: APP_LIBS =3D gnttab evtchn toollog manage xenstore-minios.gen.cfg: xenstore-minios.cfg Makefile $(GEN_config) >$@ =20 @@ -480,7 +480,7 @@ xenstore: $(CROSS_ROOT) xenstore-minios-config.mk # xenstorepvh ############# =20 -xenstorepvh-minios.gen.cfg: APP_LIBS =3D gnttab evtchn toollog ctrl +xenstorepvh-minios.gen.cfg: APP_LIBS =3D gnttab evtchn toollog manage xenstorepvh-minios.gen.cfg: xenstorepvh-minios.cfg Makefile $(GEN_config) >$@ =20 @@ -523,7 +523,7 @@ else pv-grub-if-enabled: endif =20 -XENSTORE_DEPS :=3D libxenevtchn libxengnttab libxenctrl +XENSTORE_DEPS :=3D libxenevtchn libxengnttab libxenmanage =20 .PHONY: xenstore-stubdom xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore $(XENSTORE_DEPS) xen= store diff --git a/stubdom/mini-os.mk b/stubdom/mini-os.mk index 7e4968e026..be32302f9e 100644 --- a/stubdom/mini-os.mk +++ b/stubdom/mini-os.mk @@ -13,5 +13,6 @@ GNTTAB_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_= ARCH)/gnttab CALL_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call FOREIGNMEMORY_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/fore= ignmemory DEVICEMODEL_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/device= model +MANAGE_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/manage CTRL_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl GUEST_PATH =3D $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/guest diff --git a/tools/xenstored/Makefile b/tools/xenstored/Makefile index 09adfe1d50..81c42838e0 100644 --- a/tools/xenstored/Makefile +++ b/tools/xenstored/Makefile @@ -5,7 +5,7 @@ include Makefile.common =20 xenstored: LDLIBS +=3D $(LDLIBS_libxenevtchn) xenstored: LDLIBS +=3D $(LDLIBS_libxengnttab) -xenstored: LDLIBS +=3D $(LDLIBS_libxenctrl) +xenstored: LDLIBS +=3D $(LDLIBS_libxenmanage) xenstored: LDLIBS +=3D -lrt xenstored: LDLIBS +=3D $(SOCKET_LIBS) =20 diff --git a/tools/xenstored/Makefile.common b/tools/xenstored/Makefile.com= mon index 27fdb3b49e..271134fcc1 100644 --- a/tools/xenstored/Makefile.common +++ b/tools/xenstored/Makefile.common @@ -12,7 +12,7 @@ XENSTORED_OBJS-$(CONFIG_MiniOS) +=3D minios.o lu_minios.o # Include configure output (config.h) CFLAGS +=3D -include $(XEN_ROOT)/tools/config.h CFLAGS +=3D $(CFLAGS_libxenevtchn) -CFLAGS +=3D $(CFLAGS_libxenctrl) +CFLAGS +=3D $(CFLAGS_libxenmanage) CFLAGS +=3D $(CFLAGS_libxentoolcore) =20 $(XENSTORED_OBJS-y): CFLAGS +=3D $(CFLAGS_libxengnttab) diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index e58779e88c..632886cecf 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -19,7 +19,6 @@ #ifndef _XENSTORED_CORE_H #define _XENSTORED_CORE_H =20 -#include #include =20 #include diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 64c8fd0cc3..c0264d9477 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -34,14 +34,15 @@ #include "control.h" =20 #include -#include +#include +#include #include =20 #ifdef __MINIOS__ #include #endif =20 -static xc_interface **xc_handle; +static xenmanage_handle *xm_handle; xengnttab_handle **xgt_handle; static evtchn_port_t virq_port; =20 @@ -619,32 +620,28 @@ static int destroy_domain(void *_domain) return 0; } =20 -static bool get_domain_info(unsigned int domid, xc_domaininfo_t *dominfo) -{ - return xc_domain_getinfo_single(*xc_handle, domid, dominfo) =3D=3D 0; -} - static int check_domain(const void *k, void *v, void *arg) { - xc_domaininfo_t dominfo; + unsigned int state; struct connection *conn; - bool dom_valid; + int dom_invalid; struct domain *domain =3D v; bool *notify =3D arg; =20 - dom_valid =3D get_domain_info(domain->domid, &dominfo); + dom_invalid =3D xenmanage_get_domain_info(xm_handle, domain->domid, + &state, NULL); if (!domain->introduced) { - if (!dom_valid) + if (dom_invalid) talloc_free(domain); return 0; } - if (dom_valid) { - if ((dominfo.flags & XEN_DOMINF_shutdown) + if (!dom_invalid) { + if ((state & XENMANAGE_GETDOMSTATE_STATE_SHUTDOWN) && !domain->shutdown) { domain->shutdown =3D true; *notify =3D true; } - if (!(dominfo.flags & XEN_DOMINF_dying)) + if (!(state & XENMANAGE_GETDOMSTATE_STATE_DYING)) return 0; } if (domain->conn) { @@ -786,10 +783,9 @@ static struct domain *find_or_alloc_domain(const void = *ctx, unsigned int domid) static struct domain *find_or_alloc_existing_domain(unsigned int domid) { struct domain *domain; - xc_domaininfo_t dominfo; =20 domain =3D find_domain_struct(domid); - if (!domain && get_domain_info(domid, &dominfo)) + if (!domain && !xenmanage_get_domain_info(xm_handle, domid, NULL, NULL)) domain =3D alloc_domain(NULL, domid); =20 return domain; @@ -1187,12 +1183,6 @@ int do_reset_watches(const void *ctx, struct connect= ion *conn, return 0; } =20 -static int close_xc_handle(void *_handle) -{ - xc_interface_close(*(xc_interface**)_handle); - return 0; -} - static int close_xgt_handle(void *_handle) { xengnttab_close(*(xengnttab_handle **)_handle); @@ -1258,15 +1248,9 @@ void domain_early_init(void) if (!domhash) barf_perror("Failed to allocate domain hashtable"); =20 - xc_handle =3D talloc(talloc_autofree_context(), xc_interface*); - if (!xc_handle) - barf_perror("Failed to allocate domain handle"); - - *xc_handle =3D xc_interface_open(0,0,0); - if (!*xc_handle) - barf_perror("Failed to open connection to hypervisor"); - - talloc_set_destructor(xc_handle, close_xc_handle); + xm_handle =3D xenmanage_open(NULL, 0); + if (!xm_handle) + barf_perror("Failed to open connection to libxenmanage"); =20 xgt_handle =3D talloc(talloc_autofree_context(), xengnttab_handle*); if (!xgt_handle) @@ -1306,6 +1290,8 @@ void domain_deinit(void) { if (virq_port) xenevtchn_unbind(xce_handle, virq_port); + + xenmanage_close(xm_handle); } =20 /* @@ -1335,13 +1321,13 @@ int domain_alloc_permrefs(struct node_perms *perms) { unsigned int i, domid; struct domain *d; - xc_domaininfo_t dominfo; =20 for (i =3D 0; i < perms->num; i++) { domid =3D perms->p[i].id; d =3D find_domain_struct(domid); if (!d) { - if (!get_domain_info(domid, &dominfo)) + if (xenmanage_get_domain_info(xm_handle, domid, + NULL, NULL)) perms->p[i].perms |=3D XS_PERM_IGNORE; else if (!alloc_domain(NULL, domid)) return ENOMEM; diff --git a/tools/xenstored/lu.c b/tools/xenstored/lu.c index bec2a84e10..4fccbbc195 100644 --- a/tools/xenstored/lu.c +++ b/tools/xenstored/lu.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c index 6df6c80a2a..88d8d9e1b3 100644 --- a/tools/xenstored/lu_daemon.c +++ b/tools/xenstored/lu_daemon.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include =20 #include "talloc.h" --=20 2.43.0