* [PATCH] vhost-user-gpio: Configure vhost_dev when connecting
@ 2023-01-30 14:03 Akihiko Odaki
2023-01-31 3:25 ` Viresh Kumar
2023-01-31 9:46 ` Alex Bennée
0 siblings, 2 replies; 3+ messages in thread
From: Akihiko Odaki @ 2023-01-30 14:03 UTC (permalink / raw)
Cc: qemu-devel, Viresh Kumar, Alex Bennée, Michael S. Tsirkin,
Akihiko Odaki
vhost_dev_cleanup(), called from vu_gpio_disconnect(), clears vhost_dev
so vhost-user-gpio must set the members of vhost_dev each time
connecting.
do_vhost_user_cleanup() should also acquire the pointer to vqs directly
from VHostUserGPIO instead of referring to vhost_dev as it can be called
after vhost_dev_cleanup().
Fixes: 27ba7b027f ("hw/virtio: add boilerplate for vhost-user-gpio device")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
hw/virtio/vhost-user-gpio.c | 10 ++++++----
include/hw/virtio/vhost-user-gpio.h | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index fe3da32c74..d6927b610a 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -16,6 +16,7 @@
#include "trace.h"
#define REALIZE_CONNECTION_RETRIES 3
+#define VHOST_NVQS 2
/* Features required from VirtIO */
static const int feature_bits[] = {
@@ -208,8 +209,7 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio)
{
virtio_delete_queue(gpio->command_vq);
virtio_delete_queue(gpio->interrupt_vq);
- g_free(gpio->vhost_dev.vqs);
- gpio->vhost_dev.vqs = NULL;
+ g_free(gpio->vhost_vqs);
virtio_cleanup(vdev);
vhost_user_cleanup(&gpio->vhost_user);
}
@@ -229,6 +229,9 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
gpio->vhost_user.supports_config = true;
+ gpio->vhost_dev.nvqs = VHOST_NVQS;
+ gpio->vhost_dev.vqs = gpio->vhost_vqs;
+
ret = vhost_dev_init(vhost_dev, &gpio->vhost_user,
VHOST_BACKEND_TYPE_USER, 0, errp);
if (ret < 0) {
@@ -347,10 +350,9 @@ static void vu_gpio_device_realize(DeviceState *dev, Error **errp)
virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config));
- gpio->vhost_dev.nvqs = 2;
gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
- gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs);
+ gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS);
gpio->connected = false;
diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h
index a9305c5e6c..a9d3f9b049 100644
--- a/include/hw/virtio/vhost-user-gpio.h
+++ b/include/hw/virtio/vhost-user-gpio.h
@@ -23,7 +23,7 @@ struct VHostUserGPIO {
VirtIODevice parent_obj;
CharBackend chardev;
struct virtio_gpio_config config;
- struct vhost_virtqueue *vhost_vq;
+ struct vhost_virtqueue *vhost_vqs;
struct vhost_dev vhost_dev;
VhostUserState vhost_user;
VirtQueue *command_vq;
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-user-gpio: Configure vhost_dev when connecting
2023-01-30 14:03 [PATCH] vhost-user-gpio: Configure vhost_dev when connecting Akihiko Odaki
@ 2023-01-31 3:25 ` Viresh Kumar
2023-01-31 9:46 ` Alex Bennée
1 sibling, 0 replies; 3+ messages in thread
From: Viresh Kumar @ 2023-01-31 3:25 UTC (permalink / raw)
To: Akihiko Odaki; +Cc: qemu-devel, Alex Bennée, Michael S. Tsirkin
On 30-01-23, 23:03, Akihiko Odaki wrote:
> vhost_dev_cleanup(), called from vu_gpio_disconnect(), clears vhost_dev
> so vhost-user-gpio must set the members of vhost_dev each time
> connecting.
>
> do_vhost_user_cleanup() should also acquire the pointer to vqs directly
> from VHostUserGPIO instead of referring to vhost_dev as it can be called
> after vhost_dev_cleanup().
>
> Fixes: 27ba7b027f ("hw/virtio: add boilerplate for vhost-user-gpio device")
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> hw/virtio/vhost-user-gpio.c | 10 ++++++----
> include/hw/virtio/vhost-user-gpio.h | 2 +-
> 2 files changed, 7 insertions(+), 5 deletions(-)
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost-user-gpio: Configure vhost_dev when connecting
2023-01-30 14:03 [PATCH] vhost-user-gpio: Configure vhost_dev when connecting Akihiko Odaki
2023-01-31 3:25 ` Viresh Kumar
@ 2023-01-31 9:46 ` Alex Bennée
1 sibling, 0 replies; 3+ messages in thread
From: Alex Bennée @ 2023-01-31 9:46 UTC (permalink / raw)
To: Akihiko Odaki; +Cc: qemu-devel, Viresh Kumar, Michael S. Tsirkin
Akihiko Odaki <akihiko.odaki@daynix.com> writes:
> vhost_dev_cleanup(), called from vu_gpio_disconnect(), clears vhost_dev
> so vhost-user-gpio must set the members of vhost_dev each time
> connecting.
>
> do_vhost_user_cleanup() should also acquire the pointer to vqs directly
> from VHostUserGPIO instead of referring to vhost_dev as it can be called
> after vhost_dev_cleanup().
>
> Fixes: 27ba7b027f ("hw/virtio: add boilerplate for vhost-user-gpio device")
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-31 9:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-30 14:03 [PATCH] vhost-user-gpio: Configure vhost_dev when connecting Akihiko Odaki
2023-01-31 3:25 ` Viresh Kumar
2023-01-31 9:46 ` Alex Bennée
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).