qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 01/16] vvfat: Fix read-write mode
Date: Fri, 11 Nov 2011 18:39:13 +0100	[thread overview]
Message-ID: <1321033168-8739-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1321033168-8739-1-git-send-email-kwolf@redhat.com>

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 <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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_num<s->faked_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;
-- 
1.7.6.4

  reply	other threads:[~2011-11-11 17:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 17:39 [Qemu-devel] [PULL 00/16] Block patches for 1.0 Kevin Wolf
2011-11-11 17:39 ` Kevin Wolf [this message]
2011-11-11 17:39 ` [Qemu-devel] [PATCH 02/16] block: add eject request callback Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 03/16] atapi: implement eject requests Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 04/16] scsi-disk: " Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 05/16] nbd: treat EPIPE from NBD_DO_IT as success Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 06/16] qemu-nbd: trap SIGTERM Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 07/16] qemu-nbd: rename socket variable Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 08/16] qemu-nbd: move client to a thread Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 09/16] qemu-nbd: print error messages from the daemon through a pipe Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 10/16] qemu-nbd: fix socket creation race Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 11/16] qemu-nbd: open the block device after starting the client thread Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 12/16] block: Fix vpc initialization of the Dynamic Disk Header Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 13/16] hw/pc.c: Fix use-while-uninitialized of fd_type[] Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 14/16] block: Rename bdrv_co_flush to bdrv_co_flush_to_disk Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 15/16] block: Introduce bdrv_co_flush_to_os Kevin Wolf
2011-11-11 17:39 ` [Qemu-devel] [PATCH 16/16] block: Make cache=unsafe flush to the OS Kevin Wolf
2011-11-13 17:44 ` [Qemu-devel] [PULL 00/16] Block patches for 1.0 Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321033168-8739-2-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).