On Tue, Sep 29, 2026 at 05:22:23PM +0500, Alexandr Moshkov wrote:
Currently, do_vhost_virtqueue_stop() calls
vhost_user_has_protocol_feature(), causing a link failure with
--disable-vhost-user when other vhost backends are enabled.

Move the assertion to vhost_user_get_vring_base_skip_drain(), keeping
the protocol feature check in the vhost-user backend and removing
the dependency from the common vhost code.

Reported-by: ClĂ©ment Chigot <[email protected]>
Fixes: 5eb2347867 ("vhost-user: add skip_drain param to 
do_vhost_virtqueue_stop")
Signed-off-by: Alexandr Moshkov <[email protected]>
---

v1 -> v2:
- Move the protocol feature assertion from do_vhost_virtqueue_stop()
  to vhost_user_get_vring_base_skip_drain().
- Drop the stub added in v1 and remove the unused vhost-user.h
  include.

hw/virtio/vhost-user.c | 4 +---
hw/virtio/vhost.c      | 5 -----
2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 65889b0776..84918c7265 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1463,9 +1463,7 @@ static int vhost_user_get_vring_base_skip_drain(struct 
vhost_dev *dev,
    bool skip_drain_supported = vhost_user_has_protocol_feature(dev,
                               VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN);

-    if (!skip_drain_supported) {
-        return 0;
-    }
+    assert(skip_drain_supported);

I'm still not sure if an assert is the right approach here, rather than returning -1 and letting the caller handle the error.

That said, the behavior remains the same as before, so:

Acked-by: Stefano Garzarella <[email protected]>


    return get_vring_base(dev, ring, true);
}
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 68a8e40481..db8f246137 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -23,7 +23,6 @@
#include "qemu/log.h"
#include "standard-headers/linux/vhost_types.h"
#include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/vhost-user.h"
#include "hw/mem/memory-device.h"
#include "migration/blocker.h"
#include "migration/qemu-file-types.h"
@@ -1503,10 +1502,6 @@ static int do_vhost_virtqueue_stop(struct vhost_dev *dev,
                                   unsigned idx, bool force,
                                   bool skip_drain)
{
-    if (skip_drain) {
-        assert(vhost_user_has_protocol_feature(dev,
-               VHOST_USER_PROTOCOL_F_GET_VRING_BASE_SKIP_DRAIN));
-    }
    int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);
    struct vhost_vring_state state = {
        .index = vhost_vq_index,
--
2.34.1



Reply via email to