diff mbox

[1/2] niagara: fail if a firmware file is missing

Message ID 87pojcx3zd.fsf@dusky.pond.sub.org
State New
Headers show

Commit Message

Markus Armbruster Jan. 24, 2017, 8:21 a.m. UTC
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.

Comments

Artyom Tarasenko Jan. 24, 2017, 9:32 a.m. UTC | #1
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);
>      }
Peter Maydell Jan. 24, 2017, 9:55 a.m. UTC | #2
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
diff mbox

Patch

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);
     }