From nobody Mon May 20 23:48:14 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=1708101137; cv=none; d=zohomail.com; s=zohoarc; b=PiqSln8Giiu4HpFNigDu5Bn3BdPCvcALAi1vkWK8PH/V3i4EhwKuIaYCO7aBfCsDuC3RMz+nNU2EOX0ZisMn7XINA/bElkYejPyhNc787ZMRSX3PZgTcC9vB6XrottryHuyd6dRBd85AJuOvXskbcrwLXeLsXBN6skgrNKahhcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708101137; 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=zgmWzK99RZBrySpVIOBOfTuvIg1qZCvB7PuUVcrLtSw=; b=ISyd/XdjnZwd1drE8zlVNtI4Xuv6L/Dm2m8bY3GTJGKsfUEUm1W+myDaumUuJOcXnPklKeyT/cYJ7OhNIJy10lZYzEY2NOSuIsITioA0bU3TqTPtl6UXGu+kKkXm1Zdz57TEqTtEONpii7W3rzoal8EizvrEuJBM6Qo9ZldYVUI= 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 1708101137200771.1900659612102; Fri, 16 Feb 2024 08:32:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682280.1061390 (Exim 4.92) (envelope-from ) id 1rb17u-0000TK-SC; Fri, 16 Feb 2024 16:31:50 +0000 Received: by outflank-mailman (output) from mailman id 682280.1061390; Fri, 16 Feb 2024 16:31:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb17u-0000TD-PU; Fri, 16 Feb 2024 16:31:50 +0000 Received: by outflank-mailman (input) for mailman id 682280; Fri, 16 Feb 2024 16:31:49 +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 1rb17t-0000Sx-52 for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:31:49 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e11b871c-cce8-11ee-8a4f-1f161083a0e0; Fri, 16 Feb 2024 17:31:47 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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 54F4F1FB76; Fri, 16 Feb 2024 16:31:47 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 1027A13343; Fri, 16 Feb 2024 16:31:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id WD1FAvONz2U+VAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:31:47 +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: e11b871c-cce8-11ee-8a4f-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708101107; 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=zgmWzK99RZBrySpVIOBOfTuvIg1qZCvB7PuUVcrLtSw=; b=DmTAkEPkDk3OrdLE6LkLutxX1HgH9G05u70Ov2Rn0lZ7qOPPM+c/hsKuDLjR6vY+tpHFe7 1byuP5gr+vM339yEONIu63hJzaDpDt/C6omP2IvMfwwT7+GL0BhJrtdzbq3GX/wofVvMVy wr0Y2sZsMwDd1uucpxTEXZb/cMtajlY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708101107; 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=zgmWzK99RZBrySpVIOBOfTuvIg1qZCvB7PuUVcrLtSw=; b=DmTAkEPkDk3OrdLE6LkLutxX1HgH9G05u70Ov2Rn0lZ7qOPPM+c/hsKuDLjR6vY+tpHFe7 1byuP5gr+vM339yEONIu63hJzaDpDt/C6omP2IvMfwwT7+GL0BhJrtdzbq3GX/wofVvMVy wr0Y2sZsMwDd1uucpxTEXZb/cMtajlY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , George Dunlap , Nick Rosbrook , Wei Liu , Anthony PERARD , Jason Andryuk , George Dunlap Subject: [PATCH v8 1/8] tools/libs/light: add backend type for 9pfs PV devices Date: Fri, 16 Feb 2024 17:31:32 +0100 Message-Id: <20240216163139.9093-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[suse.com,citrix.com,gmail.com,xen.org,cloud.com]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.10 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1708101138738100001 Content-Type: text/plain; charset="utf-8" Make the backend type of 9pfs PV devices configurable. The default is "qemu" with the related Xenstore backend-side directory being "9pfs". Add another type "xen_9pfsd" with the related Xenstore backend-side directory "xen_9pfs". As additional security features it is possible to specify: - "max-space" for limiting the maximum space consumed on the filesystem in MBs - "max-files" for limiting the maximum number of files in the filesystem - "max-open-files" for limiting the maximum number of concurrent open files For convenience "auto-delete" is available to let the backend delete the oldest file of the guest in case otherwise "max-space" or "max-files" would be violated. The xen-9pfsd daemon will be started by libxenlight automatically when the first "xen_9pfs" device is being created. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Acked-by: George Dunlap # Golang bits Reviewed-by: Anthony PERARD --- V3: - regenerate go bindings V4: - rename libxl_device_p9_dm_needed() to libxl__device_p9_dm_needed() (Anthony Perard) - reorder span related functions (Anthony Perard) - add comment for xen9pfsd_spawn() return values (Anthony Perard) - add LIBXL_HAVE_XEN_9PFS to libxl.h (Anthony Perard) - use a copy of 'p9' in xen9pfsd_spawn() (Anthony Perard) V6: - rebase (Anthony Perard) - drop callback from struct libxl__aop9_state (Anthony Perard) --- tools/golang/xenlight/helpers.gen.go | 10 ++ tools/golang/xenlight/types.gen.go | 12 ++ tools/include/libxl.h | 7 + tools/libs/light/libxl_9pfs.c | 157 +++++++++++++++++++++- tools/libs/light/libxl_create.c | 4 +- tools/libs/light/libxl_dm.c | 2 +- tools/libs/light/libxl_types.idl | 11 ++ tools/libs/light/libxl_types_internal.idl | 1 + 8 files changed, 197 insertions(+), 7 deletions(-) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 0f8e23773c..8f44397a4e 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -2440,6 +2440,11 @@ x.Tag =3D C.GoString(xc.tag) x.Path =3D C.GoString(xc.path) x.SecurityModel =3D C.GoString(xc.security_model) x.Devid =3D Devid(xc.devid) +x.Type =3D P9Type(xc._type) +x.MaxSpace =3D int(xc.max_space) +x.MaxFiles =3D int(xc.max_files) +x.MaxOpenFiles =3D int(xc.max_open_files) +x.AutoDelete =3D bool(xc.auto_delete) =20 return nil} =20 @@ -2458,6 +2463,11 @@ xc.path =3D C.CString(x.Path)} if x.SecurityModel !=3D "" { xc.security_model =3D C.CString(x.SecurityModel)} xc.devid =3D C.libxl_devid(x.Devid) +xc._type =3D C.libxl_p9_type(x.Type) +xc.max_space =3D C.int(x.MaxSpace) +xc.max_files =3D C.int(x.MaxFiles) +xc.max_open_files =3D C.int(x.MaxOpenFiles) +xc.auto_delete =3D C.bool(x.AutoDelete) =20 return nil } diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index 9c8b7b81f6..d31722407a 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -122,6 +122,13 @@ NicTypeVifIoemu NicType =3D 1 NicTypeVif NicType =3D 2 ) =20 +type P9Type int +const( +P9TypeUnknown P9Type =3D 0 +P9TypeQemu P9Type =3D 1 +P9TypeXen9Pfsd P9Type =3D 2 +) + type ActionOnShutdown int const( ActionOnShutdownDestroy ActionOnShutdown =3D 1 @@ -889,6 +896,11 @@ Tag string Path string SecurityModel string Devid Devid +Type P9Type +MaxSpace int +MaxFiles int +MaxOpenFiles int +AutoDelete bool } =20 type DevicePvcallsif struct { diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 46bc774126..9a3e702557 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -615,6 +615,13 @@ */ #define LIBXL_HAVE_HVM_PIRQ 1 =20 +/* + * LIBXL_HAVE_XEN_9PFS indicates the presence of the xen-9pfsd related + * fields in libxl_device_p9: type, max_space, max_files, max_open_files a= nd + * auto_delete. + */ +#define LIBXL_HAVE_XEN_9PFS 1 + /* * libxl memory management * diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index 5ab0d3aa21..900c0d46a0 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -33,20 +33,171 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint3= 2_t domid, =20 flexarray_append_pair(front, "tag", p9->tag); =20 + if (p9->type =3D=3D LIBXL_P9_TYPE_XEN_9PFSD) { + flexarray_append_pair(back, "max-space", + GCSPRINTF("%u", p9->max_space)); + flexarray_append_pair(back, "max-files", + GCSPRINTF("%u", p9->max_files)); + flexarray_append_pair(back, "max-open-files", + GCSPRINTF("%u", p9->max_open_files)); + flexarray_append_pair(back, "auto-delete", + p9->auto_delete ? "1" : "0"); + } + + return 0; +} + +static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid, + libxl_device_p9 *type, libxl__device *dev= ice) +{ + device->backend_devid =3D type->devid; + device->backend_domid =3D type->backend_domid; + device->backend_kind =3D type->type =3D=3D LIBXL_P9_TYPE_QEMU + ? LIBXL__DEVICE_KIND_9PFS + : LIBXL__DEVICE_KIND_XEN_9PFS; + device->devid =3D type->devid; + device->domid =3D domid; + device->kind =3D LIBXL__DEVICE_KIND_9PFS; + return 0; } =20 -#define libxl__add_p9s NULL +static int libxl__device_p9_dm_needed(void *e, unsigned domid) +{ + libxl_device_p9 *elem =3D e; + + return elem->type =3D=3D LIBXL_P9_TYPE_QEMU && elem->backend_domid =3D= =3D domid; +} + +typedef struct libxl__aop9_state libxl__aop9_state; + +struct libxl__aop9_state { + libxl__spawn_state spawn; + libxl__ao_device *aodev; + libxl_device_p9 p9; + uint32_t domid; +}; + +static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata); +static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, in= t rc); +static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn); +static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop= 9, + int rc); + +/* + * Spawn the xen-9pfsd daemon if needed. + * returns: + * < 0 if error + * 0 if no daemon needs to be spawned + * 1 if daemon was spawned + */ +static int xen9pfsd_spawn(libxl__egc *egc, uint32_t domid, libxl_device_p9= *p9, + libxl__ao_device *aodev) +{ + STATE_AO_GC(aodev->ao); + struct libxl__aop9_state *aop9; + int rc; + char *args[] =3D { "xen-9pfsd", NULL }; + char *path =3D GCSPRINTF("/local/domain/%u/libxl/xen-9pfs", + p9->backend_domid); + + if (p9->type !=3D LIBXL_P9_TYPE_XEN_9PFSD || + libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", path))) + return 0; + + GCNEW(aop9); + aop9->aodev =3D aodev; + libxl_device_p9_copy(CTX, &aop9->p9, p9); + aop9->domid =3D domid; + + aop9->spawn.ao =3D aodev->ao; + aop9->spawn.what =3D "xen-9pfs daemon"; + aop9->spawn.xspath =3D GCSPRINTF("%s/state", path); + aop9->spawn.timeout_ms =3D LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000; + aop9->spawn.pidpath =3D GCSPRINTF("%s/pid", path); + aop9->spawn.midproc_cb =3D libxl__spawn_record_pid; + aop9->spawn.confirm_cb =3D xen9pfsd_confirm; + aop9->spawn.failure_cb =3D xen9pfsd_failed; + aop9->spawn.detached_cb =3D xen9pfsd_detached; + rc =3D libxl__spawn_spawn(egc, &aop9->spawn); + if (rc < 0) + return rc; + if (!rc) { + setsid(); + libxl__exec(gc, -1, -1, -1, LIBEXEC_BIN "/xen-9pfsd", args, NULL); + } + + return 1; +} + +static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata) +{ + STATE_AO_GC(spawn->ao); + + if (!xsdata) + return; + + if (strcmp(xsdata, "running")) + return; + + libxl__spawn_initiate_detach(gc, spawn); +} + +static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, in= t rc) +{ + libxl__aop9_state *aop9 =3D CONTAINER_OF(spawn, *aop9, spawn); + + xen9pfsd_spawn_outcome(egc, aop9, rc); +} + +static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn) +{ + libxl__aop9_state *aop9 =3D CONTAINER_OF(spawn, *aop9, spawn); + + xen9pfsd_spawn_outcome(egc, aop9, 0); +} + +static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop= 9, + int rc) +{ + aop9->aodev->rc =3D rc; + if (rc) + aop9->aodev->callback(egc, aop9->aodev); + else + libxl__device_add_async(egc, aop9->domid, &libxl__p9_devtype, + &aop9->p9, aop9->aodev); +} + +static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid, + libxl_device_p9 *p9, + libxl__ao_device *aodev) +{ + int rc; + + rc =3D xen9pfsd_spawn(egc, domid, p9, aodev); + if (rc =3D=3D 1) + return; + + if (rc =3D=3D 0) + libxl__device_add_async(egc, domid, &libxl__p9_devtype, p9, aodev); + + aodev->rc =3D rc; + if (rc) + aodev->callback(egc, aodev); +} + #define libxl_device_p9_list NULL #define libxl_device_p9_compare NULL =20 static LIBXL_DEFINE_UPDATE_DEVID(p9) -static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9) +static LIBXL_DEFINE_DEVICES_ADD(p9) =20 LIBXL_DEFINE_DEVICE_REMOVE(p9) =20 DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, p9s, - .skip_attach =3D 1, .set_xenstore_config =3D (device_set_xenstore_config_fn_t) libxl__set_xenstore_p9, + .dm_needed =3D libxl__device_p9_dm_needed, ); diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_creat= e.c index 0008fac607..5546335973 100644 --- a/tools/libs/light/libxl_create.c +++ b/tools/libs/light/libxl_create.c @@ -1761,9 +1761,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libx= l__multidev *multidev, libxl__device_console_dispose(&console); } =20 - for (i =3D 0; i < d_config->num_p9s; i++) - libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]= ); - for (i =3D 0; i < d_config->num_pvcallsifs; i++) libxl__device_add(gc, domid, &libxl__pvcallsif_devtype, &d_config->pvcallsifs[i]); @@ -1900,6 +1897,7 @@ const libxl__device_type *device_type_tbl[] =3D { &libxl__vdispl_devtype, &libxl__vsnd_devtype, &libxl__virtio_devtype, + &libxl__p9_devtype, NULL }; =20 diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 14b593110f..2aaaeb5aa7 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -3761,7 +3761,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domai= n_config *d_config) goto out; } =20 - if (d_config->num_vfbs > 0 || d_config->num_p9s > 0) { + if (d_config->num_vfbs > 0) { ret =3D 1; goto out; } diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index 899ad30969..682092a058 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -150,6 +150,12 @@ libxl_nic_type =3D Enumeration("nic_type", [ (2, "VIF"), ]) =20 +libxl_p9_type =3D Enumeration("p9_type", [ + (0, "unknown"), + (1, "qemu"), + (2, "xen_9pfsd"), + ]) + libxl_action_on_shutdown =3D Enumeration("action_on_shutdown", [ (1, "DESTROY"), =20 @@ -943,6 +949,11 @@ libxl_device_p9 =3D Struct("device_p9", [ ("path", string), ("security_model", string), ("devid", libxl_devid), + ("type", libxl_p9_type), + ("max_space", integer), + ("max_files", integer), + ("max_open_files", integer), + ("auto_delete", bool), ]) =20 libxl_device_pvcallsif =3D Struct("device_pvcallsif", [ diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/l= ibxl_types_internal.idl index 56dccac153..0425e9b6b0 100644 --- a/tools/libs/light/libxl_types_internal.idl +++ b/tools/libs/light/libxl_types_internal.idl @@ -35,6 +35,7 @@ libxl__device_kind =3D Enumeration("device_kind", [ (17, "VIRTIO_DISK"), (18, "VIRTIO"), (19, "VBD3"), + (20, "XEN_9PFS"), ]) =20 libxl__console_backend =3D Enumeration("console_backend", [ --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 1708101135504321.75031352122505; Fri, 16 Feb 2024 08:32:15 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682281.1061400 (Exim 4.92) (envelope-from ) id 1rb180-0000kI-2P; Fri, 16 Feb 2024 16:31:56 +0000 Received: by outflank-mailman (output) from mailman id 682281.1061400; Fri, 16 Feb 2024 16:31:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb17z-0000kB-Vz; Fri, 16 Feb 2024 16:31:55 +0000 Received: by outflank-mailman (input) for mailman id 682281; Fri, 16 Feb 2024 16:31:55 +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 1rb17z-0000EA-1k for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:31:55 +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 e456d40a-cce8-11ee-98f5-efadbce2ee36; Fri, 16 Feb 2024 17:31:53 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 E9C861FB7D; Fri, 16 Feb 2024 16:31:52 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id BA14513343; Fri, 16 Feb 2024 16:31:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id 1gzoK/iNz2VEVAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:31:52 +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: e456d40a-cce8-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Jason Andryuk Subject: [PATCH v8 2/8] tools/xl: support new 9pfs backend xen_9pfsd Date: Fri, 16 Feb 2024 17:31:33 +0100 Message-Id: <20240216163139.9093-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: E9C861FB7D X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101136357100002 Content-Type: text/plain; charset="utf-8" Add support for the new 9pfs backend "xen_9pfsd". For this backend type the tag defaults to "Xen" and the host side path to "/var/log/xen/guests/". Do most of the default settings in libxl. Unfortunately the default path can't easily be set in libxl, as the domain name isn't available in the related 9pfs specific function. Settings the defaults in libxl requires to move the sanity checking of 9pfs parameters from xl to libxl, too. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Anthony PERARD --- V2: - test max_files and max_open_files, too (Jason Andryuk) V4: - fix man page to use the "xen_9pfsd" type due to idl limitation (Jason Andryuk) - set (most of) the defaults in libxl (Anthony Perard) --- docs/man/xl.cfg.5.pod.in | 36 +++++++++++++++++++++++++++++++++-- tools/libs/light/libxl_9pfs.c | 18 ++++++++++++++++++ tools/xl/xl_parse.c | 23 +++++++++++++++++++--- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index ea8d41727d..039e057318 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -772,10 +772,16 @@ settings, from the following list: =20 =3Dover 4 =20 +=3Ditem B + +The backendtype for the PV device. Supported values are B and +B. The default is B. + =3Ditem B =20 9pfs tag to identify the filesystem share. The tag is needed on the -guest side to mount it. +guest side to mount it. For the backendtype of B the tag defaul= ts to +"Xen". =20 =3Ditem B =20 @@ -785,12 +791,38 @@ squash or remap). =20 =3Ditem B =20 -Filesystem path on the backend to export. +Filesystem path on the backend to export. For the backendtype of B +the path defaults to "@XEN_LOG_DIR@/guests/". =20 =3Ditem B =20 Specify the backend domain name or id, defaults to dom0. =20 +=3Ditem B + +Specify the maximum number of files below B. A value of 0 (which +is the default) doesn't limit the number of files. Only valid for +B. + +=3Ditem B + +Specify the maximum number of concurrently opened files below B. +Multiple opens of the same file are counted individually. Only valid for +B, which has a default of B. + +=3Ditem B + +Specify the maximum used disk space in MiB below B. A value of 0 (wh= ich +is the default) doesn't limit the usable disk space. Only valid for +B. + +=3Ditem B + +When set the backend will delete the oldest file which is currently not +opened by the guest in case the disk space limit set via B or t= he +file limit set via B is being reached. Only valid for +B. + =3Dback =20 =3Ditem B diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index 900c0d46a0..ddeb4f20a7 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -20,6 +20,24 @@ static int libxl__device_p9_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_p9 *p9, bool hotplug) { + if (p9->type =3D=3D LIBXL_P9_TYPE_UNKNOWN) { + p9->type =3D LIBXL_P9_TYPE_QEMU; + } + if (p9->type =3D=3D LIBXL_P9_TYPE_QEMU && + (p9->max_files || p9->max_open_files || p9->max_space || + p9->auto_delete)) { + LOGD(ERROR, domid, "Illegal 9pfs parameter combination"); + return ERROR_INVAL; + } + if (p9->type =3D=3D LIBXL_P9_TYPE_XEN_9PFSD && !p9->tag) { + p9->tag =3D libxl__strdup(NOGC, "Xen"); + } + + if (!p9->path || !p9->security_model || !p9->tag) { + LOGD(ERROR, domid, "9pfs spec missing required field!"); + return ERROR_INVAL; + } + return libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domi= d); } =20 diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 9b358f11b8..80ffe85f5e 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2233,6 +2233,20 @@ void parse_config_data(const char *config_source, replace_string(&p9->tag, value); } else if (!strcmp(key, "backend")) { replace_string(&p9->backend_domname, value); + } else if (!strcmp(key, "type")) { + if (libxl_p9_type_from_string(value, &p9->type)) { + fprintf(stderr, "failed to parse 9pfs type: %s\n", + value); + exit(1); + } + } else if (!strcmp(key, "max-files")) { + p9->max_files =3D parse_ulong(value); + } else if (!strcmp(key, "max-open-files")) { + p9->max_open_files =3D parse_ulong(value); + } else if (!strcmp(key, "max-space")) { + p9->max_space =3D parse_ulong(value); + } else if (!strcmp(key, "auto-delete")) { + p9->auto_delete =3D strtoul(value, NULL, 0); } else { fprintf(stderr, "Unknown 9pfs parameter '%s'\n", key); exit(1); @@ -2243,9 +2257,12 @@ void parse_config_data(const char *config_source, =20 libxl_string_list_dispose(&pairs); =20 - if (!p9->path || !p9->security_model || !p9->tag) { - fprintf(stderr, "9pfs spec missing required field!\n"); - exit(1); + if (p9->type =3D=3D LIBXL_P9_TYPE_XEN_9PFSD && !p9->path) { + char *path; + + xasprintf(&path, XEN_LOG_DIR "/guests/%s", c_info->name); + replace_string(&p9->path, path); + free(path); } } } --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 1708101139472613.1508869917717; Fri, 16 Feb 2024 08:32:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682282.1061411 (Exim 4.92) (envelope-from ) id 1rb186-00013F-De; Fri, 16 Feb 2024 16:32:02 +0000 Received: by outflank-mailman (output) from mailman id 682282.1061411; Fri, 16 Feb 2024 16:32: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 1rb186-000138-AU; Fri, 16 Feb 2024 16:32:02 +0000 Received: by outflank-mailman (input) for mailman id 682282; Fri, 16 Feb 2024 16:32:00 +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 1rb184-0000EA-Pj for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:00 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e7a63c14-cce8-11ee-98f5-efadbce2ee36; Fri, 16 Feb 2024 17:31:58 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 819B11FB81; Fri, 16 Feb 2024 16:31:58 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 580FC13343; Fri, 16 Feb 2024 16:31:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id /jLzE/6Nz2VHVAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:31: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: e7a63c14-cce8-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Samuel Thibault , Jason Andryuk Subject: [PATCH v8 3/8] stubdom: extend xenstore stubdom configs Date: Fri, 16 Feb 2024 17:31:34 +0100 Message-Id: <20240216163139.9093-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 819B11FB81 X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101140293100003 Content-Type: text/plain; charset="utf-8" Extend the config files of the Xenstore stubdoms to include XENBUS and 9PFRONT items in order to support file based logging. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Acked-by: Samuel Thibault --- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg index a41704bb6b..239da519b9 100644 --- a/stubdom/xenstore-minios.cfg +++ b/stubdom/xenstore-minios.cfg @@ -3,7 +3,7 @@ CONFIG_NETFRONT=3Dn CONFIG_FBFRONT=3Dn CONFIG_KBDFRONT=3Dn CONFIG_CONSFRONT=3Dn -CONFIG_XENBUS=3Dn CONFIG_LWIP=3Dn +CONFIG_9PFRONT=3Dy CONFIG_BALLOON=3Dy XEN_INTERFACE_VERSION=3D__XEN_LATEST_INTERFACE_VERSION__ diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg index 6af51f5753..752b90d7d3 100644 --- a/stubdom/xenstorepvh-minios.cfg +++ b/stubdom/xenstorepvh-minios.cfg @@ -4,7 +4,7 @@ CONFIG_NETFRONT=3Dn CONFIG_FBFRONT=3Dn CONFIG_KBDFRONT=3Dn CONFIG_CONSFRONT=3Dn -CONFIG_XENBUS=3Dn CONFIG_LWIP=3Dn +CONFIG_9PFRONT=3Dy CONFIG_BALLOON=3Dy XEN_INTERFACE_VERSION=3D__XEN_LATEST_INTERFACE_VERSION__ --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 1708101144068580.8028821029123; Fri, 16 Feb 2024 08:32:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682283.1061421 (Exim 4.92) (envelope-from ) id 1rb18A-0001NA-KO; Fri, 16 Feb 2024 16:32:06 +0000 Received: by outflank-mailman (output) from mailman id 682283.1061421; Fri, 16 Feb 2024 16:32:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb18A-0001Mu-H9; Fri, 16 Feb 2024 16:32:06 +0000 Received: by outflank-mailman (input) for mailman id 682283; Fri, 16 Feb 2024 16:32: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 1rb18A-0000EA-2z for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:06 +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 eb01f592-cce8-11ee-98f5-efadbce2ee36; Fri, 16 Feb 2024 17:32:04 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 261C11FD3B; Fri, 16 Feb 2024 16:32:04 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id E1A5B13343; Fri, 16 Feb 2024 16:32:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id I5WaNQOOz2VdVAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:32:03 +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: eb01f592-cce8-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Jason Andryuk Subject: [PATCH v8 4/8] tools: add 9pfs device to xenstore-stubdom Date: Fri, 16 Feb 2024 17:31:35 +0100 Message-Id: <20240216163139.9093-5-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 261C11FD3B X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101146322100001 Content-Type: text/plain; charset="utf-8" Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g. logging into a dom0 file. Use the following parameters for the new device: - tag =3D "Xen" - type =3D "xen_9pfsd" - path =3D "/var/lib/xen/xenstore" - security-model =3D "none" For now don't limit allowed file space or number of files. Add a new libxl function for adding it similar to the function for adding the console device. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Anthony PERARD --- V2: - add security_model parameter to new libxl function (Jason Andryuk) V4: - rename function to libxl_device_9pfs_add() (Anthony Perard) - use a libxl_device_p9 pointer as parameter (Anthony Perard) V8: - remove "_XENSTORE" suffix from define (Anthony Perard) --- tools/helpers/init-xenstore-domain.c | 7 +++++++ tools/include/libxl.h | 15 +++++++++++++++ tools/libs/light/libxl_9pfs.c | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xens= tore-domain.c index 140ed610ae..1683438c5c 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -433,6 +433,12 @@ int main(int argc, char** argv) int rv, fd; char *maxmem_str =3D NULL; libxl_ctx *ctx; + libxl_device_p9 p9 =3D { .backend_domid =3D 0, + .tag =3D "Xen", + .path =3D XEN_LIB_DIR"/xenstore", + .security_model =3D "none", + .type =3D LIBXL_P9_TYPE_XEN_9PFSD, + }; =20 while ( (opt =3D getopt_long(argc, argv, "v", options, NULL)) !=3D -1 ) { @@ -543,6 +549,7 @@ int main(int argc, char** argv) } libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn, NULL); + libxl_device_9pfs_add(ctx, domid, &p9, NULL); libxl_ctx_free(ctx); =20 fd =3D creat(XEN_RUN_DIR "/xenstored.pid", 0666); diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 9a3e702557..804496a9f8 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -583,6 +583,13 @@ * libxl_console_add_xenstore() in libxl. */ #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1 + +/* + * LIBXL_HAVE_P9_ADD indicates presence of the function + * libxl_device_9pfs_add() in libxl. + */ +#define LIBXL_HAVE_P9_ADD 1 + /* * libxl ABI compatibility * @@ -2074,6 +2081,14 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint3= 2_t domid, uint32_t backend, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; =20 +/* libxl_device_9pfs_add writes the Xenstore entries for a domain's + * primary 9pfs device based on domid, and device parameters. + * If needed it will start the backend daemon. + */ +int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 = *p9, + const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + /* May be called with info_r =3D=3D NULL to check for domain's existence. * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return * ERROR_INVAL for this scenario). */ diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index ddeb4f20a7..48f894f070 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -206,6 +206,22 @@ static void libxl__device_p9_add(libxl__egc *egc, uint= 32_t domid, aodev->callback(egc, aodev); } =20 +int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 = *p9, + const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + libxl__ao_device *aodev; + + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action =3D LIBXL__DEVICE_ACTION_ADD; + aodev->callback =3D device_addrm_aocomplete; + + libxl__device_p9_add(egc, domid, p9, aodev); + + return AO_INPROGRESS; +} + #define libxl_device_p9_list NULL #define libxl_device_p9_compare NULL =20 --=20 2.35.3 From nobody Mon May 20 23:48:14 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=1708101149; cv=none; d=zohomail.com; s=zohoarc; b=BiraG1ZqUVkLckzFfE4LoJun2KJ2Jemr9I73+sKpj9FiEQ/mOa5i7XNUxhM9jSYM2x6D9y54WfD0pESuJYeqeHqC0PNgtQXfVUh+1sGPzDgHLBi83iW1+LULpPuId3CZMvZkwAJjsS1k2b2M5l2Sb9Z2Rs0eyu3YsJ8tJqYF00o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708101149; 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=GuKS5JMiiFYV782dbcVdzQvPQKcEtbDic1ZOTvla/ok=; b=hJuLUobVkI770F9DQXgKZs3ge5pdtxsddXgb9JUC/w8D4euP6HQr3aJJ5n16aQKP68tCatkXkoN3H0tp88PgwmlDqhXfkpwywEN/T41EhqvqfhpziVe0SJejqOAI8mBFfdD6459ujRivJ8G2GzcTsVXzRqUesdSpmf8yfC3yKV8= 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 1708101148820122.05097381808594; Fri, 16 Feb 2024 08:32:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682285.1061431 (Exim 4.92) (envelope-from ) id 1rb18F-0001q3-Sy; Fri, 16 Feb 2024 16:32:11 +0000 Received: by outflank-mailman (output) from mailman id 682285.1061431; Fri, 16 Feb 2024 16:32:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb18F-0001pu-Q3; Fri, 16 Feb 2024 16:32:11 +0000 Received: by outflank-mailman (input) for mailman id 682285; Fri, 16 Feb 2024 16:32:10 +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 1rb18E-0000Sx-TE for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:10 +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 ee6e4fe1-cce8-11ee-8a4f-1f161083a0e0; Fri, 16 Feb 2024 17:32:10 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (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 C43201FB73; Fri, 16 Feb 2024 16:32:09 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 896FF13343; Fri, 16 Feb 2024 16:32:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id 9YMgIAmOz2VyVAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:32: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: ee6e4fe1-cce8-11ee-8a4f-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708101129; 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=GuKS5JMiiFYV782dbcVdzQvPQKcEtbDic1ZOTvla/ok=; b=tRm4VtLfI/GQKkZOpQvVKyI2lfurK4zgGY9gZn6fJpp5hor/nDLqnHzasJimrn1ghGEqcI XLoyoiNuonSX5o2MCYwpOb2+byTVo7MfqA21x0INsZMy5YNDwNSy7mfklGDOHA7vGJeHGY BeCoZ3IpI5ZQzhHLRi2s76jzBPm7HJg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1708101129; 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=GuKS5JMiiFYV782dbcVdzQvPQKcEtbDic1ZOTvla/ok=; b=tRm4VtLfI/GQKkZOpQvVKyI2lfurK4zgGY9gZn6fJpp5hor/nDLqnHzasJimrn1ghGEqcI XLoyoiNuonSX5o2MCYwpOb2+byTVo7MfqA21x0INsZMy5YNDwNSy7mfklGDOHA7vGJeHGY BeCoZ3IpI5ZQzhHLRi2s76jzBPm7HJg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Jason Andryuk , Julien Grall Subject: [PATCH v8 5/8] tools/xenstored: mount 9pfs device in stubdom Date: Fri, 16 Feb 2024 17:31:36 +0100 Message-Id: <20240216163139.9093-6-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[suse.com,xen.org,citrix.com,gmail.com,amazon.com]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Flag: NO X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1708101150457100007 Content-Type: text/plain; charset="utf-8" Mount the 9pfs device in stubdom enabling it to use files. This has to happen in a worker thread in order to allow the main thread handling the required Xenstore accesses in parallel. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Julien Grall --- V3: - add logging in case of errors (Julien Grall) --- tools/xenstored/core.h | 6 +++++ tools/xenstored/domain.c | 2 ++ tools/xenstored/minios.c | 54 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index f6af086f01..fe0ee90581 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -36,6 +36,8 @@ #include "list.h" #include "hashtable.h" =20 +#define XENSTORE_LIB_DIR XEN_LIB_DIR "/xenstore" + #ifndef O_CLOEXEC #define O_CLOEXEC 0 /* O_CLOEXEC support is needed for Live Update in the daemon case. */ @@ -399,6 +401,10 @@ void handle_special_fds(void); int get_socket_fd(void); void set_socket_fd(int fd); =20 +#ifdef __MINIOS__ +void mount_9pfs(void); +#endif + /* Close stdin/stdout/stderr to complete daemonize */ void finish_daemonize(void); =20 diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 1a7d5e9756..64c8fd0cc3 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1236,6 +1236,8 @@ void stubdom_init(void) barf_perror("Failed to initialize stubdom"); =20 xenevtchn_notify(xce_handle, stubdom->port); + + mount_9pfs(); #endif } =20 diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index 22ac8defbd..562a9b4972 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -17,10 +17,20 @@ */ #include #include +#include +#include "talloc.h" #include "core.h" #include "utils.h" #include #include +#include +#include +#include +#include + +#define P9_STATE_PATH "device/9pfs/0/state" + +static void *p9_device; =20 void finish_daemonize(void) { @@ -74,3 +84,47 @@ int get_socket_fd(void) void set_socket_fd(int fd) { } + +static void mount_thread(void *p) +{ + xenbus_event_queue events =3D NULL; + char *err; + char *dummy; + + err =3D xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events); + if (err) { + log("error \"%s\" when setting watch on \"%s\"\n", err, + P9_STATE_PATH); + free(err); + return; + } + + for (;;) { + xenbus_wait_for_watch(&events); + + /* + * We only care for existence of the state node. + * State changes are handled in init_9pfront(). + */ + err =3D xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy); + if (!err) + break; + free(err); + } + + free(dummy); + + err =3D xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs"); + if (err) { + log("error \"%s\" when unwatching \"%s\", leaking watch\n", + err, P9_STATE_PATH); + free(err); + } + + p9_device =3D init_9pfront(0, XENSTORE_LIB_DIR); +} + +void mount_9pfs(void) +{ + create_thread("mount-9pfs", mount_thread, NULL); +} --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 1708101154292458.7669246142193; Fri, 16 Feb 2024 08:32:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682290.1061441 (Exim 4.92) (envelope-from ) id 1rb18N-0002QX-42; Fri, 16 Feb 2024 16:32:19 +0000 Received: by outflank-mailman (output) from mailman id 682290.1061441; Fri, 16 Feb 2024 16:32:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb18N-0002QP-0z; Fri, 16 Feb 2024 16:32:19 +0000 Received: by outflank-mailman (input) for mailman id 682290; Fri, 16 Feb 2024 16:32:17 +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 1rb18L-0000EA-Fz for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:17 +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 f1c86399-cce8-11ee-98f5-efadbce2ee36; Fri, 16 Feb 2024 17:32:15 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 7ED0A22286; Fri, 16 Feb 2024 16:32:15 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 388DA13343; Fri, 16 Feb 2024 16:32:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id EQsZDA+Oz2V5VAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:32: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: f1c86399-cce8-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Jason Andryuk , Julien Grall Subject: [PATCH v8 6/8] tools/xenstored: add helpers for filename handling Date: Fri, 16 Feb 2024 17:31:37 +0100 Message-Id: <20240216163139.9093-7-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 7ED0A22286 X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101156420100001 Content-Type: text/plain; charset="utf-8" Add some helpers for handling filenames which might need different implementations between stubdom and daemon environments: - expansion of relative filenames (those are not really defined today, just expand them to be relative to /var/lib/xen/xenstore) - expansion of xenstore_daemon_rundir() (used e.g. for saving the state file in case of live update - needs to be unchanged in the daemon case, but should result in /var/lib/xen/xenstore for stubdom) Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Julien Grall --- V3: - make absolute_filename() return a pointer to const (Julien Grall) --- tools/xenstored/core.c | 15 +++++++++++++-- tools/xenstored/core.h | 5 ++++- tools/xenstored/lu_daemon.c | 4 ++-- tools/xenstored/minios.c | 5 +++++ tools/xenstored/posix.c | 8 +++++++- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index 48fc787ac1..bada1ad9a2 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -63,7 +63,7 @@ char **orig_argv; LIST_HEAD(connections); int tracefd =3D -1; bool keep_orphans =3D false; -char *tracefile =3D NULL; +const char *tracefile =3D NULL; static struct hashtable *nodes; unsigned int trace_flags =3D TRACE_OBJ | TRACE_IO; =20 @@ -137,6 +137,17 @@ void trace_destroy(const void *data, const char *type) trace("obj: DESTROY %s %p\n", type, data); } =20 +/* + * Return an absolute filename. + * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR. + */ +const char *absolute_filename(const void *ctx, const char *filename) +{ + if (filename[0] !=3D '/') + return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename); + return talloc_strdup(ctx, filename); +} + void close_log(void) { if (tracefd >=3D 0) @@ -2759,7 +2770,7 @@ int main(int argc, char *argv[]) #endif =20 if (tracefile) - tracefile =3D talloc_strdup(NULL, tracefile); + tracefile =3D absolute_filename(NULL, tracefile); =20 #ifndef NO_LIVE_UPDATE /* Read state in case of live update. */ diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index fe0ee90581..e58779e88c 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -341,7 +341,7 @@ void close_log(void); extern int orig_argc; extern char **orig_argv; =20 -extern char *tracefile; +extern const char *tracefile; extern int tracefd; =20 /* Trace flag values must be kept in sync with trace_switches[] contents. = */ @@ -405,6 +405,9 @@ void set_socket_fd(int fd); void mount_9pfs(void); #endif =20 +const char *xenstore_rundir(void); +const char *absolute_filename(const void *ctx, const char *filename); + /* Close stdin/stdout/stderr to complete daemonize */ void finish_daemonize(void); =20 diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c index 71bcabadd3..6351111ab0 100644 --- a/tools/xenstored/lu_daemon.c +++ b/tools/xenstored/lu_daemon.c @@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state) state->size =3D 0; =20 state->filename =3D talloc_asprintf(NULL, "%s/state_dump", - xenstore_daemon_rundir()); + xenstore_rundir()); if (!state->filename) barf("Allocation failure"); =20 @@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx) int fd; =20 filename =3D talloc_asprintf(ctx, "%s/state_dump", - xenstore_daemon_rundir()); + xenstore_rundir()); if (!filename) return NULL; =20 diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index 562a9b4972..e70386f8c7 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -128,3 +128,8 @@ void mount_9pfs(void) { create_thread("mount-9pfs", mount_thread, NULL); } + +const char *xenstore_rundir(void) +{ + return XENSTORE_LIB_DIR; +} diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index 496329dfd1..d88c82d972 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -326,9 +326,10 @@ void early_init(bool live_update, bool dofork, const c= har *pidfile) { reopen_log(); =20 - /* Make sure xenstored directory exists. */ + /* Make sure xenstored directories exist. */ /* Errors ignored here, will be reported when we open files */ mkdir(xenstore_daemon_rundir(), 0755); + mkdir(XENSTORE_LIB_DIR, 0755); =20 if (dofork) { openlog("xenstored", 0, LOG_DAEMON); @@ -406,3 +407,8 @@ void set_socket_fd(int fd) { sock =3D fd; } + +const char *xenstore_rundir(void) +{ + return xenstore_daemon_rundir(); +} --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 170810115914085.37521524358306; Fri, 16 Feb 2024 08:32:39 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682293.1061451 (Exim 4.92) (envelope-from ) id 1rb18R-0002rs-E4; Fri, 16 Feb 2024 16:32:23 +0000 Received: by outflank-mailman (output) from mailman id 682293.1061451; Fri, 16 Feb 2024 16:32:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rb18R-0002rh-8k; Fri, 16 Feb 2024 16:32:23 +0000 Received: by outflank-mailman (input) for mailman id 682293; Fri, 16 Feb 2024 16:32:22 +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 1rb18Q-0000Sx-3t for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:22 +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 f524b614-cce8-11ee-8a4f-1f161083a0e0; Fri, 16 Feb 2024 17:32:21 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 22FF321241; Fri, 16 Feb 2024 16:32:21 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id DA67913343; Fri, 16 Feb 2024 16:32:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id +pDRMxSOz2V/VAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:32: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: f524b614-cce8-11ee-8a4f-1f161083a0e0 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Julien Grall , Jason Andryuk , Julien Grall Subject: [PATCH v8 7/8] tools/xenstored: support complete log capabilities in stubdom Date: Fri, 16 Feb 2024 17:31:38 +0100 Message-Id: <20240216163139.9093-8-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 22FF321241 X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101160437100001 Content-Type: text/plain; charset="utf-8" With 9pfs being fully available in Xenstore-stubdom now, there is no reason to not fully support all logging capabilities in stubdom. Open the logfile on stubdom only after the 9pfs file system has been mounted. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk Reviewed-by: Julien Grall Acked-by: Anthony PERARD --- V3: - remove now stale comment in sysconfig.xencommons.in (Julien Grall) --- .../Linux/init.d/sysconfig.xencommons.in | 1 - tools/hotplug/Linux/launch-xenstore.in | 1 + tools/xenstored/control.c | 30 +++++++++---------- tools/xenstored/minios.c | 3 ++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hot= plug/Linux/init.d/sysconfig.xencommons.in index 433e4849af..1bdd830d8a 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -58,7 +58,6 @@ XENSTORED_ARGS=3D ## Default: Not defined, tracing off # # Log xenstored messages -# Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_TRACE=3D[yes|on|1] =20 ## Type: integer diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/l= aunch-xenstore.in index e854ca1eb8..da4eeca7c5 100644 --- a/tools/hotplug/Linux/launch-xenstore.in +++ b/tools/hotplug/Linux/launch-xenstore.in @@ -98,6 +98,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @C= ONFIG_DIR@/@CONFIG_LEAF [ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=3D8 XENSTORE_DOMAIN_ARGS=3D"$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_S= IZE" [ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS=3D"$XENSTORE_D= OMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE" + [ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS=3D"$XENSTORE_DOMAIN_ARG= S -T xenstored-trace.log" =20 echo -n Starting $XENSTORE_DOMAIN_KERNEL... ${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1 diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c index b2f64d674f..dae23a5ac0 100644 --- a/tools/xenstored/control.c +++ b/tools/xenstored/control.c @@ -201,19 +201,6 @@ static int do_control_quota_s(const void *ctx, struct = connection *conn, return EINVAL; } =20 -#ifdef __MINIOS__ -static int do_control_memreport(const void *ctx, struct connection *conn, - const char **vec, int num) -{ - if (num) - return EINVAL; - - talloc_report_full(NULL, stdout); - - send_ack(conn, XS_CONTROL); - return 0; -} -#else static int do_control_logfile(const void *ctx, struct connection *conn, const char **vec, int num) { @@ -222,13 +209,26 @@ static int do_control_logfile(const void *ctx, struct= connection *conn, =20 close_log(); talloc_free(tracefile); - tracefile =3D talloc_strdup(NULL, vec[0]); + tracefile =3D absolute_filename(NULL, vec[0]); reopen_log(); =20 send_ack(conn, XS_CONTROL); return 0; } =20 +#ifdef __MINIOS__ +static int do_control_memreport(const void *ctx, struct connection *conn, + const char **vec, int num) +{ + if (num) + return EINVAL; + + talloc_report_full(NULL, stdout); + + send_ack(conn, XS_CONTROL); + return 0; +} +#else static int do_control_memreport(const void *ctx, struct connection *conn, const char **vec, int num) { @@ -309,10 +309,10 @@ static struct cmd_s cmds[] =3D { "[-c ] [-F] [-t ] \n" " Default timeout is 60 seconds.", 5 }, #endif + { "logfile", do_control_logfile, "" }, #ifdef __MINIOS__ { "memreport", do_control_memreport, "" }, #else - { "logfile", do_control_logfile, "" }, { "memreport", do_control_memreport, "[]" }, #endif { "print", do_control_print, "" }, diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index e70386f8c7..a229954cf4 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -122,6 +122,9 @@ static void mount_thread(void *p) } =20 p9_device =3D init_9pfront(0, XENSTORE_LIB_DIR); + + /* Start logging if selected. */ + reopen_log(); } =20 void mount_9pfs(void) --=20 2.35.3 From nobody Mon May 20 23:48:14 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; 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 1708101162910231.9869428170689; Fri, 16 Feb 2024 08:32:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.682296.1061461 (Exim 4.92) (envelope-from ) id 1rb18X-0003Mn-Q6; Fri, 16 Feb 2024 16:32:29 +0000 Received: by outflank-mailman (output) from mailman id 682296.1061461; Fri, 16 Feb 2024 16:32: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 1rb18X-0003Mg-MW; Fri, 16 Feb 2024 16:32:29 +0000 Received: by outflank-mailman (input) for mailman id 682296; Fri, 16 Feb 2024 16:32:28 +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 1rb18W-0000EA-JU for xen-devel@lists.xenproject.org; Fri, 16 Feb 2024 16:32:28 +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 f87ca945-cce8-11ee-98f5-efadbce2ee36; Fri, 16 Feb 2024 17:32:27 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (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 BA24821241; Fri, 16 Feb 2024 16:32:26 +0000 (UTC) Received: from imap2.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 imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 8334C13343; Fri, 16 Feb 2024 16:32:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id 8+6YHhqOz2WBVAAAn2gu4w (envelope-from ); Fri, 16 Feb 2024 16:32: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: f87ca945-cce8-11ee-98f5-efadbce2ee36 From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Jason Andryuk Subject: [PATCH v8 8/8] tools/xenstored: have a single do_control_memreport() Date: Fri, 16 Feb 2024 17:31:39 +0100 Message-Id: <20240216163139.9093-9-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240216163139.9093-1-jgross@suse.com> References: <20240216163139.9093-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: BA24821241 X-Spam-Flag: NO X-ZM-MESSAGEID: 1708101164390100001 Content-Type: text/plain; charset="utf-8" With 9pfs now available in Xenstore-stubdom, there is no reason to have distinct do_control_memreport() variants for the daemon and the stubdom implementations. Signed-off-by: Juergen Gross Reviewed-by: Jason Andryuk --- tools/xenstored/control.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c index dae23a5ac0..9561289179 100644 --- a/tools/xenstored/control.c +++ b/tools/xenstored/control.c @@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct= connection *conn, return 0; } =20 -#ifdef __MINIOS__ -static int do_control_memreport(const void *ctx, struct connection *conn, - const char **vec, int num) -{ - if (num) - return EINVAL; - - talloc_report_full(NULL, stdout); - - send_ack(conn, XS_CONTROL); - return 0; -} -#else static int do_control_memreport(const void *ctx, struct connection *conn, const char **vec, int num) { FILE *fp; + const char *filename; int fd; =20 if (num > 1) @@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struc= t connection *conn, if (!fp) close(fd); } - } else - fp =3D fopen(vec[0], "a"); + } else { + filename =3D absolute_filename(ctx, vec[0]); + if (!filename) + return ENOMEM; + fp =3D fopen(filename, "a"); + } =20 if (!fp) return EBADF; @@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct= connection *conn, send_ack(conn, XS_CONTROL); return 0; } -#endif =20 static int do_control_print(const void *ctx, struct connection *conn, const char **vec, int num) @@ -310,11 +301,7 @@ static struct cmd_s cmds[] =3D { " Default timeout is 60 seconds.", 5 }, #endif { "logfile", do_control_logfile, "" }, -#ifdef __MINIOS__ - { "memreport", do_control_memreport, "" }, -#else { "memreport", do_control_memreport, "[]" }, -#endif { "print", do_control_print, "" }, { "quota", do_control_quota, "[set ||max [-r]]" }, --=20 2.35.3