From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTWYa-0003ih-2H for qemu-devel@nongnu.org; Mon, 06 Jun 2011 05:57:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTWYY-0007xe-IP for qemu-devel@nongnu.org; Mon, 06 Jun 2011 05:57:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTWYX-0007xJ-Ur for qemu-devel@nongnu.org; Mon, 06 Jun 2011 05:57:10 -0400 Message-ID: <4DECA520.9020109@redhat.com> Date: Mon, 06 Jun 2011 12:00:00 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1306929912-15484-1-git-send-email-kwolf@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] bdrv_img_create: Fix segfault List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org Am 02.06.2011 00:34, schrieb Stefan Hajnoczi: > On Wed, Jun 1, 2011 at 1:05 PM, Kevin Wolf wrote: >> Block drivers that don't support creating images don't have a size option. Fail >> gracefully instead of segfaulting when trying to access the option's value. >> >> Signed-off-by: Kevin Wolf >> --- >> block.c | 5 +++-- >> 1 files changed, 3 insertions(+), 2 deletions(-) > > A command-line to reproduce the crash would be nice. qemu-img create -f bochs nbd:foo 32M It doesn't happen with a file protocol any more since we merge the create options of the protocol with those of the format (was introduced with Sheepdog). > I noticed this line above your fix: > set_option_parameter_int(param, BLOCK_OPT_SIZE, img_size); > > If I follow correctly there should be an "Unknown option 'size'" error > message before set_option_parameter_int() returns -1 (which we ignore) > and then crash. Right, this is what happens. > Perhaps we should just catch the error when set_option_parameter_int() fails? We could do that, but the segfault isn't really related to a failing set_option_parameter_int() but to the failing get_option_parameter(). I think it's good style not to rely on the error handling of an unrelated action some lines above. Adding some error handling there, too, wouldn't hurt, though. Kevin