From nobody Wed Feb 11 04:20:28 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=1678209512; cv=none; d=zohomail.com; s=zohoarc; b=L3egRM5JvcbV4uQQIBONuafZ2TRgxFJJYmkVkvCfijkbM82aWRFjF2UEgdmL8rHJVvmWBW/ErUrBA1Aghem9m6ep17bcX4qn6If6Ej2Ja3oknPQpZTvKZDp091q+XcA4YTdIszJHOdkzpOmLLS2SMmtR4NuOd5GwOL4K21GytG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678209512; 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=0E400xq9eyjPpQs8f/JfkPvcDe4VR1r79BDrhDwRCtg=; b=GwidHADXg9UetnFeP2YSg5R5m9wCmb3rYOWJfIrfK42ovQd8Y+uKBys9beTJexZVGWjR9VejvNaTzY8WQjqRbQ00BcSBqiHBOpDXpI5uJvlHlBVA67nygiW6MoZOtha7OgnpDH9o5bkyzhfUEB6JsMxmt5WNkH+jLL+Rq0tW/7k= 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 1678209512334474.0124515855614; Tue, 7 Mar 2023 09:18:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.507647.781428 (Exim 4.92) (envelope-from ) id 1pZawu-0000bS-V7; Tue, 07 Mar 2023 17:18:04 +0000 Received: by outflank-mailman (output) from mailman id 507647.781428; Tue, 07 Mar 2023 17:18:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pZawu-0000bL-SL; Tue, 07 Mar 2023 17:18:04 +0000 Received: by outflank-mailman (input) for mailman id 507647; Tue, 07 Mar 2023 17:18:03 +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 1pZaws-0000az-L6 for xen-devel@lists.xenproject.org; Tue, 07 Mar 2023 17:18:03 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 03123a0f-bd0c-11ed-96b5-2f268f93b82a; Tue, 07 Mar 2023 18:18:01 +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 1pZawk-006axf-1j; Tue, 07 Mar 2023 17:17:54 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1pZawk-009chO-0F; Tue, 07 Mar 2023 17:17:54 +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: 03123a0f-bd0c-11ed-96b5-2f268f93b82a 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=0E400xq9eyjPpQs8f/JfkPvcDe4VR1r79BDrhDwRCtg=; b=S+1p+2lB/6nyzWVhW7N8Cw4oHf yw3rtOg/BRZsgJxIcMRzHUyxlJPpu9WU6i8qkWScpBajA1NKeSyJ8Gn8dYGZvmleELmtSp+kg075L MoKaCiWFB0A2XvRFDSRhj+ubVGFDNsPf/kaD5ajp5x6mx7cQErpOQmOuQb9anAcDkMEgZuEQ1Liu2 5WAul0/sUr7jnXckTRw5ijY8cix4sqdLFxgD1s5mQozQv1HirEVt+kMcVkLi2LXeuG3X/m/2hWfg5 vPRnLJWMJzYCxKrFJO6RqpsJ+7HPh88TUj0YVh+7uXfKOhc9HJQXSIIdrjApLLaM+X0AWU8NP744k zQnpZqPQ==; 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, Juan Quintela , "Dr . David Alan Gilbert" , Peter Maydell Subject: [PATCH v2 14/27] hw/xen: Move xenstore_store_pv_console_info to xen_console.c Date: Tue, 7 Mar 2023 17:17:37 +0000 Message-Id: <20230307171750.2293175-15-dwmw2@infradead.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230307171750.2293175-1-dwmw2@infradead.org> References: <20230307171750.2293175-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: 1678209514103100008 Content-Type: text/plain; charset="utf-8" From: David Woodhouse There's no need for this to be in the Xen accel code, and as we want to use the Xen console support with KVM-emulated Xen we'll want to have a platform-agnostic version of it. Make it use GString to build up the path while we're at it. Signed-off-by: David Woodhouse Reviewed-by: Paul Durrant --- accel/xen/xen-all.c | 61 ------------------------------------------- hw/char/xen_console.c | 45 +++++++++++++++++++++++++++++-- include/hw/xen/xen.h | 2 -- 3 files changed, 43 insertions(+), 65 deletions(-) diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 425216230f..2d51c41e40 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -29,67 +29,6 @@ xc_interface *xen_xc; xenforeignmemory_handle *xen_fmem; xendevicemodel_handle *xen_dmod; =20 -static int store_dev_info(int domid, Chardev *cs, const char *string) -{ - struct xs_handle *xs =3D NULL; - char *path =3D NULL; - char *newpath =3D NULL; - char *pts =3D NULL; - int ret =3D -1; - - /* Only continue if we're talking to a pty. */ - if (!CHARDEV_IS_PTY(cs)) { - return 0; - } - pts =3D cs->filename + 4; - - /* We now have everything we need to set the xenstore entry. */ - xs =3D xs_open(0); - if (xs =3D=3D NULL) { - fprintf(stderr, "Could not contact XenStore\n"); - goto out; - } - - path =3D xs_get_domain_path(xs, domid); - if (path =3D=3D NULL) { - fprintf(stderr, "xs_get_domain_path() error\n"); - goto out; - } - newpath =3D realloc(path, (strlen(path) + strlen(string) + - strlen("/tty") + 1)); - if (newpath =3D=3D NULL) { - fprintf(stderr, "realloc error\n"); - goto out; - } - path =3D newpath; - - strcat(path, string); - strcat(path, "/tty"); - if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) { - fprintf(stderr, "xs_write for '%s' fail", string); - goto out; - } - ret =3D 0; - -out: - free(path); - xs_close(xs); - - return ret; -} - -void xenstore_store_pv_console_info(int i, Chardev *chr) -{ - if (i =3D=3D 0) { - store_dev_info(xen_domid, chr, "/console"); - } else { - char buf[32]; - snprintf(buf, sizeof(buf), "/device/console/%d", i); - store_dev_info(xen_domid, chr, buf); - } -} - - static void xenstore_record_dm_state(const char *state) { struct xs_handle *xs; diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index ad8638a86d..c7a19c0e7c 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -173,6 +173,48 @@ static void xencons_send(struct XenConsole *con) =20 /* -------------------------------------------------------------------- */ =20 +static int store_con_info(struct XenConsole *con) +{ + Chardev *cs =3D qemu_chr_fe_get_driver(&con->chr); + char *pts =3D NULL; + char *dom_path; + GString *path; + int ret =3D -1; + + /* Only continue if we're talking to a pty. */ + if (!CHARDEV_IS_PTY(cs)) { + return 0; + } + pts =3D cs->filename + 4; + + dom_path =3D qemu_xen_xs_get_domain_path(xenstore, xen_domid); + if (!dom_path) { + return 0; + } + + path =3D g_string_new(dom_path); + free(dom_path); + + if (con->xendev.dev) { + g_string_append_printf(path, "/device/console/%d", con->xendev.dev= ); + } else { + g_string_append(path, "/console"); + } + g_string_append(path, "/tty"); + + if (xenstore_write_str(con->console, path->str, pts)) { + fprintf(stderr, "xenstore_write_str for '%s' fail", path->str); + goto out; + } + ret =3D 0; + +out: + g_string_free(path, true); + free(path); + + return ret; +} + static int con_init(struct XenLegacyDevice *xendev) { struct XenConsole *con =3D container_of(xendev, struct XenConsole, xen= dev); @@ -215,8 +257,7 @@ static int con_init(struct XenLegacyDevice *xendev) &error_abort); } =20 - xenstore_store_pv_console_info(con->xendev.dev, - qemu_chr_fe_get_driver(&con->chr)); + store_con_info(con); =20 out: g_free(type); diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 03983939f9..56b1c2a827 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -39,8 +39,6 @@ int xen_is_pirq_msi(uint32_t msi_data); =20 qemu_irq *xen_interrupt_controller_init(void); =20 -void xenstore_store_pv_console_info(int i, Chardev *chr); - void xen_register_framebuffer(struct MemoryRegion *mr); =20 #endif /* QEMU_HW_XEN_H */ --=20 2.39.0