All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] vdpa-dev: add get_vhost() callback for vhost-vdpa device
@ 2025-09-26 11:08 Li Zhaoxin via
  2025-10-05 12:45 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: Li Zhaoxin via @ 2025-09-26 11:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S . Tsirkin, Stefano Garzarella, Jonah Palmer,
	Miao Kezhan, Li Zhaoxin

Commit c255488d67 "virtio: add vhost support for virtio devices"
added the get_vhost() function, but it did not include vhost-vdpa devices.

So when I use the vdpa device and query the status of the vdpa device
with the x-query-virtio-status qmp command, since vdpa does not implement
vhost_get, it will cause qemu to crash.

Therefore, in order to obtain the status of the virtio device under vhost-vdpa,
we need to add a vhost_get implement for the vdpa device.

Co-developed-by: Miao Kezhan <miaokezhan@baidu.com>
Signed-off-by: Miao Kezhan <miaokezhan@baidu.com>
Signed-off-by: Li Zhaoxin <lizhaoxin04@baidu.com>
---
 hw/virtio/vdpa-dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
index d1da40afc8..4a7b970976 100644
--- a/hw/virtio/vdpa-dev.c
+++ b/hw/virtio/vdpa-dev.c
@@ -338,6 +338,12 @@ static int vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)
     return 0;
 }
 
+static struct vhost_dev *vhost_vdpa_device_get_vhost(VirtIODevice *vdev)
+{
+    VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
+    return &s->dev;
+}
+
 static const Property vhost_vdpa_device_properties[] = {
     DEFINE_PROP_STRING("vhostdev", VhostVdpaDevice, vhostdev),
     DEFINE_PROP_UINT16("queue-size", VhostVdpaDevice, queue_size, 0),
@@ -369,6 +375,7 @@ static void vhost_vdpa_device_class_init(ObjectClass *klass, const void *data)
     vdc->set_config = vhost_vdpa_device_set_config;
     vdc->get_features = vhost_vdpa_device_get_features;
     vdc->set_status = vhost_vdpa_device_set_status;
+    vdc->get_vhost = vhost_vdpa_device_get_vhost;
 }
 
 static void vhost_vdpa_device_instance_init(Object *obj)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] vdpa-dev: add get_vhost() callback for vhost-vdpa device
  2025-09-26 11:08 [PATCH v2] vdpa-dev: add get_vhost() callback for vhost-vdpa device Li Zhaoxin via
@ 2025-10-05 12:45 ` Michael S. Tsirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2025-10-05 12:45 UTC (permalink / raw)
  To: Li Zhaoxin; +Cc: qemu-devel, Stefano Garzarella, Jonah Palmer, Miao Kezhan

On Fri, Sep 26, 2025 at 07:08:17PM +0800, Li Zhaoxin wrote:
> Commit c255488d67 "virtio: add vhost support for virtio devices"
> added the get_vhost() function, but it did not include vhost-vdpa devices.
> 
> So when I use the vdpa device and query the status of the vdpa device
> with the x-query-virtio-status qmp command, since vdpa does not implement
> vhost_get, it will cause qemu to crash.
> 
> Therefore, in order to obtain the status of the virtio device under vhost-vdpa,
> we need to add a vhost_get implement for the vdpa device.
> 
> Co-developed-by: Miao Kezhan <miaokezhan@baidu.com>
> Signed-off-by: Miao Kezhan <miaokezhan@baidu.com>
> Signed-off-by: Li Zhaoxin <lizhaoxin04@baidu.com>


For some reason, in my inbox I have this with
	From: Li Zhaoxin <lizhaoxin04@baidu.com>
but on qemu-devel the from address is mangled:
https://lore.kernel.org/all/2778f817cb6740a15ecb37927804a67288b062d1.1758860411.git.lizhaoxin04@baidu.com/

I fixed it up but I suggest you figure out what happened here,
because I do not like to fix up patches manually.


> ---
>  hw/virtio/vdpa-dev.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c
> index d1da40afc8..4a7b970976 100644
> --- a/hw/virtio/vdpa-dev.c
> +++ b/hw/virtio/vdpa-dev.c
> @@ -338,6 +338,12 @@ static int vhost_vdpa_device_set_status(VirtIODevice *vdev, uint8_t status)
>      return 0;
>  }
>  
> +static struct vhost_dev *vhost_vdpa_device_get_vhost(VirtIODevice *vdev)
> +{
> +    VhostVdpaDevice *s = VHOST_VDPA_DEVICE(vdev);
> +    return &s->dev;
> +}
> +
>  static const Property vhost_vdpa_device_properties[] = {
>      DEFINE_PROP_STRING("vhostdev", VhostVdpaDevice, vhostdev),
>      DEFINE_PROP_UINT16("queue-size", VhostVdpaDevice, queue_size, 0),
> @@ -369,6 +375,7 @@ static void vhost_vdpa_device_class_init(ObjectClass *klass, const void *data)
>      vdc->set_config = vhost_vdpa_device_set_config;
>      vdc->get_features = vhost_vdpa_device_get_features;
>      vdc->set_status = vhost_vdpa_device_set_status;
> +    vdc->get_vhost = vhost_vdpa_device_get_vhost;
>  }
>  
>  static void vhost_vdpa_device_instance_init(Object *obj)
> -- 
> 2.34.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-05 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 11:08 [PATCH v2] vdpa-dev: add get_vhost() callback for vhost-vdpa device Li Zhaoxin via
2025-10-05 12:45 ` Michael S. Tsirkin

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.