From patchwork Fri Oct 9 15:17:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 528373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 84D0B1406AA for ; Sat, 10 Oct 2015 05:08:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=tD3+Rhd9; dkim-atps=neutral Received: from lists.gnu.org ([208.118.235.17]:55325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zkc5Y-0002Ps-MN for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 14:08:16 -0400 Received: from localhost ([::1]:40935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zkc5Y-0004hr-Ar for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 14:08:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZR3-0001sX-UW for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkZR2-0007tU-Rf for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:17 -0400 Received: from mail-qg0-x22e.google.com ([2607:f8b0:400d:c04::22e]:33838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZR2-0007tP-Ny for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:16 -0400 Received: by qgez77 with SMTP id z77so71525151qge.1 for ; Fri, 09 Oct 2015 08:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Oa9xGDYLNza5X0Q+vXim0vuXHQtmX3iKNbI+fQC+pMk=; b=tD3+Rhd9DTYd3hQod/iXNPS88nPjRl9WPeDvILhzx5tkmdREd+OCYvSnOVCRBOcLvK SnJZYjwxeFBaQvQPB88RTvOm2gimiL6EmbZez9l/rGw7jIfP+B6nVfWMQ8A1B2GDbCFt uatEs9BK0+5bqNqrbR1/fDPS83vB+E7YfBj2X0WJUMFPxiQTMx+4Gu0hsSJ3YNLnwVKb OGZYDva9C0z5JXu6NaHvvsCoa1+Du9PaKe3ihUQLi8kGsmlvsKnFVI/fyieF11D+vtTJ SgmrlpUoILiAw1okm5AVw1WvDTN/1Vwy857UIclAA/RLjQuiLlJJ7j1utPsg8KfkdZ7N ytlg== X-Received: by 10.140.202.204 with SMTP id x195mr15833570qha.7.1444403896390; Fri, 09 Oct 2015 08:18:16 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id d66sm818868qgd.36.2015.10.09.08.18.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2015 08:18:15 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 9 Oct 2015 17:17:23 +0200 Message-Id: <1444403861-3240-10-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444403861-3240-1-git-send-email-marcandre.lureau@redhat.com> References: <1444403861-3240-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::22e Cc: haifeng.lin@huawei.com, mst@redhat.com, thibaut.collet@6wind.com, jasowang@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH v8 09/27] vhost: add vhost_set_log_base op X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x From: Marc-André 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é Lureau --- hw/virtio/vhost-backend.c | 8 ++++++++ hw/virtio/vhost-user.c | 17 ++++++++++++++++- hw/virtio/vhost.c | 6 +++--- include/hw/virtio/vhost-backend.h | 5 +++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 72d1392..88d33fd 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -11,6 +11,7 @@ #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-backend.h" #include "qemu/error-report.h" +#include "linux/vhost.h" #include @@ -49,12 +50,19 @@ static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx) return idx - dev->vq_index; } +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 = { .backend_type = VHOST_BACKEND_TYPE_KERNEL, .vhost_call = vhost_kernel_call, .vhost_backend_init = vhost_kernel_init, .vhost_backend_cleanup = vhost_kernel_cleanup, .vhost_backend_get_vq_index = vhost_kernel_get_vq_index, + + .vhost_set_log_base = vhost_set_log_base, }; int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index b11c0d2..fd4fcbf 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, unsigned long int request, break; case VHOST_USER_SET_FEATURES: - case VHOST_USER_SET_LOG_BASE: case VHOST_USER_SET_PROTOCOL_FEATURES: msg.u64 = *((__u64 *) arg); msg.size = sizeof(m.u64); @@ -367,6 +366,20 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request, return 0; } +static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base) +{ + VhostUserMsg msg = { + .request = VHOST_USER_SET_LOG_BASE, + .flags = VHOST_USER_VERSION, + .u64 = base, + .size = 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; @@ -447,4 +460,6 @@ const VhostOps user_ops = { .vhost_backend_cleanup = vhost_user_cleanup, .vhost_backend_get_vq_index = vhost_user_get_vq_index, .vhost_backend_set_vring_enable = vhost_user_set_vring_enable, + + .vhost_set_log_base = vhost_set_log_base, }; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 67e09fe..37bf603 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -336,7 +336,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size) /* inform backend of log switching, this must be done before releasing the current log, to ensure no logging is lost */ - r = dev->vhost_ops->vhost_call(dev, VHOST_SET_LOG_BASE, &log_base); + r = dev->vhost_ops->vhost_set_log_base(dev, log_base); assert(r >= 0); vhost_log_put(dev, true); dev->log = log; @@ -1140,8 +1140,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) hdev->log_size = vhost_get_log_size(hdev); hdev->log = vhost_log_get(hdev->log_size); log_base = (uintptr_t)hdev->log->log; - r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_LOG_BASE, - hdev->log_size ? &log_base : NULL); + r = hdev->vhost_ops->vhost_set_log_base(hdev, + hdev->log_size ? log_base : 0); if (r < 0) { r = -errno; goto fail_log; diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 3a0f6e2..c6b688a 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -27,13 +27,18 @@ typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev); 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_set_log_base_op)(struct vhost_dev *dev, uint64_t base); + typedef struct VhostOps { VhostBackendType backend_type; vhost_call vhost_call; + vhost_backend_init vhost_backend_init; vhost_backend_cleanup vhost_backend_cleanup; vhost_backend_get_vq_index vhost_backend_get_vq_index; vhost_backend_set_vring_enable vhost_backend_set_vring_enable; + + vhost_set_log_base_op vhost_set_log_base; } VhostOps; extern const VhostOps user_ops;