Patchwork avoid core reading with bdrv_read (qemu-io)

login
register
mail settings
Submitter Frediano Ziglio
Date July 19, 2011, 7:33 a.m.
Message ID <CAHt6W4ef8yfC=ymNi4smYXhLw5ur0jCW4iKQ0CkAPTyp=vn7ew@mail.gmail.com>
Download mbox | patch
Permalink /patch/105399/
State New
Headers show

Comments

Frediano Ziglio - July 19, 2011, 7:33 a.m.
This patch apply to kevin coroutine-block branch and avoid code. It
fix "qcow: Use coroutines" patch. Test case:

$ ./qemu-img create -f qcow aaa.img 1G
Formatting 'aaa.img', fmt=qcow size=1073741824 encryption=off
$ ./qemu-io aaa.img
qemu-io> read 1024 1024
Segmentation fault

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
---
 block/qcow.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)


@@ -729,6 +731,7 @@ static int qcow_co_writev(BlockDriverState *bs,
int64_t sector_num,

     if (acb->qiov->niov > 1) {
         qemu_vfree(acb->orig_buf);
+        acb->orig_buf = NULL;
     }
     qemu_aio_release(acb);

Patch

diff --git a/block/qcow.c b/block/qcow.c
index 6f7973c..1386e92 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -573,7 +573,8 @@  static int qcow_aio_read_cb(void *opaque)

     if (acb->nb_sectors == 0) {
         /* request completed */
-        qemu_iovec_from_buffer(acb->qiov, acb->orig_buf, acb->qiov->size);
+        if (acb->orig_buf)
+            qemu_iovec_from_buffer(acb->qiov, acb->orig_buf, acb->qiov->size);
         return 0;
     }

@@ -648,6 +649,7 @@  static int qcow_co_readv(BlockDriverState *bs,
int64_t sector_num,

     if (acb->qiov->niov > 1) {
         qemu_vfree(acb->orig_buf);
+        acb->orig_buf = NULL;
     }
     qemu_aio_release(acb);