From 6e40b3bfc7e82823cf4df5f0bf668f56db41e53a Mon Sep 17 00:00:00 2001 From: Alexander Yarygin Date: Wed, 17 Jun 2015 13:37:20 +0300 Subject: virtio-blk: Use blk_drain() to drain IO requests Each call of the virtio_blk_reset() function calls blk_drain_all(), which works for all existing BlockDriverStates, while draining only one is needed. This patch replaces blk_drain_all() by blk_drain() in virtio_blk_reset(). virtio_blk_data_plane_stop() should be called after draining because it restores vblk->complete_request. Cc: "Michael S. Tsirkin" Cc: Christian Borntraeger Cc: Cornelia Huck Cc: Kevin Wolf Cc: Paolo Bonzini Cc: Stefan Hajnoczi Signed-off-by: Alexander Yarygin Message-id: 1434537440-28236-3-git-send-email-yarygin@linux.vnet.ibm.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'hw') diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index cd539aa11c..bbb1fc1877 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -651,16 +651,21 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running, static void virtio_blk_reset(VirtIODevice *vdev) { VirtIOBlock *s = VIRTIO_BLK(vdev); - - if (s->dataplane) { - virtio_blk_data_plane_stop(s->dataplane); - } + AioContext *ctx; /* * This should cancel pending requests, but can't do nicely until there * are per-device request lists. */ - blk_drain_all(); + ctx = blk_get_aio_context(s->blk); + aio_context_acquire(ctx); + blk_drain(s->blk); + + if (s->dataplane) { + virtio_blk_data_plane_stop(s->dataplane); + } + aio_context_release(ctx); + blk_set_enable_write_cache(s->blk, s->original_wce); } -- cgit v1.2.3-55-g7522 From 25940fa7e57ffce9d495b4c2aadc39790535856d Mon Sep 17 00:00:00 2001 From: Lu Lina Date: Fri, 19 Jun 2015 14:27:34 +0800 Subject: nvme: Fix memleak in nvme_dma_read_prp Signed-off-by: Lu Lina Acked-by: Keith Busch Message-id: 1434695254-69808-1-git-send-email-kathy.wangting@huawei.com Signed-off-by: Stefan Hajnoczi --- hw/block/nvme.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw') diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 4b6d5e6078..c6a6a0e49a 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -154,6 +154,7 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, qemu_sglist_destroy(&qsg); return NVME_INVALID_FIELD | NVME_DNR; } + qemu_sglist_destroy(&qsg); return NVME_SUCCESS; } -- cgit v1.2.3-55-g7522 From 12048545019cd1d64c8147ea9277648e685fa489 Mon Sep 17 00:00:00 2001 From: Gonglei Date: Wed, 24 Jun 2015 17:29:24 +0800 Subject: virito-blk: drop duplicate check in_num = req->elem.in_num, and req->elem.in_num is checked in line 489, so the check about in_num variable is superflous, let's drop it. Signed-off-by: Gonglei Reviewed-by: Fam Zheng Message-id: 1435138164-11728-1-git-send-email-arei.gonglei@huawei.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index bbb1fc1877..6aefda4bf2 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -499,8 +499,7 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) iov_discard_front(&iov, &out_num, sizeof(req->out)); - if (in_num < 1 || - in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) { + if (in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) { error_report("virtio-blk request inhdr too short"); exit(1); } -- cgit v1.2.3-55-g7522