* [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function
@ 2017-02-09 11:14 Thomas Huth
2017-02-09 23:10 ` Hervé Poussineau
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Huth @ 2017-02-09 11:14 UTC (permalink / raw)
To: Hervé Poussineau, qemu-ppc; +Cc: qemu-devel
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 <thuth@redhat.com>
---
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 = 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_name);
+ memory_region_del_subregion(get_system_memory(), &s->bios);
+ error_setg(errp, "Could not load bios image '%s'", s->bios_name);
+ return;
}
- g_free(filename);
}
+
+ vmstate_register_ram_global(&s->bios);
}
static const VMStateDescription vmstate_raven = {
@@ -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 = true;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function
2017-02-09 11:14 [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function Thomas Huth
@ 2017-02-09 23:10 ` Hervé Poussineau
2017-02-10 4:04 ` Philippe Mathieu-Daudé
2017-02-13 5:43 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2 siblings, 0 replies; 4+ messages in thread
From: Hervé Poussineau @ 2017-02-09 23:10 UTC (permalink / raw)
To: Thomas Huth, qemu-ppc; +Cc: qemu-devel
Le 09/02/2017 à 12:14, Thomas Huth a écrit :
> 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 <thuth@redhat.com>
> ---
> hw/pci-host/prep.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function
2017-02-09 11:14 [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function Thomas Huth
2017-02-09 23:10 ` Hervé Poussineau
@ 2017-02-10 4:04 ` Philippe Mathieu-Daudé
2017-02-13 5:43 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-02-10 4:04 UTC (permalink / raw)
To: Thomas Huth, qemu-ppc; +Cc: Hervé Poussineau, qemu-devel
On 02/09/2017 08:14 AM, Thomas Huth wrote:
> 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 <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> 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 = 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_name);
> + memory_region_del_subregion(get_system_memory(), &s->bios);
> + error_setg(errp, "Could not load bios image '%s'", s->bios_name);
> + return;
> }
> - g_free(filename);
> }
> +
> + vmstate_register_ram_global(&s->bios);
> }
>
> static const VMStateDescription vmstate_raven = {
> @@ -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 = true;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function
2017-02-09 11:14 [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function Thomas Huth
2017-02-09 23:10 ` Hervé Poussineau
2017-02-10 4:04 ` Philippe Mathieu-Daudé
@ 2017-02-13 5:43 ` David Gibson
2 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2017-02-13 5:43 UTC (permalink / raw)
To: Thomas Huth; +Cc: Hervé Poussineau, qemu-ppc, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 2573 bytes --]
On Thu, Feb 09, 2017 at 12:14:41PM +0100, Thomas Huth wrote:
> 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 <thuth@redhat.com>
Applied to ppc-for-2.9.
> ---
> 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 = 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_name);
> + memory_region_del_subregion(get_system_memory(), &s->bios);
> + error_setg(errp, "Could not load bios image '%s'", s->bios_name);
> + return;
> }
> - g_free(filename);
> }
> +
> + vmstate_register_ram_global(&s->bios);
> }
>
> static const VMStateDescription vmstate_raven = {
> @@ -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 = true;
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-13 6:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 11:14 [Qemu-devel] [PATCH] hw/pci-host/prep: Do not use hw_error() in realize function Thomas Huth
2017-02-09 23:10 ` Hervé Poussineau
2017-02-10 4:04 ` Philippe Mathieu-Daudé
2017-02-13 5:43 ` [Qemu-devel] [Qemu-ppc] " David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).