From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yx5ZQ-0007jx-DN for qemu-devel@nongnu.org; Mon, 25 May 2015 23:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yx5ZN-0002VS-6b for qemu-devel@nongnu.org; Mon, 25 May 2015 23:30:24 -0400 Date: Tue, 26 May 2015 11:30:14 +0800 From: Fam Zheng Message-ID: <20150526033014.GA5044@ad.nay.redhat.com> References: <1432266060-22104-1-git-send-email-famz@redhat.com> <1432266060-22104-2-git-send-email-famz@redhat.com> <55633519.9030407@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55633519.9030407@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 1/8] block: Add "base" option to bdrv_get_block_status List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-block@nongnu.org, Jeff Cody , qemu-devel@nongnu.org, qemu-stable@nongnu.org, Stefan Hajnoczi , jsnow@redhat.com, wangxiaolong@ucloud.cn On Mon, 05/25 16:43, Paolo Bonzini wrote: > > > On 22/05/2015 05:40, Fam Zheng wrote: > > +{ > > + BlockDriverState *p; > > + int64_t ret; > > + > > + assert(bs != base); > > + for (p = bs; p != base; p = p->backing_hd) { > > + ret = bdrv_co_get_block_status(p, sector_num, nb_sectors, pnum); > > It's a bit ugly to have different parameters for bdrv_get_block_status > and bdrv_co_get_block_status. I'll add bdrv_get_block_status_above and rewrite bdrv_get_block_status body on top. > > > + if (ret < 0 || ret & BDRV_BLOCK_ALLOCATED) { > > + break; > > + } > > + } > > + return ret; > > +} > > + > > I think BDRV_BLOCK_ALLOCATED will always be true if passing NULL as the > base, so patch 3 still needs a tweak. OK, will use BDRV_BLOCK_DATA there. > > But, more important, you need extra logic to correct the output value of > pnum, as in bdrv_is_allocated_above. bdrv_co_get_block_status should fix pnum. Fam