From nobody Tue Feb 10 06:57:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1677771331; cv=none; d=zohomail.com; s=zohoarc; b=hdOYAnfk55m0xpV1frhFWM6SZmTQdCET9kxOVlWu7LHOJfOpWpdyLIA7A7kP+RPTDwZi9lX3qvk56cTUegYQF6kjn04HPRH7DxSSEaGyS0wmb5lU6m7ourkOa0IpKhRzkS1IAZm3wsYN86jX3Pf8b94HZKUOAvmveRSfDtW3ofw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677771331; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CiL9BoVIR8kjLuSX6JDQTr7KEneQW3tf2NeAtIBuItk=; b=j07D++sVx+GtQai6hu+40eDwP3cQkAYg6vHP7csjjoU0I+6no/kfS+nHnZPMxEjmgkBLeMZprPnZ5L3iX1VxLEmG7LyKKG4QOd8sxt0w5FnfkcpxZ+KoVHeBrnHUl6433t2KFMplk5WaJt+/aiGWNkxZy3Rt4dJpvl85LyUcWY4= 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677771331719475.05999099194275; Thu, 2 Mar 2023 07:35:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.505051.777599 (Exim 4.92) (envelope-from ) id 1pXkxL-0001ig-LW; Thu, 02 Mar 2023 15:34:55 +0000 Received: by outflank-mailman (output) from mailman id 505051.777599; Thu, 02 Mar 2023 15:34:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pXkxL-0001dE-Ay; Thu, 02 Mar 2023 15:34:55 +0000 Received: by outflank-mailman (input) for mailman id 505051; Thu, 02 Mar 2023 15:34:53 +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 1pXkxJ-0001Jw-Q2 for xen-devel@lists.xenproject.org; Thu, 02 Mar 2023 15:34:53 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c2137f89-b90f-11ed-a550-8520e6686977; Thu, 02 Mar 2023 16:34:49 +0100 (CET) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pXkx4-002UNG-6D; Thu, 02 Mar 2023 15:34:38 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pXkx4-004uyn-0c; Thu, 02 Mar 2023 15:34:38 +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 X-Inumbo-ID: c2137f89-b90f-11ed-a550-8520e6686977 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=CiL9BoVIR8kjLuSX6JDQTr7KEneQW3tf2NeAtIBuItk=; b=tgdtvoyyO6EkUx17MYdIZ0BC9v +wdjiO/YftXiwsYf+hXfDk6NgeLX1UioTSk+oTsvWRln8Y4UpzIb9ox5+6Il7d2/8PS3tr0lyn4Sb TEUktrIAaojfPt4Ays0rukS2gPFFe9iBizcg7kAVjGGnL4Ylnk15Y5hXWI2eHJvKcatermggwrH6W zNh5SyVCIkKqaWPNt3t+OZbJUMBIreqLpd8NceeKzmK43/vzVha/JU7H96T4HswEBWpdvA7F0F6d9 tKxdaXLhxwgJSOuYj7ZiUlq0NKCxKQtDHHzimMEhUKFC9kZxwTIGlq9QRnU7vfSqxxQGpFjXIvl5j bhw4V3Nw==; From: David Woodhouse To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Paul Durrant , Joao Martins , Ankur Arora , Stefano Stabellini , vikram.garhwal@amd.com, Anthony Perard , xen-devel@lists.xenproject.org Subject: [RFC PATCH v1 08/25] hw/xen: Create initial XenStore nodes Date: Thu, 2 Mar 2023 15:34:18 +0000 Message-Id: <20230302153435.1170111-9-dwmw2@infradead.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230302153435.1170111-1-dwmw2@infradead.org> References: <20230302153435.1170111-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1677771333616100019 Content-Type: text/plain; charset="utf-8" From: Paul Durrant Signed-off-by: Paul Durrant Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- hw/i386/kvm/xen_xenstore.c | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 1b1358ad4c..5a8e38aae7 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -76,9 +76,39 @@ struct XenXenstoreState *xen_xenstore_singleton; static void xen_xenstore_event(void *opaque); static void fire_watch_cb(void *opaque, const char *path, const char *toke= n); =20 +static void G_GNUC_PRINTF (4, 5) relpath_printf(XenXenstoreState *s, + GList *perms, + const char *relpath, + const char *fmt, ...) +{ + gchar *abspath; + gchar *value; + va_list args; + GByteArray *data; + int err; + + abspath =3D g_strdup_printf("/local/domain/%u/%s", xen_domid, relpath); + va_start(args, fmt); + value =3D g_strdup_vprintf(fmt, args); + va_end(args); + + data =3D g_byte_array_new_take((void *)value, strlen(value)); + + err =3D xs_impl_write(s->impl, DOMID_QEMU, XBT_NULL, abspath, data); + assert(!err); + + g_byte_array_unref(data); + + err =3D xs_impl_set_perms(s->impl, DOMID_QEMU, XBT_NULL, abspath, perm= s); + assert(!err); + + g_free(abspath); +} + static void xen_xenstore_realize(DeviceState *dev, Error **errp) { XenXenstoreState *s =3D XEN_XENSTORE(dev); + GList *perms; =20 if (xen_mode !=3D XEN_EMULATE) { error_setg(errp, "Xen xenstore support is for Xen emulation"); @@ -102,6 +132,46 @@ static void xen_xenstore_realize(DeviceState *dev, Err= or **errp) xen_xenstore_event, NULL, NULL, NULL, s); =20 s->impl =3D xs_impl_create(xen_domid); + + /* Populate the default nodes */ + + /* Nodes owned by 'dom0' but readable by the guest */ + perms =3D g_list_append(NULL, xs_perm_as_string(XS_PERM_NONE, DOMID_QE= MU)); + perms =3D g_list_append(perms, xs_perm_as_string(XS_PERM_READ, xen_dom= id)); + + relpath_printf(s, perms, "", "%s", ""); + + relpath_printf(s, perms, "domid", "%u", xen_domid); + + relpath_printf(s, perms, "control/platform-feature-xs_reset_watches", = "%u", 1); + relpath_printf(s, perms, "control/platform-feature-multiprocessor-susp= end", "%u", 1); + + relpath_printf(s, perms, "platform/acpi", "%u", 1); + relpath_printf(s, perms, "platform/acpi_s3", "%u", 1); + relpath_printf(s, perms, "platform/acpi_s4", "%u", 1); + relpath_printf(s, perms, "platform/acpi_laptop_slate", "%u", 0); + + g_list_free_full(perms, g_free); + + /* Nodes owned by the guest */ + perms =3D g_list_append(NULL, xs_perm_as_string(XS_PERM_NONE, xen_domi= d)); + + relpath_printf(s, perms, "attr", "%s", ""); + + relpath_printf(s, perms, "control/shutdown", "%s", ""); + relpath_printf(s, perms, "control/feature-poweroff", "%u", 1); + relpath_printf(s, perms, "control/feature-reboot", "%u", 1); + relpath_printf(s, perms, "control/feature-suspend", "%u", 1); + relpath_printf(s, perms, "control/feature-s3", "%u", 1); + relpath_printf(s, perms, "control/feature-s4", "%u", 1); + + relpath_printf(s, perms, "data", "%s", ""); + relpath_printf(s, perms, "device", "%s", ""); + relpath_printf(s, perms, "drivers", "%s", ""); + relpath_printf(s, perms, "error", "%s", ""); + relpath_printf(s, perms, "feature", "%s", ""); + + g_list_free_full(perms, g_free); } =20 static bool xen_xenstore_is_needed(void *opaque) --=20 2.39.0