From patchwork Wed Jan 15 16:27:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 13940631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0B07C02187 for ; Wed, 15 Jan 2025 16:35:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.872762.1283796 (Exim 4.92) (envelope-from ) id 1tY6Mz-0004es-HI; Wed, 15 Jan 2025 16:35:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 872762.1283796; Wed, 15 Jan 2025 16:35:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tY6Mz-0004dw-CN; Wed, 15 Jan 2025 16:35:53 +0000 Received: by outflank-mailman (input) for mailman id 872762; Wed, 15 Jan 2025 16:35:51 +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 1tY6Mx-0003cf-BN for xen-devel@lists.xenproject.org; Wed, 15 Jan 2025 16:35:51 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c4c99897-d35e-11ef-99a4-01e77a169b0f; Wed, 15 Jan 2025 17:35:45 +0100 (CET) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tY6Mq-0000000GF6P-148j; Wed, 15 Jan 2025 16:35:44 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tY6Mq-00000001Hhn-00TQ; Wed, 15 Jan 2025 16:35:44 +0000 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: c4c99897-d35e-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description; bh=9nRlgfR/HkbXdsVZN1RJ5s3wIYDMgIRx7AVyt9JqyRI=; b=EyF73ntA9nNRs2USmFs3VhSFpr jNl690oAvAmfPoM3d9Lc2BGc1l1/s1/SeknFPeuJTpxrf1A7JrWVzvlQVDsOj8a+dRPFzbNaLKfAO j2WHAFN3Nr8xuSB9VGGQDHCWq5KJ/qkkMZ2jVCLwxPvkJkUdNMMJeg7knUUa+/YPzo2+VwEESoAFK dNaXDRzPMj19LMHea3hONYRgsJN3CMHRQBl2M0zn8N29N77J4yU9eQbTo/7OQhdX7ZE6KAFTAofUj XtLavELYf7LC08zgEem/hTcCPhKKoUEEmBaZ3rZkt0vw8s9Tz8tyDcbsrOICPyDnOxtVeDiDXWNhn dMfyec3g==; From: David Woodhouse To: qemu-devel@nongnu.org, =?utf-8?q?Roger_Pau_Monn=C3=A9?= Cc: Stefano Stabellini , Anthony PERARD , Paul Durrant , "Edgar E. Iglesias" , Kevin Wolf , Hanna Reitz , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Jason Wang , xen-devel@lists.xenproject.org, qemu-block@nongnu.org Subject: [PATCH v3 4/7] hw/xen: Use xs_node_read() from xen_console_get_name() Date: Wed, 15 Jan 2025 16:27:22 +0000 Message-ID: <20250115163542.291424-5-dwmw2@infradead.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250115163542.291424-1-dwmw2@infradead.org> References: <20250115163542.291424-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html From: David Woodhouse Now that xs_node_read() can construct a node path, no need to open-code it. Signed-off-by: David Woodhouse Reviewed-by: Anthony PERARD Acked-by: Roger Pau Monné --- hw/char/xen_console.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index cb39b21504..e61902461b 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -367,28 +367,28 @@ static char *xen_console_get_name(XenDevice *xendev, Error **errp) if (con->dev == -1) { XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev))); - char fe_path[XENSTORE_ABS_PATH_MAX + 1]; int idx = (xen_mode == XEN_EMULATE) ? 0 : 1; + Error *local_err = NULL; char *value; /* Theoretically we could go up to INT_MAX here but that's overkill */ while (idx < 100) { if (!idx) { - snprintf(fe_path, sizeof(fe_path), - "/local/domain/%u/console", xendev->frontend_id); + value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err, + "/local/domain/%u/console", + xendev->frontend_id); } else { - snprintf(fe_path, sizeof(fe_path), - "/local/domain/%u/device/console/%u", - xendev->frontend_id, idx); + value = xs_node_read(xenbus->xsh, XBT_NULL, NULL, &local_err, + "/local/domain/%u/device/console/%u", + xendev->frontend_id, idx); } - value = qemu_xen_xs_read(xenbus->xsh, XBT_NULL, fe_path, NULL); if (!value) { if (errno == ENOENT) { con->dev = idx; + error_free(local_err); goto found; } - error_setg(errp, "cannot read %s: %s", fe_path, - strerror(errno)); + error_propagate(errp, local_err); return NULL; } free(value);