diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2010-05-24 10:53:41 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-05-24 10:53:41 -0500 |
commit | 9c678ccd15e71968ba9ce3cba704f429c5c7d539 (patch) | |
tree | 39aec570e79a4e5e23ade0415d1fddb980f7d2da /hw | |
parent | 3853528a913f0807170e2c78b6ea692f8515c859 (diff) | |
parent | 3e89cb0419cf5ff8f97fe219c6faa58f4c0c8728 (diff) | |
download | hqemu-9c678ccd15e71968ba9ce3cba704f429c5c7d539.zip hqemu-9c678ccd15e71968ba9ce3cba704f429c5c7d539.tar.gz |
Merge remote branch 'kwolf/for-anthony' into staging
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio-blk.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index b05d15e..5d7f1a2 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -105,8 +105,10 @@ static void virtio_blk_flush_complete(void *opaque, int ret) static VirtIOBlockReq *virtio_blk_alloc_request(VirtIOBlock *s) { - VirtIOBlockReq *req = qemu_mallocz(sizeof(*req)); + VirtIOBlockReq *req = qemu_malloc(sizeof(*req)); req->dev = s; + req->qiov.size = 0; + req->next = NULL; return req; } @@ -238,10 +240,20 @@ static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq, } } -static void virtio_blk_handle_flush(VirtIOBlockReq *req) +static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes, + VirtIOBlockReq *req, BlockDriverState **old_bs) { BlockDriverAIOCB *acb; + /* + * Make sure all outstanding writes are posted to the backing device. + */ + if (*old_bs != NULL) { + do_multiwrite(*old_bs, blkreq, *num_writes); + } + *num_writes = 0; + *old_bs = req->dev->bs; + acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req); if (!acb) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); @@ -314,7 +326,8 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req, req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base; if (req->out->type & VIRTIO_BLK_T_FLUSH) { - virtio_blk_handle_flush(req); + virtio_blk_handle_flush(mrb->blkreq, &mrb->num_writes, + req, &mrb->old_bs); } else if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) { virtio_blk_handle_scsi(req); } else if (req->out->type & VIRTIO_BLK_T_OUT) { |