From: Eugenio Pérez <[email protected]> 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 <[email protected]> Fixes: 6c4825476a43 ("vdpa: move vhost_vdpa_set_vring_ready to the caller") Acked-by: Jason Wang <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Message-Id: <[email protected]> --- 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, -- MST
