From: Eugenio Perez Martin <eperezma@redhat.com>
To: Jonah Palmer <jonah.palmer@oracle.com>
Cc: qemu-devel@nongnu.org, eduardo@habkost.net,
marcel.apfelbaum@gmail.com, philmd@linaro.org,
wangyanan55@huawei.com, zhao1.liu@intel.com, mst@redhat.com,
sgarzare@redhat.com, jasowang@redhat.com, leiyang@redhat.com,
si-wei.liu@oracle.com, boris.ostrovsky@oracle.com,
armbru@redhat.com
Subject: Re: [RFC v2 13/14] virtio-net: detect pending Tx work for VQs mid-migration changes
Date: Tue, 24 Mar 2026 12:35:21 +0100 [thread overview]
Message-ID: <CAJaqyWeSr42GwqG82hWcj5Etpde0Kz8no1TMwFbVeuCazQghJA@mail.gmail.com> (raw)
In-Reply-To: <20260320142015.3856652-14-jonah.palmer@oracle.com>
On Fri, Mar 20, 2026 at 3:21 PM Jonah Palmer <jonah.palmer@oracle.com> wrote:
>
> Track per-queue pending Tx work state during early migration time.
>
> This includes a snapshot of pending Tx state for active queue pairs,
> checking for deltas at the end of migration, and freeing the snapshot
> buffer during device unrealize.
>
> With this final delta signal in place, drop the temporary always-true
> fallback in virtio_net_has_delta and return false when no deltas are
> found.
>
> Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com>
> ---
> hw/net/virtio-net.c | 26 +++++++++++++++++++++-----
> include/hw/virtio/virtio-net.h | 2 ++
> 2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 3ee49a043a..483a43be4f 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -3943,6 +3943,14 @@ static int virtio_net_early_pre_save(void *opaque)
> vnet_mig->mq_early = n->multiqueue;
> vnet_mig->queue_pairs_early = n->curr_queue_pairs;
>
> + /* Tx waiting snapshot for active queue pairs */
> + if (!vnet_mig->tx_waiting_early) {
> + vnet_mig->tx_waiting_early = g_new0(uint32_t, n->max_queue_pairs);
> + }
> + for (int i = 0; i < n->curr_queue_pairs; i++) {
> + vnet_mig->tx_waiting_early[i] = n->vqs[i].tx_waiting;
> + }
> +
> /* RSS state snapshot */
> vnet_mig->rss_enabled_early = n->rss_data.enabled;
> vnet_mig->rss_redirect_early = n->rss_data.redirect;
> @@ -4254,6 +4262,8 @@ static void virtio_net_device_unrealize(DeviceState *dev)
> n->migration->mtable_macs_early = NULL;
> g_free(n->migration->vlans_early);
> n->migration->vlans_early = NULL;
> + g_free(n->migration->tx_waiting_early);
> + n->migration->tx_waiting_early = NULL;
> g_free(n->migration->rss_indirections_table_early);
> n->migration->rss_indirections_table_early = NULL;
> g_free(n->migration);
> @@ -4412,6 +4422,16 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtIODevice *vdev)
> return true;
> }
>
> + /* Has any active queue's tx_waiting changed? */
> + if (!vnet_mig->tx_waiting_early) {
> + return true;
> + }
> + for (int i = 0; i < n->curr_queue_pairs; i++) {
> + if (n->vqs[i].tx_waiting != vnet_mig->tx_waiting_early[i]) {
> + return true;
> + }
> + }
> +
> /* Has the VirtIONet's RSS state changed? */
> if (n->rss_data.enabled != vnet_mig->rss_enabled_early ||
> n->rss_data.redirect != vnet_mig->rss_redirect_early ||
> @@ -4439,11 +4459,7 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtIODevice *vdev)
> }
> }
>
> - /*
> - * Always return true for now until we're able to detect all possible
> - * changes to a VirtIONet device.
> - */
> - return true;
> + return false;
I'm failing to see one thing: If we add a new feature that the guest
can change during migration and it's only added in the
VMStateDescription vmstate_virtio_net_device, will this "return false"
prevent the state from being resent in the stop-and-copy phase?
Mandating its addition here is ok somehow, but I'm not sure if I'm
missing something.
> }
>
> static bool virtio_net_needed(void *opaque)
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index 88074a0976..dbbacc83bb 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -180,6 +180,7 @@ typedef struct VirtIONetQueue {
> * @guest_offloads_early: Guest offloads snapshot.
> * @mq_early: Multiqueue state snapshot.
> * @queue_pairs_early: Queue pairs snapshot.
> + * @tx_waiting_early: Per-queue pending-Tx snapshot.
> * @rss_enabled_early: RSS enabled flag.
> * @rss_redirect_early: RSS redirect flag.
> * @rss_populate_hash_early: RSS populate hash flag.
> @@ -201,6 +202,7 @@ typedef struct VirtIONetMigration {
> uint64_t guest_offloads_early;
> int mq_early;
> uint16_t queue_pairs_early;
> + uint32_t *tx_waiting_early;
> bool rss_enabled_early;
> bool rss_redirect_early;
> bool rss_populate_hash_early;
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-03-24 11:36 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 14:20 [RFC v2 00/14] virtio-net: early VMStateDescription live migration support Jonah Palmer
2026-03-20 14:20 ` [RFC v2 01/14] machine,virtio-net: add early-mig property Jonah Palmer
2026-03-23 10:25 ` Eugenio Perez Martin
2026-03-24 14:07 ` Jonah Palmer
2026-03-26 8:02 ` Eugenio Perez Martin
2026-03-20 14:20 ` [RFC v2 02/14] virtio, virtio-net: add initial early VMSD for setup-phase migration Jonah Palmer via qemu development
2026-03-24 9:27 ` [RFC v2 02/14] virtio,virtio-net: " Eugenio Perez Martin
2026-03-24 14:28 ` Jonah Palmer
2026-03-24 14:38 ` Eugenio Perez Martin
2026-03-24 17:16 ` Jonah Palmer
2026-03-20 14:20 ` [RFC v2 03/14] virtio,virtio-net: virtio-delta VMSD - VQ state Jonah Palmer
2026-03-20 14:20 ` [RFC v2 04/14] virtio-net: detect VirtIODevice status mid-migration change Jonah Palmer
2026-03-24 10:45 ` Eugenio Perez Martin
2026-03-24 15:01 ` Jonah Palmer
2026-03-26 10:08 ` Eugenio Perez Martin
2026-03-20 14:20 ` [RFC v2 05/14] virtio-net: detect VirtIODevice config buffer " Jonah Palmer
2026-03-24 10:48 ` Eugenio Perez Martin
2026-03-24 15:25 ` Jonah Palmer
2026-03-20 14:20 ` [RFC v2 06/14] virtio-net: detect VirtIONet MAC addr " Jonah Palmer
2026-03-20 14:20 ` [RFC v2 07/14] virtio-net: detect VirtIONet MAC table mid-migration changes Jonah Palmer
2026-03-20 14:20 ` [RFC v2 08/14] virtio-net: detect VirtIONet status mid-migration change Jonah Palmer
2026-03-24 11:26 ` Eugenio Perez Martin
2026-03-24 16:23 ` Jonah Palmer
2026-03-26 10:20 ` Eugenio Perez Martin
2026-03-20 14:20 ` [RFC v2 09/14] virtio-net: detect VirtIONet Rx filter mid-migration changes Jonah Palmer
2026-03-20 14:20 ` [RFC v2 10/14] virtio-net: detect VirtIONet VLAN filter table changes Jonah Palmer
2026-03-20 14:20 ` [RFC v2 11/14] virtio-net: detect VirtIONet guest offload & MQ mid-migration changes Jonah Palmer
2026-03-20 14:20 ` [RFC v2 12/14] virtio-net: detect RSS state " Jonah Palmer
2026-03-20 14:20 ` [RFC v2 13/14] virtio-net: detect pending Tx work for VQs " Jonah Palmer
2026-03-24 11:35 ` Eugenio Perez Martin [this message]
2026-03-24 16:47 ` Jonah Palmer
2026-03-26 10:30 ` Eugenio Perez Martin
2026-03-20 14:20 ` [RFC v2 14/14] virtio-net, vhost-net: early migration support for vhost-net Jonah Palmer via qemu development
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJaqyWeSr42GwqG82hWcj5Etpde0Kz8no1TMwFbVeuCazQghJA@mail.gmail.com \
--to=eperezma@redhat.com \
--cc=armbru@redhat.com \
--cc=boris.ostrovsky@oracle.com \
--cc=eduardo@habkost.net \
--cc=jasowang@redhat.com \
--cc=jonah.palmer@oracle.com \
--cc=leiyang@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=si-wei.liu@oracle.com \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox