From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNiSF-0006YH-MD for qemu-devel@nongnu.org; Tue, 08 Nov 2011 04:58:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNiSE-0002W4-P4 for qemu-devel@nongnu.org; Tue, 08 Nov 2011 04:58:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNiSE-0002Vt-Hy for qemu-devel@nongnu.org; Tue, 08 Nov 2011 04:58:54 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA89wrUV019962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Nov 2011 04:58:53 -0500 Message-ID: <4EB8FD5A.5050704@redhat.com> Date: Tue, 08 Nov 2011 10:58:50 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1320746116-17968-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1320746116-17968-1-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vvfat: Fix read-write mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On 11/08/2011 10:55 AM, Kevin Wolf wrote: > vvfat used to directly call into the qcow2 block driver instead of using the > block.c wrappers. With the coroutine conversion, this stopped working. > > Signed-off-by: Kevin Wolf > --- > block/vvfat.c | 44 +++++++++++++++++++++++--------------------- > 1 files changed, 23 insertions(+), 21 deletions(-) > > diff --git a/block/vvfat.c b/block/vvfat.c > index 8511fe5..131680f 100644 > --- a/block/vvfat.c > +++ b/block/vvfat.c > @@ -1254,15 +1254,15 @@ static int vvfat_read(BlockDriverState *bs, int64_t sector_num, > return -1; > if (s->qcow) { > int n; > - if (s->qcow->drv->bdrv_is_allocated(s->qcow, > - sector_num, nb_sectors-i,&n)) { > + if (bdrv_is_allocated(s->qcow, sector_num, nb_sectors-i,&n)) { > DLOG(fprintf(stderr, "sectors %d+%d allocated\n", (int)sector_num, n)); > - if (s->qcow->drv->bdrv_read(s->qcow, sector_num, buf+i*0x200, n)) > - return -1; > - i += n - 1; > - sector_num += n - 1; > - continue; > - } > + if (bdrv_read(s->qcow, sector_num, buf + i*0x200, n)) { > + return -1; > + } > + i += n - 1; > + sector_num += n - 1; > + continue; > + } > DLOG(fprintf(stderr, "sector %d not allocated\n", (int)sector_num)); > } > if(sector_numfaked_sectors) { > @@ -1516,7 +1516,7 @@ static inline int cluster_was_modified(BDRVVVFATState* s, uint32_t cluster_num) > return 0; > > for (i = 0; !was_modified&& i< s->sectors_per_cluster; i++) > - was_modified = s->qcow->drv->bdrv_is_allocated(s->qcow, > + was_modified = bdrv_is_allocated(s->qcow, > cluster2sector(s, cluster_num) + i, 1,&dummy); > > return was_modified; > @@ -1665,16 +1665,16 @@ static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s, > int64_t offset = cluster2sector(s, cluster_num); > > vvfat_close_current_file(s); > - for (i = 0; i< s->sectors_per_cluster; i++) > - if (!s->qcow->drv->bdrv_is_allocated(s->qcow, > - offset + i, 1,&dummy)) { > - if (vvfat_read(s->bs, > - offset, s->cluster_buffer, 1)) > - return -1; > - if (s->qcow->drv->bdrv_write(s->qcow, > - offset, s->cluster_buffer, 1)) > - return -2; > - } > + for (i = 0; i< s->sectors_per_cluster; i++) { > + if (!bdrv_is_allocated(s->qcow, offset + i, 1,&dummy)) { > + if (vvfat_read(s->bs, offset, s->cluster_buffer, 1)) { > + return -1; > + } > + if (bdrv_write(s->qcow, offset, s->cluster_buffer, 1)) { > + return -2; > + } > + } > + } > } > } > > @@ -2619,7 +2619,9 @@ static int do_commit(BDRVVVFATState* s) > return ret; > } > > - s->qcow->drv->bdrv_make_empty(s->qcow); > + if (s->qcow->drv->bdrv_make_empty) { > + s->qcow->drv->bdrv_make_empty(s->qcow); > + } > > memset(s->used_clusters, 0, sector2cluster(s, s->sector_count)); > > @@ -2714,7 +2716,7 @@ DLOG(checkpoint()); > * Use qcow backend. Commit later. > */ > DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, nb_sectors)); > - ret = s->qcow->drv->bdrv_write(s->qcow, sector_num, buf, nb_sectors); > + ret = bdrv_write(s->qcow, sector_num, buf, nb_sectors); > if (ret< 0) { > fprintf(stderr, "Error writing to qcow backend\n"); > return ret; Reviewed-by: Paolo Bonzini