From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W43lv-00033y-BK for qemu-devel@nongnu.org; Fri, 17 Jan 2014 02:23:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W43ll-0004m9-Qo for qemu-devel@nongnu.org; Fri, 17 Jan 2014 02:23:19 -0500 Received: from mail-ee0-x229.google.com ([2a00:1450:4013:c00::229]:44240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W43ll-0004lt-JP for qemu-devel@nongnu.org; Fri, 17 Jan 2014 02:23:09 -0500 Received: by mail-ee0-f41.google.com with SMTP id e49so1968528eek.28 for ; Thu, 16 Jan 2014 23:23:08 -0800 (PST) Date: Fri, 17 Jan 2014 15:23:00 +0800 From: Stefan Hajnoczi Message-ID: <20140117072300.GC19441@stefanha-thinkpad.redhat.com> References: <677e470b5c2823a06afd63ba72f17f083d944fa3.1389644007.git.jcody@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <677e470b5c2823a06afd63ba72f17f083d944fa3.1389644007.git.jcody@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/2] block: resize backing file image during offline commit, if necessary List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Mon, Jan 13, 2014 at 03:18:45PM -0500, Jeff Cody wrote: > @@ -1904,7 +1904,19 @@ int bdrv_commit(BlockDriverState *bs) > } > } > > - total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; > + length = bdrv_getlength(bs); > + > + /* If our top snapshot is larger than the backing file image, > + * grow the backing file image if possible. If not possible, > + * we must return an error */ > + if (length > bdrv_getlength(bs->backing_hd)) { > + ret = bdrv_truncate(bs->backing_hd, length); bdrv_getlength() is allowed to return -errno. It's unlikely here but we should at least check bdrv_getlength(bs), probably also bdrv_getlength(bs->backing_hd).