Received: from eggs.gnu.org ([2001:4830:134:3::10]:36769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YR0xb-0003yT-Aw for qemu-devel@nongnu.org; Thu, 26 Feb 2015 11:06:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YR0xW-0002T0-9Z for qemu-devel@nongnu.org; Thu, 26 Feb 2015 11:06:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YR0xW-0002Sv-0b for qemu-devel@nongnu.org; Thu, 26 Feb 2015 11:06:42 -0500 Date: Thu, 26 Feb 2015 13:06:37 -0300 From: Eduardo Habkost Message-ID: <20150226160637.GC3513@thinpad.lan.raisama.net> References: <1424894306-26740-1-git-send-email-ehabkost@redhat.com> <1424894306-26740-9-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PULL 08/11] linux-user: Check for cpu_init() errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Andreas =?iso-8859-1?Q?F=E4rber?= , QEMU Developers On Thu, Feb 26, 2015 at 08:27:12AM +0900, Peter Maydell wrote: > On 26 February 2015 at 04:58, Eduardo Habkost wrote: > > This was the only caller of cpu_init() that was not checking for NULL > > yet. > > > > Reviewed-by: Paolo Bonzini > > Signed-off-by: Eduardo Habkost > > --- > > 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. Makes sense to me, but I would prefer that to be done by somebody faimilar with the *-user code as a follow-up. My intention was to simply fix the bug so that QEMU won't crash. -- Eduardo