Received: from eggs.gnu.org ([2001:4830:134:3::10]:46026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwkKS-0006YY-ML for qemu-devel@nongnu.org; Mon, 16 Jun 2014 23:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwkKM-0007fi-9w for qemu-devel@nongnu.org; Mon, 16 Jun 2014 23:45:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwkKM-0007fY-0d for qemu-devel@nongnu.org; Mon, 16 Jun 2014 23:44:54 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5H3irjr000538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 16 Jun 2014 23:44:53 -0400 From: Fam Zheng Date: Tue, 17 Jun 2014 11:44:58 +0800 Message-Id: <1402976701-10271-4-git-send-email-famz@redhat.com> In-Reply-To: <1402976701-10271-1-git-send-email-famz@redhat.com> References: <1402976701-10271-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH 3/6] virtio-blk: Make request completion function virtual List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi virtio_blk_req_complete will call VirtIOBlock.complete_request() to push data and notify guest. No functional change. Later, this will allow dataplane to provide it's own (vring_) version. Signed-off-by: Fam Zheng --- hw/block/virtio-blk.c | 9 ++++++++- include/hw/virtio/virtio-blk.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b9d0d0a..f32c663 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -44,7 +44,8 @@ static void virtio_blk_free_request(VirtIOBlockReq *req) } } -static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) +static void virtio_blk_complete_request(VirtIOBlockReq *req, + unsigned char status) { VirtIOBlock *s = req->dev; VirtIODevice *vdev = VIRTIO_DEVICE(s); @@ -56,6 +57,11 @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, int status) virtio_notify(vdev, s->vq); } +static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) +{ + req->dev->complete_request(req, status); +} + static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, bool is_read) { @@ -751,6 +757,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) add_migration_state_change_notifier(&s->migration_state_notifier); #endif + s->complete_request = virtio_blk_complete_request; s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 2571e96..0398f4c 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -117,6 +117,7 @@ struct VirtIOBlkConf struct VirtIOBlockDataPlane; +struct VirtIOBlockReq; typedef struct VirtIOBlock { VirtIODevice parent_obj; BlockDriverState *bs; @@ -128,6 +129,8 @@ typedef struct VirtIOBlock { unsigned short sector_mask; bool original_wce; VMChangeStateEntry *change; + /* Function to push to vq and notify guest */ + void (*complete_request)(struct VirtIOBlockReq *req, unsigned char status); #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE Notifier migration_state_notifier; struct VirtIOBlockDataPlane *dataplane; -- 2.0.0