* [PATCH] virtio-net: Add queues before loading them
@ 2024-10-22 6:49 Akihiko Odaki
2024-10-23 8:02 ` Michael S. Tsirkin
0 siblings, 1 reply; 4+ messages in thread
From: Akihiko Odaki @ 2024-10-22 6:49 UTC (permalink / raw)
To: Jason Wang, Laurent Vivier, Michael S. Tsirkin
Cc: qemu-devel, qemu-stable, 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.
Cc: qemu-stable@nongnu.org
Fixes: 8c49756825da ("virtio-net: Add only one queue pair when realizing")
Reported-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
include/hw/virtio/virtio.h | 2 ++
hw/net/virtio-net.c | 10 ++++++++++
hw/virtio/virtio.c | 7 +++++++
3 files changed, 19 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index f526ecc8fcc0..638691028050 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -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.
*/
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index fb84d142ee29..c467ef130016 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -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;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index a26f18908ea5..f12c4aa81eb5 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -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,
--
Akihiko Odaki <akihiko.odaki@daynix.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio-net: Add queues before loading them
2024-10-22 6:49 [PATCH] virtio-net: Add queues before loading them Akihiko Odaki
@ 2024-10-23 8:02 ` Michael S. Tsirkin
2024-10-25 8:44 ` Jason Wang
0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2024-10-23 8:02 UTC (permalink / raw)
To: Akihiko Odaki; +Cc: Jason Wang, Laurent Vivier, qemu-devel, qemu-stable
On Tue, Oct 22, 2024 at 03:49:01PM +0900, Akihiko Odaki wrote:
> 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.
>
> Cc: qemu-stable@nongnu.org
> Fixes: 8c49756825da ("virtio-net: Add only one queue pair when realizing")
> Reported-by: Laurent Vivier <lvivier@redhat.com>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Jason, your queue?
> ---
> include/hw/virtio/virtio.h | 2 ++
> hw/net/virtio-net.c | 10 ++++++++++
> hw/virtio/virtio.c | 7 +++++++
> 3 files changed, 19 insertions(+)
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index f526ecc8fcc0..638691028050 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -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.
> */
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index fb84d142ee29..c467ef130016 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -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;
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index a26f18908ea5..f12c4aa81eb5 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -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,
> --
> Akihiko Odaki <akihiko.odaki@daynix.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio-net: Add queues before loading them
2024-10-23 8:02 ` Michael S. Tsirkin
@ 2024-10-25 8:44 ` Jason Wang
2024-11-13 10:41 ` Laurent Vivier
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2024-10-25 8:44 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Akihiko Odaki, Laurent Vivier, qemu-devel, qemu-stable
On Wed, Oct 23, 2024 at 4:02 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Tue, Oct 22, 2024 at 03:49:01PM +0900, Akihiko Odaki wrote:
> > 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.
> >
> > Cc: qemu-stable@nongnu.org
> > Fixes: 8c49756825da ("virtio-net: Add only one queue pair when realizing")
> > Reported-by: Laurent Vivier <lvivier@redhat.com>
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>
>
> Jason, your queue?
>
Yes, queued.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio-net: Add queues before loading them
2024-10-25 8:44 ` Jason Wang
@ 2024-11-13 10:41 ` Laurent Vivier
0 siblings, 0 replies; 4+ messages in thread
From: Laurent Vivier @ 2024-11-13 10:41 UTC (permalink / raw)
To: Jason Wang, Michael S. Tsirkin; +Cc: Akihiko Odaki, qemu-devel, qemu-stable
On 25/10/2024 10:44, Jason Wang wrote:
> On Wed, Oct 23, 2024 at 4:02 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>>
>> On Tue, Oct 22, 2024 at 03:49:01PM +0900, Akihiko Odaki wrote:
>>> 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.
>>>
>>> Cc: qemu-stable@nongnu.org
>>> Fixes: 8c49756825da ("virtio-net: Add only one queue pair when realizing")
>>> Reported-by: Laurent Vivier <lvivier@redhat.com>
>>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>>
>> Acked-by: Michael S. Tsirkin <mst@redhat.com>
>>
>>
>> Jason, your queue?
>>
>
> Yes, queued.
>
Is this merged now ?
Thanks
Laurent
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-13 10:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-22 6:49 [PATCH] virtio-net: Add queues before loading them Akihiko Odaki
2024-10-23 8:02 ` Michael S. Tsirkin
2024-10-25 8:44 ` Jason Wang
2024-11-13 10:41 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).