virtio-net: Add queues before loading them
PATCH 1/1 virtio-net: Add queues before loading them
Call virtio_net_set_multiqueue() to add queues before loading their states. Otherwise the loaded queues will not have handlers and elements in them will not be processed.
--- include/hw/virtio/virtio.h | 2 ++ hw/net/virtio-net.c | 10 ++++++++++ hw/virtio/virtio.c | 7 +++++++ 3 files changed, 19 insertions(+)
include/hw/virtio/virtio.h +2 -0
@@ -210,6 +210,8 @@ struct VirtioDeviceClass {void (*guest_notifier_mask)(VirtIODevice *vdev,int n,bool mask);int (*start_ioeventfd)(VirtIODevice *vdev);void (*stop_ioeventfd)(VirtIODevice *vdev); +/* Called before loading queues. Useful to add queues before loading. */ +int (*pre_load_queues)(VirtIODevice *vdev);/* Saving and loading of a device; trying to deprecate save/load * use vmsd for new devices. */
hw/net/virtio-net.c +10 -0
@@ -3032,6 +3032,15 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)virtio_net_set_queue_pairs (n); } +static int virtio_net_pre_load_queues (VirtIODevice *vdev) +{ +virtio_net_set_multiqueue (VIRTIO_NET (vdev), +virtio_has_feature (vdev->guest_features,VIRTIO_NET_F_RSS ) || +virtio_has_feature (vdev->guest_features,VIRTIO_NET_F_MQ )); + +return 0 ; +} +static int virtio_net_post_load_device (void *opaque,int version_id) {VirtIONet *n = opaque;
@@ -4025,6 +4034,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_mask = virtio_net_guest_notifier_mask; vdc->guest_notifier_pending = virtio_net_guest_notifier_pending; vdc->legacy_features |= (0x1 <<VIRTIO_NET_F_GSO ); + vdc->pre_load_queues = virtio_net_pre_load_queues; vdc->post_load = virtio_net_post_load_virtio; vdc->vmsd = &vmstate_virtio_net_device; vdc->primary_unplug_pending = primary_unplug_pending;
hw/virtio/virtio.c +7 -0
@@ -3255,6 +3255,13 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) config_len--; } +if (vdc->pre_load_queues) { + ret = vdc->pre_load_queues (vdev); +if (ret) { +return ret; + } + } + num =qemu_get_be32 (f);if (num >VIRTIO_QUEUE_MAX ) {
---
base-commit: 7e3b6d8063f245d27eecce5aabe624b5785f2a77
change-id: 20241017-load-fb5544456d28
Best regards,
Signature · 1 line
Akihiko Odaki <[email protected]>
Quoted 8 lines · Akihiko Odaki
Call
virtio_net_set_multiqueue()to add queues before loading their states. Otherwise the loaded queues will not have handlers and elements in them will not be processed.Fixes 8c49756825da ("virtio-net: Add only one queue pair when realizing")Reported-by Laurent Vivier <[email protected]>Signed-off-by Akihiko Odaki <[email protected]>
Jason, your queue?
Quoted 73 lines
--- include/hw/virtio/virtio.h | 2 ++ hw/net/virtio-net.c | 10 ++++++++++ hw/virtio/virtio.c | 7 +++++++ 3 files changed, 19 insertions(+)include/hw/virtio/virtio.h +2
-0@@ -210,6 +210,8 @@ struct VirtioDeviceClass {void (*guest_notifier_mask)(VirtIODevice *vdev,int n,bool mask);int (*start_ioeventfd)(VirtIODevice *vdev);void (*stop_ioeventfd)(VirtIODevice *vdev); +/* Called before loading queues. Useful to add queues before loading. */ +int (*pre_load_queues)(VirtIODevice *vdev);/* Saving and loading of a device; trying to deprecate save/load * use vmsd for new devices. */ hw/net/virtio-net.c +10
-0@@ -3032,6 +3032,15 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)virtio_net_set_queue_pairs (n); } +static int virtio_net_pre_load_queues (VirtIODevice *vdev) +{ +virtio_net_set_multiqueue (VIRTIO_NET (vdev), +virtio_has_feature (vdev->guest_features,VIRTIO_NET_F_RSS ) || +virtio_has_feature (vdev->guest_features,VIRTIO_NET_F_MQ )); + +return 0 ; +} +static int virtio_net_post_load_device (void *opaque,int version_id) {VirtIONet *n = opaque;@@ -4025,6 +4034,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_mask = virtio_net_guest_notifier_mask; vdc->guest_notifier_pending = virtio_net_guest_notifier_pending; vdc->legacy_features |= (0x1 <<VIRTIO_NET_F_GSO ); + vdc->pre_load_queues = virtio_net_pre_load_queues; vdc->post_load = virtio_net_post_load_virtio; vdc->vmsd = &vmstate_virtio_net_device; vdc->primary_unplug_pending = primary_unplug_pending;hw/virtio/virtio.c +7
-1@@ -3255,6 +3255,13 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) config_len--; } +if (vdc->pre_load_queues) { + ret = vdc->pre_load_queues (vdev); +if (ret) { +return ret; + } + } + num =qemu_get_be32 (f);if (num >VIRTIO_QUEUE_MAX ) { ---base-commit:
7e3b6d8063f245d27eecce5aabe624b5785f2a77
change-id: 20241017-load-fb5544456d28Best regards,
Signature · 1 line
Akihiko Odaki <[email protected]>
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Akihiko Odaki
Call
virtio_net_set_multiqueue()to add queues before loading their states. Otherwise the loaded queues will not have handlers and elements in them will not be processed.Fixes 8c49756825da ("virtio-net: Add only one queue pair when realizing")Reported-by Laurent Vivier <[email protected]>Signed-off-by Akihiko Odaki <[email protected]>
Quoted 5 lines
Jason, your queue?
Yes, queued.
Thanks
Quoted 12 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Akihiko Odaki
Call
virtio_net_set_multiqueue()to add queues before loading their states. Otherwise the loaded queues will not have handlers and elements in them will not be processed.Fixes 8c49756825da ("virtio-net: Add only one queue pair when realizing")Reported-by Laurent Vivier <[email protected]>Signed-off-by Akihiko Odaki <[email protected]>
Quoted 8 lines
Quoted 5 lines
Jason, your queue?
Yes, queued.
Is this merged now ?
Thanks
Laurent