All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Leo Yan" <leo.yan@linaro.org>
Subject: [PATCH v3 1/4] hw/virtio: Support set_config() callback in vhost-user-base
Date: Mon, 20 Nov 2023 12:37:18 +0800	[thread overview]
Message-ID: <20231120043721.50555-2-leo.yan@linaro.org> (raw)
In-Reply-To: <20231120043721.50555-1-leo.yan@linaro.org>

The Virtio input device invokes set_config() callback for retrieving
the event configuration info, but the callback is not supported in
vhost-user-base.

This patch adds support set_config() callback in vhost-user-base.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/virtio/vhost-user-base.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c
index 78cfa9a5bb..a83167191e 100644
--- a/hw/virtio/vhost-user-base.c
+++ b/hw/virtio/vhost-user-base.c
@@ -140,6 +140,22 @@ static void vub_get_config(VirtIODevice *vdev, uint8_t *config)
     }
 }
 
+static void vub_set_config(VirtIODevice *vdev, const uint8_t *config_data)
+{
+    VHostUserBase *vub = VHOST_USER_BASE(vdev);
+    int ret;
+
+    g_assert(vub->config_size && vub->vhost_user.supports_config == true);
+
+    ret = vhost_dev_set_config(&vub->vhost_dev, config_data,
+                               0, vub->config_size,
+                               VHOST_SET_CONFIG_TYPE_FRONTEND);
+    if (ret) {
+        error_report("vhost guest set device config space failed: %d", ret);
+        return;
+    }
+}
+
 /*
  * When the daemon signals an update to the config we just need to
  * signal the guest as we re-read the config on demand above.
@@ -337,6 +353,7 @@ static void vub_class_init(ObjectClass *klass, void *data)
     vdc->unrealize = vub_device_unrealize;
     vdc->get_features = vub_get_features;
     vdc->get_config = vub_get_config;
+    vdc->set_config = vub_set_config;
     vdc->set_status = vub_set_status;
 }
 
-- 
2.39.2



  reply	other threads:[~2023-11-20  4:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  4:37 [PATCH v3 0/4] virtio: Refactor vhost input stub Leo Yan
2023-11-20  4:37 ` Leo Yan [this message]
2023-11-20  4:37 ` [PATCH v3 2/4] docs/system: Add vhost-user-input documentation Leo Yan
2023-11-20  4:37 ` [PATCH v3 3/4] hw/virtio: Move vhost-user-input into virtio folder Leo Yan
2023-11-20  5:17   ` Manos Pitsidianakis
2023-11-20  4:37 ` [PATCH v3 4/4] hw/virtio: derive vhost-user-input from vhost-user-base Leo Yan
2023-11-20  5:20   ` Manos Pitsidianakis
2023-11-20  9:20 ` [PATCH v3 0/4] virtio: Refactor vhost input stub Michael S. Tsirkin
2023-12-25 16:06 ` Michael S. Tsirkin
2023-12-29  9:01   ` Leo Yan
2024-01-03 13:25     ` Alex Bennée
2024-01-04 12:34 ` Alex Bennée

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=20231120043721.50555-2-leo.yan@linaro.org \
    --to=leo.yan@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=kraxel@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.