From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH v2 08/10] kvm tools: Hook virtio-blk completion to disk op completion Date: Tue, 1 Nov 2011 18:06:17 +0200 Message-ID: <1320163579-13811-8-git-send-email-levinsasha928@gmail.com> References: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:50583 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932206Ab1KAQIX (ORCPT ); Tue, 1 Nov 2011 12:08:23 -0400 Received: by mail-ey0-f174.google.com with SMTP id 27so6345771eye.19 for ; Tue, 01 Nov 2011 09:08:23 -0700 (PDT) In-Reply-To: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: This patch connects the completion processing in virtio-blk to the completion notification coming from disk image. Signed-off-by: Sasha Levin --- tools/kvm/virtio/blk.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index be53111..5969d27 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -119,26 +119,26 @@ static void virtio_blk_do_io_request(struct kvm *kvm, struct blk_dev_req *req) switch (req_hdr->type) { case VIRTIO_BLK_T_IN: block_cnt = disk_image__read(bdev->disk, req_hdr->sector, iov + 1, - in + out - 2, NULL); + in + out - 2, req); break; case VIRTIO_BLK_T_OUT: block_cnt = disk_image__write(bdev->disk, req_hdr->sector, iov + 1, - in + out - 2, NULL); + in + out - 2, req); break; case VIRTIO_BLK_T_FLUSH: block_cnt = disk_image__flush(bdev->disk); + virtio_blk_complete(req, block_cnt); break; case VIRTIO_BLK_T_GET_ID: block_cnt = VIRTIO_BLK_ID_BYTES; disk_image__get_serial(bdev->disk, (iov + 1)->iov_base, &block_cnt); + virtio_blk_complete(req, block_cnt); break; default: pr_warning("request type %d", req_hdr->type); block_cnt = -1; break; } - - virtio_blk_complete(req, block_cnt); } static void virtio_blk_do_io(struct kvm *kvm, struct virt_queue *vq, struct blk_dev *bdev) @@ -261,6 +261,8 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk) for (i = 0; i < ARRAY_SIZE(bdev->reqs); i++) list_add(&bdev->reqs[i].list, &bdev->req_list); + disk_image__set_callback(bdev->disk, virtio_blk_complete); + if (compat_id != -1) compat_id = compat__add_message("virtio-blk device was not detected", "While you have requested a virtio-blk device, " -- 1.7.7.1