From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBvbM-00070X-Dh for qemu-devel@nongnu.org; Sat, 11 Jun 2016 22:58:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBvbK-00065U-Hm for qemu-devel@nongnu.org; Sat, 11 Jun 2016 22:58:15 -0400 Date: Sun, 12 Jun 2016 10:58:02 +0800 From: Fam Zheng Message-ID: <20160612025802.GD27167@ad.usersys.redhat.com> References: <1465574722-27656-1-git-send-email-kwolf@redhat.com> <1465574722-27656-6-git-send-email-kwolf@redhat.com> <575B41A1.5030702@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <575B41A1.5030702@redhat.com> Subject: Re: [Qemu-devel] [PATCH 5/6] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Kevin Wolf , qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Fri, 06/10 16:39, Eric Blake wrote: > > +++ b/block/qcow2.c > > @@ -2903,36 +2903,20 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, > > int64_t pos) > > { > > BDRVQcow2State *s = bs->opaque; > > - int64_t total_sectors = bs->total_sectors; > > - bool zero_beyond_eof = bs->zero_beyond_eof; > > - int ret; > > > > BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); > > - bs->zero_beyond_eof = false; > > - ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov); > > - bs->zero_beyond_eof = zero_beyond_eof; > > - > > - /* bdrv_co_do_writev will have increased the total_sectors value to include > > - * the VM state - the VM state is however not an actual part of the block > > - * device, therefore, we need to restore the old value. */ > > - bs->total_sectors = total_sectors; > > - > > - return ret; > > + return bs->drv->bdrv_co_pwritev(bs, qcow2_vm_state_offset(s) + pos, > > + qiov->size, qiov, 0); > > } > > bs->drv->bdrv_co_pwritev() is an optional interface; not all the drivers > have it yet. Should you be asserting that it exists, and/or returning > an error if it does not? bs->drv is always qcow2 driver here so this is correct. > > > > > static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, > > int64_t pos) > > { > > BDRVQcow2State *s = bs->opaque; > > - bool zero_beyond_eof = bs->zero_beyond_eof; > > - int ret; > > > > BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); > > - bs->zero_beyond_eof = false; > > - ret = bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov); > > - bs->zero_beyond_eof = zero_beyond_eof; > > - > > - return ret; > > + return bs->drv->bdrv_co_preadv(bs, qcow2_vm_state_offset(s) + pos, > > + qiov->size, qiov, 0); > > Ditto. > Fam