Received: from eggs.gnu.org ([2001:4830:134:3::10]:35036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoqcC-0005B8-Sn for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:27:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoqcB-0006FS-SZ for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:27:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33712) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoqcB-0006FI-Kj for qemu-devel@nongnu.org; Wed, 21 Oct 2015 06:27:27 -0400 Date: Wed, 21 Oct 2015 13:27:24 +0300 From: "Michael S. Tsirkin" Message-ID: <1445423133-5119-17-git-send-email-mst@redhat.com> References: <1445423133-5119-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1445423133-5119-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 16/38] vhost: add vhost_set_log_base op List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Thibaut Collet , =?us-ascii?B?PT9VVEYtOD9xP01hcmMtQW5kcj1DMz1BOT0yMEx1cmVhdT89?= From: Marc-Andr=E9 Lureau Split VHOST_SET_LOG_BASE call in a seperate function callback, so that type safety works and more arguments can be added in the next patches. Signed-off-by: Marc-Andr=E9 Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Thibaut Collet --- include/hw/virtio/vhost-backend.h | 3 +++ hw/virtio/vhost-backend.c | 6 ++++++ hw/virtio/vhost-user.c | 16 +++++++++++++++- hw/virtio/vhost.c | 6 +++--- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-= backend.h index 7d4a8ad..c903573 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -28,6 +28,8 @@ typedef int (*vhost_backend_get_vq_index)(struct vhost_= dev *dev, int idx); typedef int (*vhost_backend_set_vring_enable)(struct vhost_dev *dev, int= enable); typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev); =20 +typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t bas= e); + typedef struct VhostOps { VhostBackendType backend_type; vhost_call vhost_call; @@ -36,6 +38,7 @@ typedef struct VhostOps { vhost_backend_get_vq_index vhost_backend_get_vq_index; vhost_backend_set_vring_enable vhost_backend_set_vring_enable; vhost_backend_memslots_limit vhost_backend_memslots_limit; + vhost_set_log_base_op vhost_set_log_base; } VhostOps; =20 extern const VhostOps user_ops; diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 910d8e0..5846c37 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -67,6 +67,11 @@ static int vhost_kernel_memslots_limit(struct vhost_de= v *dev) return limit; } =20 +static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base) +{ + return vhost_kernel_call(dev, VHOST_SET_LOG_BASE, &base); +} + static const VhostOps kernel_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_KERNEL, .vhost_call =3D vhost_kernel_call, @@ -74,6 +79,7 @@ static const VhostOps kernel_ops =3D { .vhost_backend_cleanup =3D vhost_kernel_cleanup, .vhost_backend_get_vq_index =3D vhost_kernel_get_vq_index, .vhost_backend_memslots_limit =3D vhost_kernel_memslots_limit, + .vhost_set_log_base =3D vhost_set_log_base, }; =20 int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backe= nd_type) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 9585637..5d51289 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -242,7 +242,6 @@ static int vhost_user_call(struct vhost_dev *dev, uns= igned long int request, break; =20 case VHOST_USER_SET_FEATURES: - case VHOST_USER_SET_LOG_BASE: case VHOST_USER_SET_PROTOCOL_FEATURES: msg.u64 =3D *((__u64 *) arg); msg.size =3D sizeof(m.u64); @@ -367,6 +366,20 @@ static int vhost_user_call(struct vhost_dev *dev, un= signed long int request, return 0; } =20 +static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base) +{ + VhostUserMsg msg =3D { + .request =3D VHOST_USER_SET_LOG_BASE, + .flags =3D VHOST_USER_VERSION, + .u64 =3D base, + .size =3D sizeof(m.u64), + }; + + vhost_user_write(dev, &msg, NULL, 0); + + return 0; +} + static int vhost_user_init(struct vhost_dev *dev, void *opaque) { unsigned long long features; @@ -453,4 +466,5 @@ const VhostOps user_ops =3D { .vhost_backend_get_vq_index =3D vhost_user_get_vq_index, .vhost_backend_set_vring_enable =3D vhost_user_set_vring_enable, .vhost_backend_memslots_limit =3D vhost_user_memslots_limit, + .vhost_set_log_base =3D vhost_set_log_base, }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f5ecaf0..f2b31b7 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -352,7 +352,7 @@ static inline void vhost_dev_log_resize(struct vhost_= dev* dev, uint64_t size) =20 /* inform backend of log switching, this must be done before releasing the current log, to ensure no logging is lost */ - r =3D dev->vhost_ops->vhost_call(dev, VHOST_SET_LOG_BASE, &log_base)= ; + r =3D dev->vhost_ops->vhost_set_log_base(dev, log_base); assert(r >=3D 0); vhost_log_put(dev, true); dev->log =3D log; @@ -1167,8 +1167,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIOD= evice *vdev) hdev->log_size =3D vhost_get_log_size(hdev); hdev->log =3D vhost_log_get(hdev->log_size); log_base =3D (uintptr_t)hdev->log->log; - r =3D hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, - hdev->log_size ? &log_base : NUL= L); + r =3D hdev->vhost_ops->vhost_set_log_base(hdev, + hdev->log_size ? log_bas= e : 0); if (r < 0) { r =3D -errno; goto fail_log; --=20 MST