All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
@ 2017-01-23 21:21 Artyom Tarasenko
  2017-01-23 22:17 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Artyom Tarasenko @ 2017-01-23 21:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: mark.cave-ayland, peter.maydell, Artyom Tarasenko

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
---
 hw/sparc64/niagara.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index b55d4bb..e945b5a 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -35,6 +35,7 @@
 #include "hw/timer/sun4v-rtc.h"
 #include "exec/address-spaces.h"
 #include "sysemu/block-backend.h"
+#include "qemu/error-report.h"
 
 
 typedef struct NiagaraBoardState {
@@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
 #define NIAGARA_OBP_OFFSET  0x80000ULL
 #define PROM_SIZE_MAX       (4 * 1024 * 1024)
 
+static void add_rom_or_fail(const char *file, const hwaddr addr)
+{
+    if (rom_add_file_fixed(file, addr, -1)) {
+        error_report("Unable to load a firmware for -M niagara");
+        exit(1);
+    }
+
+}
 /* Niagara hardware initialisation */
 static void niagara_init(MachineState *machine)
 {
@@ -119,14 +128,13 @@ static void niagara_init(MachineState *machine)
                                          "sun4v.prom", PROM_SIZE_MAX);
     memory_region_add_subregion(sysmem, NIAGARA_PROM_BASE, &s->prom);
 
-    rom_add_file_fixed("nvram1", NIAGARA_NVRAM_BASE, -1);
-    rom_add_file_fixed("1up-md.bin", NIAGARA_MD_ROM_BASE, -1);
-    rom_add_file_fixed("1up-hv.bin", NIAGARA_HV_ROM_BASE, -1);
+    add_rom_or_fail("nvram1", NIAGARA_NVRAM_BASE);
+    add_rom_or_fail("1up-md.bin", NIAGARA_MD_ROM_BASE);
+    add_rom_or_fail("1up-hv.bin", NIAGARA_HV_ROM_BASE);
 
-    rom_add_file_fixed("reset.bin", NIAGARA_PROM_BASE, -1);
-    rom_add_file_fixed("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET, -1);
-    rom_add_file_fixed("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET,
-                       -1);
+    add_rom_or_fail("reset.bin", NIAGARA_PROM_BASE);
+    add_rom_or_fail("q.bin", NIAGARA_PROM_BASE + NIAGARA_Q_OFFSET);
+    add_rom_or_fail("openboot.bin", NIAGARA_PROM_BASE + NIAGARA_OBP_OFFSET);
 
     /* the virtual ramdisk is kind of initrd, but it resides
        outside of the partition RAM */
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
  2017-01-23 21:21 [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing Artyom Tarasenko
@ 2017-01-23 22:17 ` Peter Maydell
  2017-01-23 22:18   ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2017-01-23 22:17 UTC (permalink / raw)
  To: Artyom Tarasenko; +Cc: QEMU Developers, Mark Cave-Ayland

On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
> ---
>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index b55d4bb..e945b5a 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -35,6 +35,7 @@
>  #include "hw/timer/sun4v-rtc.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/block-backend.h"
> +#include "qemu/error-report.h"
>
>
>  typedef struct NiagaraBoardState {
> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>
> +static void add_rom_or_fail(const char *file, const hwaddr addr)
> +{
> +    if (rom_add_file_fixed(file, addr, -1)) {
> +        error_report("Unable to load a firmware for -M niagara");
> +        exit(1);

It would be nice to include the name of the file in the
error message -- or is that reported already inside
rom_add_file_fixed() somehow?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
  2017-01-23 22:17 ` Peter Maydell
@ 2017-01-23 22:18   ` Peter Maydell
  2017-01-24  8:21     ` Markus Armbruster
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2017-01-23 22:18 UTC (permalink / raw)
  To: Artyom Tarasenko; +Cc: QEMU Developers, Mark Cave-Ayland

On 23 January 2017 at 22:17, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>> ---
>>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
>> index b55d4bb..e945b5a 100644
>> --- a/hw/sparc64/niagara.c
>> +++ b/hw/sparc64/niagara.c
>> @@ -35,6 +35,7 @@
>>  #include "hw/timer/sun4v-rtc.h"
>>  #include "exec/address-spaces.h"
>>  #include "sysemu/block-backend.h"
>> +#include "qemu/error-report.h"
>>
>>
>>  typedef struct NiagaraBoardState {
>> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>>
>> +static void add_rom_or_fail(const char *file, const hwaddr addr)
>> +{
>> +    if (rom_add_file_fixed(file, addr, -1)) {
>> +        error_report("Unable to load a firmware for -M niagara");
>> +        exit(1);
>
> It would be nice to include the name of the file in the
> error message -- or is that reported already inside
> rom_add_file_fixed() somehow?

PS: doesn't this break 'make check' if the rom files
are missing?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
  2017-01-23 22:18   ` Peter Maydell
@ 2017-01-24  8:21     ` Markus Armbruster
  2017-01-24  9:32       ` Artyom Tarasenko
  2017-01-24  9:55       ` Peter Maydell
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Armbruster @ 2017-01-24  8:21 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Artyom Tarasenko, Mark Cave-Ayland, QEMU Developers

Peter Maydell <peter.maydell@linaro.org> writes:

> On 23 January 2017 at 22:17, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
>>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>>> ---
>>>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
>>> index b55d4bb..e945b5a 100644
>>> --- a/hw/sparc64/niagara.c
>>> +++ b/hw/sparc64/niagara.c
>>> @@ -35,6 +35,7 @@
>>>  #include "hw/timer/sun4v-rtc.h"
>>>  #include "exec/address-spaces.h"
>>>  #include "sysemu/block-backend.h"
>>> +#include "qemu/error-report.h"
>>>
>>>
>>>  typedef struct NiagaraBoardState {
>>> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>>>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>>>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>>>
>>> +static void add_rom_or_fail(const char *file, const hwaddr addr)
>>> +{
>>> +    if (rom_add_file_fixed(file, addr, -1)) {
>>> +        error_report("Unable to load a firmware for -M niagara");
>>> +        exit(1);
>>
>> It would be nice to include the name of the file in the
>> error message -- or is that reported already inside
>> rom_add_file_fixed() somehow?

Yes, it is, in rom_add_file():

    if (fd == -1) {
        fprintf(stderr, "Could not open option rom '%s': %s\n",
                rom->path, strerror(errno));
        goto err;
    }

> PS: doesn't this break 'make check' if the rom files
> are missing?

Yes, it does.  Obvious incremental fix appended.  It still prints
rom_add_file()'s message.  Swap the operands of && to get rid of it.



diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
index a14724f..6b78394 100644
--- a/hw/sparc64/niagara.c
+++ b/hw/sparc64/niagara.c
@@ -35,6 +35,7 @@
 #include "hw/timer/sun4v-rtc.h"
 #include "exec/address-spaces.h"
 #include "sysemu/block-backend.h"
+#include "sysemu/qtest.h"
 #include "qemu/error-report.h"
 
 
@@ -88,7 +89,7 @@ typedef struct NiagaraBoardState {
 
 static void add_rom_or_fail(const char *file, const hwaddr addr)
 {
-    if (rom_add_file_fixed(file, addr, -1)) {
+    if (rom_add_file_fixed(file, addr, -1) && !qtest_enabled()) {
         error_report("Unable to load a firmware for -M niagara");
         exit(1);
     }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
  2017-01-24  8:21     ` Markus Armbruster
@ 2017-01-24  9:32       ` Artyom Tarasenko
  2017-01-24  9:55       ` Peter Maydell
  1 sibling, 0 replies; 6+ messages in thread
From: Artyom Tarasenko @ 2017-01-24  9:32 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Peter Maydell, Mark Cave-Ayland, QEMU Developers

On Tue, Jan 24, 2017 at 9:21 AM, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>
>> On 23 January 2017 at 22:17, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> On 23 January 2017 at 21:21, Artyom Tarasenko <atar4qemu@gmail.com> wrote:
>>>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>>>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>
>>>> ---
>>>>  hw/sparc64/niagara.c | 22 +++++++++++++++-------
>>>>  1 file changed, 15 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
>>>> index b55d4bb..e945b5a 100644
>>>> --- a/hw/sparc64/niagara.c
>>>> +++ b/hw/sparc64/niagara.c
>>>> @@ -35,6 +35,7 @@
>>>>  #include "hw/timer/sun4v-rtc.h"
>>>>  #include "exec/address-spaces.h"
>>>>  #include "sysemu/block-backend.h"
>>>> +#include "qemu/error-report.h"
>>>>
>>>>
>>>>  typedef struct NiagaraBoardState {
>>>> @@ -85,6 +86,14 @@ typedef struct NiagaraBoardState {
>>>>  #define NIAGARA_OBP_OFFSET  0x80000ULL
>>>>  #define PROM_SIZE_MAX       (4 * 1024 * 1024)
>>>>
>>>> +static void add_rom_or_fail(const char *file, const hwaddr addr)
>>>> +{
>>>> +    if (rom_add_file_fixed(file, addr, -1)) {
>>>> +        error_report("Unable to load a firmware for -M niagara");
>>>> +        exit(1);
>>>
>>> It would be nice to include the name of the file in the
>>> error message -- or is that reported already inside
>>> rom_add_file_fixed() somehow?
>
> Yes, it is, in rom_add_file():
>
>     if (fd == -1) {
>         fprintf(stderr, "Could not open option rom '%s': %s\n",
>                 rom->path, strerror(errno));
>         goto err;
>     }
>
>> PS: doesn't this break 'make check' if the rom files
>> are missing?
>
> Yes, it does.  Obvious incremental fix appended.  It still prints
> rom_add_file()'s message.  Swap the operands of && to get rid of it.

Thanks, Markus. Will resubmit.

Artyom

> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index a14724f..6b78394 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -35,6 +35,7 @@
>  #include "hw/timer/sun4v-rtc.h"
>  #include "exec/address-spaces.h"
>  #include "sysemu/block-backend.h"
> +#include "sysemu/qtest.h"
>  #include "qemu/error-report.h"
>
>
> @@ -88,7 +89,7 @@ typedef struct NiagaraBoardState {
>
>  static void add_rom_or_fail(const char *file, const hwaddr addr)
>  {
> -    if (rom_add_file_fixed(file, addr, -1)) {
> +    if (rom_add_file_fixed(file, addr, -1) && !qtest_enabled()) {
>          error_report("Unable to load a firmware for -M niagara");
>          exit(1);
>      }



-- 
Regards,
Artyom Tarasenko

SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing
  2017-01-24  8:21     ` Markus Armbruster
  2017-01-24  9:32       ` Artyom Tarasenko
@ 2017-01-24  9:55       ` Peter Maydell
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2017-01-24  9:55 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Artyom Tarasenko, Mark Cave-Ayland, QEMU Developers

On 24 January 2017 at 08:21, Markus Armbruster <armbru@redhat.com> wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
>> PS: doesn't this break 'make check' if the rom files
>> are missing?
>
> Yes, it does.  Obvious incremental fix appended.  It still prints
> rom_add_file()'s message.  Swap the operands of && to get rid of it.

Yes, we should do this with
 (!qtest_enabled && rom_add_file_fixed(file, addr, -1))
to avoid printing the warnings in the make check output.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-24  9:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 21:21 [Qemu-devel] [PATCH 1/2] niagara: fail if a firmware file is missing Artyom Tarasenko
2017-01-23 22:17 ` Peter Maydell
2017-01-23 22:18   ` Peter Maydell
2017-01-24  8:21     ` Markus Armbruster
2017-01-24  9:32       ` Artyom Tarasenko
2017-01-24  9:55       ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.