qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	=?UTF-8?q?Marc-Andr=C3=A9=20Lureau?=
	<marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 07/25] vhost: add vhost_set_log_base op
Date: Fri, 9 Oct 2015 00:16:57 +0300	[thread overview]
Message-ID: <1444338957-15293-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1444338957-15293-1-git-send-email-mst@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

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 <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/virtio/vhost-backend.h |  5 +++++
 hw/virtio/vhost-backend.c         |  8 ++++++++
 hw/virtio/vhost-user.c            | 17 ++++++++++++++++-
 hw/virtio/vhost.c                 |  6 +++---
 4 files changed, 32 insertions(+), 4 deletions(-)

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;
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 <sys/ioctl.h>
 
@@ -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;
-- 
MST

  parent reply	other threads:[~2015-10-08 21:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 21:16 [Qemu-devel] [PULL 00/25] virtio,pc features, fixes Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 01/25] configure: probe for memfd Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 02/25] linux-headers: add unistd.h Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 03/25] util: add linux-only memfd fallback Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 04/25] util: add memfd helpers Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 05/25] util: add fallback for qemu_memfd_alloc() Michael S. Tsirkin
2015-10-08 21:16 ` [Qemu-devel] [PULL 06/25] vhost: document log resizing Michael S. Tsirkin
2015-10-08 21:16 ` Michael S. Tsirkin [this message]
2015-10-08 21:17 ` [Qemu-devel] [PULL 08/25] vhost-user: add vhost_user_requires_shm_log() Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 09/25] vhost: alloc shareable log Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 10/25] vhost-user: send log shm fd along with log_base Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 11/25] vhost-user: add a migration blocker Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 12/25] vhost: use a function for each call Michael S. Tsirkin
2015-10-09  6:40   ` Thibaut Collet
2015-10-09  7:37     ` Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 13/25] vhost-user: document migration log Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 14/25] net: add trace_vhost_user_event Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 15/25] vhost user: add support of live migration Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 16/25] vhost user: add rarp sending after live migration for legacy guest Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 17/25] vhost-user: use an enum helper for features mask Michael S. Tsirkin
2015-10-08 21:17 ` [Qemu-devel] [PULL 18/25] vhost: add migration block if memfd failed Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 19/25] vhost-user-test: move wait_for_fds() out Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 20/25] vhost-user-test: remove useless static check Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 21/25] vhost-user-test: wrap server in TestServer struct Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 22/25] vhost-user-test: learn to tweak various qemu arguments Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 23/25] vhost-user-test: add live-migration test Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 24/25] vhost-user-test: check ownership during migration Michael S. Tsirkin
2015-10-08 21:18 ` [Qemu-devel] [PULL 25/25] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
2015-10-09 11:05 ` [Qemu-devel] [PULL 00/25] virtio,pc features, fixes Peter Maydell
2015-10-09 11:09   ` Peter Maydell
2015-10-09 13:10     ` Eduardo Otubo
2015-10-09 13:37   ` Peter Maydell

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=1444338957-15293-8-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).