[PATCH-for-9.0 25/25] hw/pci-host/raven: Propagate error in raven_realize()

Philippe Mathieu-Daudé posted 25 patches 1 year ago
Maintainers: David Hildenbrand <david@redhat.com>, Igor Mammedov <imammedo@redhat.com>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Jean-Christophe Dubois <jcd@tribudubois.net>, "Hervé Poussineau" <hpoussin@reactos.org>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Stefan Weil <sw@weilnetz.de>
[PATCH-for-9.0 25/25] hw/pci-host/raven: Propagate error in raven_realize()
Posted by Philippe Mathieu-Daudé 1 year ago
When an Error** reference is available, it is better to
propagate local errors, rather then using generic ones,
which might terminate the whole QEMU process.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/pci-host/raven.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
index 86c3a49087..e34ce47874 100644
--- a/hw/pci-host/raven.c
+++ b/hw/pci-host/raven.c
@@ -345,8 +345,10 @@ static void raven_realize(PCIDevice *d, Error **errp)
     d->config[PCI_LATENCY_TIMER] = 0x10;
     d->config[PCI_CAPABILITY_LIST] = 0x00;
 
-    memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZE,
-                                     &error_fatal);
+    if (!memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios",
+                                          BIOS_SIZE, errp)) {
+        return;
+    }
     memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),
                                 &s->bios);
     if (s->bios_name) {
-- 
2.41.0


Re: [PATCH-for-9.0 25/25] hw/pci-host/raven: Propagate error in raven_realize()
Posted by Gavin Shan 11 months, 4 weeks ago
On 11/21/23 07:32, Philippe Mathieu-Daudé wrote:
> When an Error** reference is available, it is better to
> propagate local errors, rather then using generic ones,
> which might terminate the whole QEMU process.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/pci-host/raven.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>


Re: [PATCH-for-9.0 25/25] hw/pci-host/raven: Propagate error in raven_realize()
Posted by Manos Pitsidianakis 1 year ago
On Mon, 20 Nov 2023 23:32, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>When an Error** reference is available, it is better to
>propagate local errors, rather then using generic ones,
>which might terminate the whole QEMU process.
>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>---
> hw/pci-host/raven.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
>index 86c3a49087..e34ce47874 100644
>--- a/hw/pci-host/raven.c
>+++ b/hw/pci-host/raven.c
>@@ -345,8 +345,10 @@ static void raven_realize(PCIDevice *d, Error **errp)
>     d->config[PCI_LATENCY_TIMER] = 0x10;
>     d->config[PCI_CAPABILITY_LIST] = 0x00;
> 
>-    memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios", BIOS_SIZE,
>-                                     &error_fatal);
>+    if (!memory_region_init_rom_nomigrate(&s->bios, OBJECT(s), "bios",
>+                                          BIOS_SIZE, errp)) {
>+        return;
>+    }
>     memory_region_add_subregion(get_system_memory(), (uint32_t)(-BIOS_SIZE),
>                                 &s->bios);
>     if (s->bios_name) {
>-- 
>2.41.0

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>