From nobody Fri Mar 14 13:20:52 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1738854786; cv=none; d=zohomail.com; s=zohoarc; b=mmQOzHKHu79VBvA+Vwgu3yi+ca8vC4n3WdTTIiXs+QPc/Xa3iSdABP9LFpufOf4XNNm4aDc52zJdWXwTwgmN9vIHbBFuFaWW5crkNjo4qc2eA3+H5vWH32iPDWtIuyOnOiSO7mYqFPxLTMtvk34KOdHvDVNKcyxKDqQj+qqA6i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1738854786; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; b=fDURcpb4doS3VBHkwtJp9TtM1+8e17AqHuRwv0/L637wmBZ0I3hhjt3j3FfOuD52xUBEm1E/eOg5/h4kF9A8eMETaehqurnp75XVS6qdAYMwxKPPFeamQuUK4uvn39DqP+ri2bYLAbEzAu92zzW60GtuQt+GCtGIQxqQJT3KoBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1738854786284700.4867983632577; Thu, 6 Feb 2025 07:13:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YP-0000Zk-F3; Thu, 06 Feb 2025 10:12:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tg3YM-0000Yq-5Y for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:30 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YK-00015t-4k for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:29 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso7082895e9.3 for ; Thu, 06 Feb 2025 07:12:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854746; x=1739459546; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; b=w39CDkRrNfp3UBBvB43S4xJ/J2OShWEnci5cs9MrpYyD482ikugbqxAKI2Sss/5nhk uNfhsYcaBsWcasxnsslb/e0jGFd1QTj+YvMcj7xtMDNzXV6cAtj2PfycJ+SfA0sW+i9m Wbs7BOHop5N4MnC1sij6FZO9d67ofluGVQwGISAMvnZb1DVa4DuyyWLLMWSEnhmy88Dt mzQFqCTGZ8isZvW2YutiSOUcTM6OX7Uy/yKKf3OMZMjq8I1JLm7keVrb4qlwkUioLn55 xYCwZwc3Re4Lk/LSO48tKpagnMgmEVrGjgtWCQtZF8YGEIR2ZHrvYLEuth7x7/bW5byh LNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854746; x=1739459546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; b=fHTnFjWMaS3C7igVhsSdPUhbDVTqllOais911fBWG8ruaG6wCs8pV5fL9iR1G5fO8t G4JbiSh6/kU9zwQc6YuYk8pzd1syMaxhBhdMxDhg9mxE3FQ9a6n9ljm+NTJl6WnXZTCS /8Twk9ofsnspMA4eQ+rhp6eiARqpWarqv8Q6ceU+DgD+fTbX7/WGHGscpS007v7+4R6C wx+oQg4jPil30+52NKDKtWTKr3CV3chhRlAWUbBMpr4N7gEA7X2U3kVAfwlQGRv3cPZ5 HaWeeMCHMTteBOG2yXyHWEZufCynspzU3DszsuW3HwPr8RX1tQYFzvyhcLtn2x7w7ZfJ TQyw== X-Gm-Message-State: AOJu0YwfoUmHgQXu5KcugCRUdCHHQBfUXEV/4aSl/t9YmfbG40nwcsVe kVDTCvCqGvmodazm1XzCwRKbfmd0n3bpAaYe2qj1Jwem/d/E1ysFgDcJADtyfkd+Kd5n+V9J0os L X-Gm-Gg: ASbGncu2xKqPdmsJmSES+M4Qo5o7e005M4fCgx7p9+do4zi7px0WNmMRZrjMnSPhIZ8 6K3BXVMJiJHl4PWepo4iiGhfj3fopi1nU5jXtCZ6ElSW9//CcN6YI46S5DMfeW/ieXfXkwYn1MQ R75UgZXOTrfsioyj8GJB/a5JObQI8qfqxa+kkUgFdQuO+krK5AVQtNlHww9klcEy1o2Q/QfEPJ/ 8Uci9yM76Va8Vazi1qUMtL/QcUzZmqcrb3QRgE30qjKonMgT5hqNHCmW/5MXQyQDEzoD64OehJZ p0dmULdB+thZOHNlkuD9WA== X-Google-Smtp-Source: AGHT+IGltjcEiJzKtyFhBuzcTM9FTBBsT6c8Iz681X4mia7nbFbis3sqG3SrhKUkUhfdM69JN0flYg== X-Received: by 2002:a05:600c:46d0:b0:434:e9ee:c1e with SMTP id 5b1f17b1804b1-4390d57762amr65606665e9.31.1738854746320; Thu, 06 Feb 2025 07:12:26 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 6/6] hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error Date: Thu, 6 Feb 2025 15:12:14 +0000 Message-Id: <20250206151214.2947842-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1738854787179019000 Content-Type: text/plain; charset="utf-8" Currently if the user requests via -machine dumpdtb=3Dfile.dtb that we dump the DTB, but the machine doesn't have a DTB, we silently ignore the option. This is confusing to users, and is a legacy of the old board-specific implementation of the option, where if the execution codepath didn't go via a call to qemu_fdt_dumpdtb() we would never handle the option. Now we handle the option in one place in machine.c, we can provide the user with a useful message if they asked us to dump a DTB when none exists. qmp_dumpdtb() already produces this error; remove the logic in handle_machine_dumpdtb() that was there specifically to avoid hitting it. While we're here, beef up the error message a bit with a hint, and make it consistent about "an FDT" rather than "a FDT". (In the qmp_dumpdtb() case this needs an ERRP_GUARD to make error_append_hint() work when the caller passes error_fatal.) Note that the three places where we might report "doesn't have an FDT" are hit in different situations: (1) in handle_machine_dumpdtb(), if CONFIG_FDT is not set: this is because the QEMU binary was built without libfdt at all. The build system will not let you build with a machine type that needs an FDT but no libfdt, so here we know both that the machine doesn't use FDT and that QEMU doesn't have the support: (2) in the device_tree-stub.c qmp_dumpdtb(): this is used when we had libfdt at build time but the target architecture didn't enable any machines which did "select DEVICE_TREE", so here we know that the machine doesn't use FDT. (3) in qmp_dumpdtb(), if current_machine->fdt is NULL all we know is that this machine never set it. That might be because it doesn't use FDT, or it might be because the user didn't pass an FDT on the command line and the machine doesn't autogenerate an FDT. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2733 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/core/machine.c | 6 ++---- system/device_tree-stub.c | 5 ++++- system/device_tree.c | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1b740071ac7..f0e45fbad9d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1701,15 +1701,13 @@ static void handle_machine_dumpdtb(MachineState *ms) if (!ms->dumpdtb) { return; } - if (!ms->fdt) { - /* Silently ignore dumpdtb option if there is nothing to dump */ - return; - } #ifdef CONFIG_FDT qmp_dumpdtb(ms->dumpdtb, &error_fatal); exit(0); #else error_report("This machine doesn't have an FDT"); + error_printf("(this machine type definitely doesn't use FDT, and " + "this QEMU doesn't have FDT support compiled in)\n"); exit(1); #endif } diff --git a/system/device_tree-stub.c b/system/device_tree-stub.c index bddda6fa37a..428330b0fec 100644 --- a/system/device_tree-stub.c +++ b/system/device_tree-stub.c @@ -5,6 +5,9 @@ #ifdef CONFIG_FDT void qmp_dumpdtb(const char *filename, Error **errp) { - error_setg(errp, "This machine doesn't have a FDT"); + ERRP_GUARD(); + + error_setg(errp, "This machine doesn't have an FDT"); + error_append_hint(errp, "(this machine type definitely doesn't use FDT= )\n"); } #endif diff --git a/system/device_tree.c b/system/device_tree.c index 56d4ac5650a..0d554240f93 100644 --- a/system/device_tree.c +++ b/system/device_tree.c @@ -635,11 +635,16 @@ out: =20 void qmp_dumpdtb(const char *filename, Error **errp) { + ERRP_GUARD(); + g_autoptr(GError) err =3D NULL; uint32_t size; =20 if (!current_machine->fdt) { - error_setg(errp, "This machine doesn't have a FDT"); + error_setg(errp, "This machine doesn't have an FDT"); + error_append_hint(errp, + "(Perhaps it doesn't support FDT at all, or perh= aps " + "you need to provide an FDT with the -fdt option= ?)\n"); return; } =20 --=20 2.34.1