Received: from eggs.gnu.org ([2001:4830:134:3::10]:40754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwmwI-0004F7-Or for qemu-devel@nongnu.org; Tue, 17 Jun 2014 02:32:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwmwC-0006XZ-Kt for qemu-devel@nongnu.org; Tue, 17 Jun 2014 02:32:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwmwC-0006XT-BC for qemu-devel@nongnu.org; Tue, 17 Jun 2014 02:32:08 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5H6W61i018151 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 17 Jun 2014 02:32:07 -0400 From: Fam Zheng Date: Tue, 17 Jun 2014 14:32:06 +0800 Message-Id: <1402986730-25642-4-git-send-email-famz@redhat.com> In-Reply-To: <1402986730-25642-1-git-send-email-famz@redhat.com> References: <1402986730-25642-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 3/7] 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..aed580c 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) { @@ -740,6 +746,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); + s->complete_request = virtio_blk_complete_request; #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE virtio_blk_data_plane_create(vdev, blk, &s->dataplane, &err); if (err != NULL) { 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