@samitouri / QOSamiQemu / commits / 66232095a1

net/vhost-vdpa: enable vqs before DRIVER_OK if no cvq

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 <eperezma@redhat.com> Fixes: 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller") Acked-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260304173857.2705296-1-eperezma@redhat.com>

Eugenio Pérez committed Mar 4, 2026 at 18:38 UTC 66232095a1c71880a3fecc5ecaae47ec9a403134
1 file changed +10 -20
net/vhost-vdpa.c
+10 -20
@@ -396,6 +396,7 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
396 {
397 VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
398 struct vhost_vdpa *v = &s->vhost_vdpa;
399 + bool has_cvq = v->dev->vq_index_end % 2;
400
401 assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
402
@@ -405,6 +406,15 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
406 v->shadow_vqs_enabled = false;
407 }
408
409 + if (!has_cvq) {
410 + for (int i = 0; i < v->dev->nvqs; ++i) {
411 + int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index);
412 + if (ret < 0) {
413 + return ret;
414 + }
415 + }
416 + }
417 +
418 if (v->index == 0) {
419 v->shared->shadow_data = v->shadow_vqs_enabled;
420 vhost_vdpa_net_data_start_first(s);
@@ -414,25 +424,6 @@ static int vhost_vdpa_net_data_start(NetClientState *nc)
424 return 0;
425 }
426
417 -static int vhost_vdpa_net_data_load(NetClientState *nc)
418 -{
419 - VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
420 - struct vhost_vdpa *v = &s->vhost_vdpa;
421 - bool has_cvq = v->dev->vq_index_end % 2;
422 -
423 - if (has_cvq) {
424 - return 0;
425 - }
426 -
427 - for (int i = 0; i < v->dev->nvqs; ++i) {
428 - int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index);
429 - if (ret < 0) {
430 - return ret;
431 - }
432 - }
433 - return 0;
434 -}
435 -
427 static void vhost_vdpa_net_client_stop(NetClientState *nc)
428 {
429 VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc);
@@ -449,7 +440,6 @@ static NetClientInfo net_vhost_vdpa_info = {
440 .size = sizeof(VhostVDPAState),
441 .receive = vhost_vdpa_receive,
442 .start = vhost_vdpa_net_data_start,
452 - .load = vhost_vdpa_net_data_load,
443 .stop = vhost_vdpa_net_client_stop,
444 .cleanup = vhost_vdpa_cleanup,
445 .has_vnet_hdr = vhost_vdpa_has_vnet_hdr,