virtio-net: Add only one queue pair when realizing
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Sun, 28 Apr 2024 07:00:51 +0000 (16:00 +0900)
committerJason Wang <jasowang@redhat.com>
Tue, 4 Jun 2024 07:14:26 +0000 (15:14 +0800)
Multiqueue usage is not negotiated yet when realizing. If more than
one queue is added and the guest never requests to enable multiqueue,
the extra queues will not be deleted when unrealizing and leak.

Fixes: f9d6dbf0bf6e ("virtio-net: remove virtio queues if the guest doesn't support multiqueue")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/virtio-net.c

index 3cee2ef3acd435d0f23f4eb662febbbfdea444dc..a8db8bfd9c37865107043745716dd1cc08a24838 100644 (file)
@@ -3743,9 +3743,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
     n->net_conf.tx_queue_size = MIN(virtio_net_max_tx_queue_size(n),
                                     n->net_conf.tx_queue_size);
 
-    for (i = 0; i < n->max_queue_pairs; i++) {
-        virtio_net_add_queue(n, i);
-    }
+    virtio_net_add_queue(n, 0);
 
     n->ctrl_vq = virtio_add_queue(vdev, 64, virtio_net_handle_ctrl);
     qemu_macaddr_default_if_unset(&n->nic_conf.macaddr);