public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@cs.helsinki.fi
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
	gorcunov@gmail.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH v2 08/10] kvm tools: Hook virtio-blk completion to disk op completion
Date: Tue,  1 Nov 2011 18:06:17 +0200	[thread overview]
Message-ID: <1320163579-13811-8-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1320163579-13811-1-git-send-email-levinsasha928@gmail.com>

This patch connects the completion processing in virtio-blk to the completion
notification coming from disk image.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 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


  parent reply	other threads:[~2011-11-01 16:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 16:06 [PATCH v2 01/10] kvm tools: Switch to using an enum for disk image types Sasha Levin
2011-11-01 16:06 ` [PATCH v2 02/10] kvm tools: Remove the non-iov interface from disk image ops Sasha Levin
2011-11-01 16:06 ` [PATCH v2 03/10] kvm tools: Modify disk ops usage Sasha Levin
2011-11-01 16:06 ` [PATCH v2 04/10] kvm tools: Modify behaviour on missing ops ptr Sasha Levin
2011-11-01 16:06 ` [PATCH v2 05/10] kvm tools: Add optional callback on disk op completion Sasha Levin
2011-11-01 16:06 ` [PATCH v2 06/10] kvm tools: Remove qcow nowrite function Sasha Levin
2011-11-01 16:06 ` [PATCH v2 07/10] kvm tools: Split io request from completion Sasha Levin
2011-11-01 16:06 ` Sasha Levin [this message]
2011-11-01 16:06 ` [PATCH v2 09/10] kvm tools: Add aio read write functions Sasha Levin
2011-11-01 16:06 ` [PATCH v2 10/10] kvm tools: Use native vectored AIO in virtio-blk Sasha Levin
2011-11-01 17:07   ` Pekka Enberg

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=1320163579-13811-8-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    /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