* [Qemu-devel] [PATCH] vl.c: print error message if load fw_cfg file failed
@ 2018-10-07 4:33 Li Qiang
2018-10-07 17:48 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Li Qiang @ 2018-10-07 4:33 UTC (permalink / raw)
To: pbonzini; +Cc: qemu-devel, Li Qiang
It makes sense to print the error message while reading
file failed.
Signed-off-by: Li Qiang <liq3ea@163.com>
---
vl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index cc55fe04a2..3db410e771 100644
--- a/vl.c
+++ b/vl.c
@@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
buf = g_memdup(str, size);
} else {
- if (!g_file_get_contents(file, &buf, &size, NULL)) {
- error_report("can't load %s", file);
+ GError *error = NULL;
+ if (!g_file_get_contents(file, &buf, &size, &error)) {
+ error_report("can't load %s, %s", file, error->message);
return -1;
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vl.c: print error message if load fw_cfg file failed
2018-10-07 4:33 [Qemu-devel] [PATCH] vl.c: print error message if load fw_cfg file failed Li Qiang
@ 2018-10-07 17:48 ` Philippe Mathieu-Daudé
2018-10-08 16:36 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-07 17:48 UTC (permalink / raw)
To: Li Qiang, pbonzini; +Cc: qemu-devel
On 10/7/18 6:33 AM, Li Qiang wrote:
> It makes sense to print the error message while reading
> file failed.
>
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
> vl.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index cc55fe04a2..3db410e771 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
> size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
> buf = g_memdup(str, size);
> } else {
> - if (!g_file_get_contents(file, &buf, &size, NULL)) {
> - error_report("can't load %s", file);
> + GError *error = NULL;
> + if (!g_file_get_contents(file, &buf, &size, &error)) {
> + error_report("can't load %s, %s", file, error->message);
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> return -1;
> }
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] vl.c: print error message if load fw_cfg file failed
2018-10-07 17:48 ` Philippe Mathieu-Daudé
@ 2018-10-08 16:36 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-10-08 16:36 UTC (permalink / raw)
To: Li Qiang, Paolo Bonzini; +Cc: qemu-devel@nongnu.org Developers
Hi Li,
On Sun, Oct 7, 2018 at 7:48 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> On 10/7/18 6:33 AM, Li Qiang wrote:
> > It makes sense to print the error message while reading
> > file failed.
> >
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> > vl.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/vl.c b/vl.c
> > index cc55fe04a2..3db410e771 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -2207,8 +2207,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
> > size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
> > buf = g_memdup(str, size);
> > } else {
> > - if (!g_file_get_contents(file, &buf, &size, NULL)) {
> > - error_report("can't load %s", file);
> > + GError *error = NULL;
> > + if (!g_file_get_contents(file, &buf, &size, &error)) {
> > + error_report("can't load %s, %s", file, error->message);
You forgot:
g_error_free(error);
With the free:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> > return -1;
> > }
> > }
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-08 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-07 4:33 [Qemu-devel] [PATCH] vl.c: print error message if load fw_cfg file failed Li Qiang
2018-10-07 17:48 ` Philippe Mathieu-Daudé
2018-10-08 16:36 ` Philippe Mathieu-Daudé
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.