From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjPzL-0005El-3a for qemu-devel@nongnu.org; Thu, 21 Nov 2013 03:51:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjPzE-000693-9h for qemu-devel@nongnu.org; Thu, 21 Nov 2013 03:51:51 -0500 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:62264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjPzE-00068O-2J for qemu-devel@nongnu.org; Thu, 21 Nov 2013 03:51:44 -0500 Received: by mail-wi0-f171.google.com with SMTP id ca18so1829109wib.4 for ; Thu, 21 Nov 2013 00:51:43 -0800 (PST) Date: Thu, 21 Nov 2013 09:51:39 +0100 From: Stefan Hajnoczi Message-ID: <20131121085139.GG27039@stefanha-thinkpad.redhat.com> References: <1384937429-9950-1-git-send-email-cyliu@suse.com> <20131120151538.GA6012@stefanha-thinkpad.muc.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] qemu-img create: add -o nocow option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu Cc: Kevin Wolf , qemu-devel@nongnu.org On Thu, Nov 21, 2013 at 11:33:56AM +0800, Chunyan Liu wrote: > 2013/11/20 Stefan Hajnoczi > > > On Wed, Nov 20, 2013 at 04:50:29PM +0800, Chunyan Liu wrote: > > > block/cow.c | 22 ++++++++++++++++++++++ > > > block/qcow.c | 22 ++++++++++++++++++++++ > > > block/qcow2.c | 22 ++++++++++++++++++++++ > > > > I think you can avoid modifying all the image formats: > > > > .bdrv_create() functions pass options to bdrv_create_file(). Therefore > > an image format like qcow2 does not need to parse the nocow option > > itself. Only raw-posix.c:.bdrv_create() needs to know about the nocow > > option. > > > > > In existing code, options passed to bdrv_create_file contains no option in > fact. > > And if we pass all options to bdrv_create_file directly, raw-posix.c: > .bdrv_create() will get NOCOW option but at the same time get SIZE option, > it > will create a file with total size. For cow/qcow/qcow2, I suppose it's not > expected? In current code, bdrv_create_file will create a zero-sized image > for > cow/qcow/qcow2. I see what the problem is: the loop that parses options does options++. So by the time it has processed them the options pointer will be NULL or point to a terminator option (option->name == NULL). I was confused because there has been a patch series which changes .bdrv_create() option parsing. But I forgot it hasn't been merged. https://lists.gnu.org/archive/html/qemu-devel/2013-08/msg01695.html Kevin: Have you looked at .bdrv_create() QEMUOptionParameter removal recently? Otherwise I'm inclined to merge Chunyan's patch - we can always refactor the code later when QEMUOptionParameter is removed. Stefan