qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 08/11] linux-user: Check for cpu_init() errors


From: Peter Maydell
Subject: Re: [Qemu-devel] [PULL 08/11] linux-user: Check for cpu_init() errors
Date: Thu, 26 Feb 2015 08:27:12 +0900

On 26 February 2015 at 04:58, Eduardo Habkost <address@hidden> wrote:
> This was the only caller of cpu_init() that was not checking for NULL
> yet.
>
> Reviewed-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Eduardo Habkost <address@hidden>
> ---
>  linux-user/main.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/main.c b/linux-user/main.c
> index d92702a..111c1ff 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -3453,10 +3453,17 @@ CPUArchState *cpu_copy(CPUArchState *env)
>  {
>      CPUState *cpu = ENV_GET_CPU(env);
>      CPUArchState *new_env = cpu_init(cpu_model);
> -    CPUState *new_cpu = ENV_GET_CPU(new_env);
> +    CPUState *new_cpu;
>      CPUBreakpoint *bp;
>      CPUWatchpoint *wp;
>
> +    if (!new_env) {
> +        fprintf(stderr, "cpu_copy: Failed to create new CPU\n");
> +        exit(1);
> +    }

Rather than bailing out here, it would be better to
propagate the failure out to the caller, which can
then fail the fork syscall it's trying to emulate
by returning a suitable error code to the guest.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]