All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [PATCH hci-8.1/hci-8.2] vhost-blk: add .get_vhost() callback #VSTOR-156756
@ 2026-11-23 17:06 Andrey Drobyshev
  2026-11-23 17:16 ` no-reply
  2026-11-25  0:21 ` Andrey Zhadchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Drobyshev @ 2026-11-23 17:06 UTC (permalink / raw)
  To: svt-core; +Cc: andrey.zhadchenko, andrey.drobyshev

Currently QMP command x-query-virtio-status on a vhost-blk disk leads to
SIGSEGV:

  #1  0x000055de877be9f1 in qmp_x_query_virtio_status (path=0x55deb3e79030 "/machine/peripheral/virtio-disk1/virtio-backend", errp=0x7f5501a81f80)
      at ../hw/virtio/virtio-qmp.c:814
  #2  0x000055de87a1c8ec in qmp_marshal_x_query_virtio_status (args=0x7f53ec003a20, ret=0x7f550017dfa8, errp=0x7f550017dfb0) at qapi/qapi-commands-virtio.c:126
  #3  0x000055de87a580be in do_qmp_dispatch_bh (opaque=0x7f550017dfb8) at ../qapi/qmp-dispatch.c:128
  ...
  #14 0x000055de87537a75 in qemu_main_loop () at ../system/runstate.c:910
  #15 0x000055de879681a2 in qemu_default_main (opaque=0x0) at ../system/main.c:51

That's because this command leads to calling .get_vhost() method which
TYPE_VHOST_BLK never realizes.  Let's add a simple implementation
returning that pointer.

QMP commands x-query-virtio-vhost-queue-status, x-query-virtio-queue-status
are also affected by this bug and fixed by the callback implementation.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
 hw/block/vhost-blk.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c
index ffd647bfef2..80cfe8e1eff 100644
--- a/hw/block/vhost-blk.c
+++ b/hw/block/vhost-blk.c
@@ -784,6 +784,12 @@ static void vhost_blk_update_config(VirtIODevice *vdev, uint8_t *config)
     memcpy(config, &blkcfg, sizeof(struct virtio_blk_config));
 }
 
+static struct vhost_dev *vhost_blk_get_vhost(VirtIODevice *vdev)
+{
+    VHostBlk *s = VHOST_BLK(vdev);
+    return &s->dev;
+}
+
 static const Property vhost_blk_properties[] = {
     DEFINE_PROP_STRING("devpath", VHostBlk, conf.devpath),
     DEFINE_PROP_STRING("ueventfd", VHostBlk, conf.ueventfd),
@@ -826,6 +832,7 @@ static void vhost_blk_class_init(ObjectClass *klass, const void *data)
     vdc->get_features = vhost_blk_get_features;
     vdc->set_status = vhost_blk_set_status;
     vdc->reset = vhost_blk_reset;
+    vdc->get_vhost = vhost_blk_get_vhost;
 }
 
 static void vhost_blk_instance_init(Object *obj)
-- 
2.47.1


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

end of thread, other threads:[~2026-11-25  0:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 17:06 [PATCH hci-8.1/hci-8.2] vhost-blk: add .get_vhost() callback #VSTOR-156756 Andrey Drobyshev
2026-11-23 17:16 ` no-reply
2026-11-25  0:21 ` Andrey Zhadchenko

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.