From nobody Thu Nov 6 20:32:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148774756133918.15905389887996; Tue, 21 Feb 2017 23:12:41 -0800 (PST) Received: from localhost ([::1]:50335 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgR6O-00089H-18 for importer@patchew.org; Wed, 22 Feb 2017 02:12:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgQVE-0003CL-Pw for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgQVC-0008EA-05 for qemu-devel@nongnu.org; Wed, 22 Feb 2017 01:34:16 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:45513) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgQVB-0008BQ-HY; Wed, 22 Feb 2017 01:34:13 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3vSndM3gCbz9sNM; Wed, 22 Feb 2017 17:33:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1487745239; bh=xBE6mcZKVoOKiJg/AsrTEjfEGEqNrOpId+zK9vQcxUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=knsQyrrgbA/cEZw9ZNzuET+othyhwh6ejww+Q6LdSyZF4s6D7bkiDF+YXanGlfAJ6 6/JapdeQ2tupwkVMVp1JFWBVInd1Z43yIOUV+eUHh1OCZB5m05H9YKmqTrqLvVNaCF GQSTisg/ilWKuhBLtbvbWnKkfQjiwTW49ADZ2QHs= From: David Gibson To: peter.maydell@linaro.org Date: Wed, 22 Feb 2017 17:33:36 +1100 Message-Id: <20170222063348.32176-32-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170222063348.32176-1-david@gibson.dropbear.id.au> References: <20170222063348.32176-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 31/43] hw/pci-host/prep: Do not use hw_error() in realize function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, qemu-ppc@nongnu.org, imammedo@redhat.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth hw_error() is for CPU related errors only (it prints out a register dump and calls abort()), so we should not use it if we just failed to load the bios image. Apart from that, realize() functions should not exit directly but always set the errp with error_setg() in case of errors instead. Additionally, move some code around and delete the bios memory subregion again in case of such an error, so that we leave a clean state when returning to the caller. Signed-off-by: Thomas Huth Reviewed-by: Herv=C3=A9 Poussineau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- hw/pci-host/prep.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index 5580293..260a119 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -309,7 +309,6 @@ static void raven_realize(PCIDevice *d, Error **errp) memory_region_set_readonly(&s->bios, true); memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE= ), &s->bios); - vmstate_register_ram_global(&s->bios); if (s->bios_name) { filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, s->bios_name); if (filename) { @@ -328,12 +327,15 @@ static void raven_realize(PCIDevice *d, Error **errp) } } } + g_free(filename); if (bios_size < 0 || bios_size > BIOS_SIZE) { - /* FIXME should error_setg() */ - hw_error("qemu: could not load bios image '%s'\n", s->bios_nam= e); + memory_region_del_subregion(get_system_memory(), &s->bios); + error_setg(errp, "Could not load bios image '%s'", s->bios_nam= e); + return; } - g_free(filename); } + + vmstate_register_ram_global(&s->bios); } =20 static const VMStateDescription vmstate_raven =3D { @@ -361,7 +363,6 @@ static void raven_class_init(ObjectClass *klass, void *= data) /* * Reason: PCI-facing part of the host bridge, not usable without * the host-facing part, which can't be device_add'ed, yet. - * Reason: realize() method uses hw_error(). */ dc->cannot_instantiate_with_device_add_yet =3D true; } --=20 2.9.3