Same way as with the MAC, restore the expected number of queues at device's start.
Signed-off-by: Eugenio Pérez <[email protected]> --- net/vhost-vdpa.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1e0dbfcced..96fd3bc835 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -391,6 +391,35 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, return 0; } +static int vhost_vdpa_net_load_mq(VhostVDPAState *s, + const VirtIONet *n) +{ + uint64_t features = n->parent_obj.guest_features; + ssize_t dev_written; + void *cursor = s->cvq_cmd_out_buffer; + if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) { + return 0; + } + + *(struct virtio_net_ctrl_hdr *)cursor = (struct virtio_net_ctrl_hdr) { + .class = VIRTIO_NET_CTRL_MQ, + .cmd = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, + }; + cursor += sizeof(struct virtio_net_ctrl_hdr); + *(struct virtio_net_ctrl_mq *)cursor = (struct virtio_net_ctrl_mq) { + .virtqueue_pairs = cpu_to_le16(n->curr_queue_pairs), + }; + cursor += sizeof(struct virtio_net_ctrl_mq); + + dev_written = vhost_vdpa_net_cvq_add(s, cursor - s->cvq_cmd_out_buffer, + sizeof(virtio_net_ctrl_ack)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -409,6 +438,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r < 0)) { return r; } + r = vhost_vdpa_net_load_mq(s, n); + if (unlikely(r)) { + return r; + } return 0; } -- 2.31.1
