diff mbox series

[v2,4/5] x86: exit qemu if load_image fails

Message ID 1542765966-20244-5-git-send-email-lizhijian@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/5] unify len and addr type for memory/address APIs | expand

Commit Message

Li Zhijian Nov. 21, 2018, 2:06 a.m. UTC
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
CC: Eduardo Habkost <ehabkost@redhat.com>
CC: "Michael S. Tsirkin" <mst@redhat.com>
CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
 hw/i386/pc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Peter Maydell Nov. 30, 2018, 1:52 p.m. UTC | #1
On Wed, 21 Nov 2018 at 02:11, Li Zhijian <lizhijian@cn.fujitsu.com> wrote:
>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Richard Henderson <rth@twiddle.net>
> CC: Eduardo Habkost <ehabkost@redhat.com>
> CC: "Michael S. Tsirkin" <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> ---
>  hw/i386/pc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f095725..2ffe6fb 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -984,7 +984,10 @@ static void load_linux(PCMachineState *pcms,
>          initrd_addr = (initrd_max-initrd_size) & ~4095;
>
>          initrd_data = g_malloc(initrd_size);
> -        load_image(initrd_filename, initrd_data);
> +        if (load_image(initrd_filename, initrd_data) < 0) {
> +            fprintf(stderr, "failed to load initrd\n");
> +            exit(1);
> +        }

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f095725..2ffe6fb 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -984,7 +984,10 @@  static void load_linux(PCMachineState *pcms,
         initrd_addr = (initrd_max-initrd_size) & ~4095;
 
         initrd_data = g_malloc(initrd_size);
-        load_image(initrd_filename, initrd_data);
+        if (load_image(initrd_filename, initrd_data) < 0) {
+            fprintf(stderr, "failed to load initrd\n");
+            exit(1);
+        }
 
         fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
         fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);