hw/virtio/vdpa-dev.c | 7 +++++++ 1 file changed, 7 insertions(+)
Commit c255488d67 "virtio: add vhost support for virtio devices"
added the get_vhost() function, but it did not include vhost-vdpa devices.
Now we add it.
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
On 9/23/25 9:51 AM, 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. > Now we add it. > Looks good to me! Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com> > 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)
On Tue, Sep 23, 2025 at 09:51:10PM +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. >Now we add it. Again, could you please explain what problem you had and how this patch solves it? This information must always be included in a commit message, so please pay attention to this. Thanks, Stefano > >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 >
On Wed, 24 Sep 2025 04:08:24 -0700, Stefano Garzarella wrote: >On Tue, Sep 23, 2025 at 09:51:10PM +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. >>Now we add it. > >Again, could you please explain what problem you had and how this patch >solves it? > >This information must always be included in a commit message, so please >pay attention to this. > >Thanks, >Stefano > OK, I've got it. 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. Later, I will send Patch v2 that includes the complete commit information. Thanks, Li Zhaoxin >> >>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 >>
© 2016 - 2025 Red Hat, Inc.