From 66232095a1c71880a3fecc5ecaae47ec9a403134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= Date: Wed, 4 Mar 2026 18:38:57 +0100 Subject: [PATCH] net/vhost-vdpa: enable vqs before DRIVER_OK if no cvq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VDUSE do not forward the enable message to the userland device at the moment, leaving the dataplane disabled. As there is no functional difference if the device have no CVQ, enable them before DRIVER_OK in that case. For devices with a control vq, keep the enabling of the dataplane after CVQ so QEMU can restore the device configuration. Signed-off-by: Eugenio Pérez Fixes: 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller") Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Message-Id: <20260304173857.2705296-1-eperezma@redhat.com> --- net/vhost-vdpa.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index c85956a04b..c526c2b2dc 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -396,6 +396,7 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); struct vhost_vdpa *v = &s->vhost_vdpa; + bool has_cvq = v->dev->vq_index_end % 2; assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); @@ -405,6 +406,15 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) v->shadow_vqs_enabled = false; } + if (!has_cvq) { + for (int i = 0; i < v->dev->nvqs; ++i) { + int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); + if (ret < 0) { + return ret; + } + } + } + if (v->index == 0) { v->shared->shadow_data = v->shadow_vqs_enabled; vhost_vdpa_net_data_start_first(s); @@ -414,25 +424,6 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) return 0; } -static int vhost_vdpa_net_data_load(NetClientState *nc) -{ - VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); - struct vhost_vdpa *v = &s->vhost_vdpa; - bool has_cvq = v->dev->vq_index_end % 2; - - if (has_cvq) { - return 0; - } - - for (int i = 0; i < v->dev->nvqs; ++i) { - int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); - if (ret < 0) { - return ret; - } - } - return 0; -} - static void vhost_vdpa_net_client_stop(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -449,7 +440,6 @@ static NetClientInfo net_vhost_vdpa_info = { .size = sizeof(VhostVDPAState), .receive = vhost_vdpa_receive, .start = vhost_vdpa_net_data_start, - .load = vhost_vdpa_net_data_load, .stop = vhost_vdpa_net_client_stop, .cleanup = vhost_vdpa_cleanup, .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,