[PATCH v7 00/19] virtio-net: live-TAP local migration

Vladimir Sementsov-Ogievskiy posted 19 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251010173957.166759-1-vsementsov@yandex-team.ru
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Stefan Weil <sw@weilnetz.de>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>
There is a newer version of this series
hw/net/virtio-net.c                           | 150 ++++++-
include/migration/vmstate.h                   |   1 +
include/net/tap.h                             |   5 +
migration/migration.c                         |   4 +
migration/options.c                           |  33 ++
migration/options.h                           |   2 +
migration/savevm.c                            |  15 +
migration/savevm.h                            |   1 +
net/tap-bsd.c                                 |   3 +-
net/tap-linux.c                               |  19 +-
net/tap-solaris.c                             |   3 +-
net/tap-stub.c                                |   3 +-
net/tap-win32.c                               |  11 +
net/tap.c                                     | 425 +++++++++++++-----
net/tap_int.h                                 |   3 +-
qapi/migration.json                           |  42 +-
tests/functional/qemu_test/decorators.py      |  16 +
tests/functional/test_x86_64_tap_migration.py | 396 ++++++++++++++++
18 files changed, 1001 insertions(+), 131 deletions(-)
create mode 100644 tests/functional/test_x86_64_tap_migration.py
[PATCH v7 00/19] virtio-net: live-TAP local migration
Posted by Vladimir Sementsov-Ogievskiy 1 month ago
Hi all!

Here is a new migration parameter backend-transfer, which allows to
enable local migration of TAP virtio-net backend, including its
properties and open fds.

With this new option, management software doesn't need to
initialize new TAP and do a switch to it. Nothing should be
done around virtio-net in local migration: it just migrates
and continues to use same TAP device. So we avoid extra logic
in management software, extra allocations in kernel (for new TAP),
and corresponding extra delay in migration downtime.

v7:

01-13,18: r-b by Maxim Davydov
          t-b by Lei Yang

05: fix tap->script to tap->downscript
07: tiny rebase conflict around "NetOffloadsd ol = {}"

14: reworked to vmsd handler
    tap is migrated inside virtio-net. And we support backend-transfer
    only for virtio-net+tap. So, it's better to support initialization
    postponing directly in virtio-net, the code is simplified, and we
    don't have to manage global list of taps.

15: reworked on top of 14

16: - drop QAPI_LIST_CONTAINS macro
    - improve commit message
    - improve QAPI documentation comments

17: - don't add extra check into virtio_net_update_host_features(),
      as we now can call it only when needed (more explicit logic)
    - drop extra includes
    - no need in "attached_to_virtio_net" variable anymore
    - add .has_tunnel to the state

19: add also test-cases for TAP migration without backend-transfer
    (to be sure, that we don't break it with new feature:)

Vladimir Sementsov-Ogievskiy (19):
  net/tap: net_init_tap_one(): drop extra error propagation
  net/tap: net_init_tap_one(): move parameter checking earlier
  net/tap: rework net_tap_init()
  net/tap: pass NULL to net_init_tap_one() in cases when scripts are
    NULL
  net/tap: rework scripts handling
  net/tap: setup exit notifier only when needed
  net/tap: split net_tap_fd_init()
  net/tap: tap_set_sndbuf(): add return value
  net/tap: rework tap_set_sndbuf()
  net/tap: rework sndbuf handling
  net/tap: introduce net_tap_setup()
  net/tap: move vhost fd initialization to net_tap_new()
  net/tap: finalize net_tap_set_fd() logic
  migration: introduce .pre_incoming() vmsd handler
  net/tap: postpone tap setup to pre-incoming
  qapi: add interface for backend-transfer virtio-net/tap migration
  virtio-net: support backend-transfer migration for virtio-net/tap
  tests/functional: add skipWithoutSudo() decorator
  tests/functional: add test_x86_64_tap_migration

 hw/net/virtio-net.c                           | 150 ++++++-
 include/migration/vmstate.h                   |   1 +
 include/net/tap.h                             |   5 +
 migration/migration.c                         |   4 +
 migration/options.c                           |  33 ++
 migration/options.h                           |   2 +
 migration/savevm.c                            |  15 +
 migration/savevm.h                            |   1 +
 net/tap-bsd.c                                 |   3 +-
 net/tap-linux.c                               |  19 +-
 net/tap-solaris.c                             |   3 +-
 net/tap-stub.c                                |   3 +-
 net/tap-win32.c                               |  11 +
 net/tap.c                                     | 425 +++++++++++++-----
 net/tap_int.h                                 |   3 +-
 qapi/migration.json                           |  42 +-
 tests/functional/qemu_test/decorators.py      |  16 +
 tests/functional/test_x86_64_tap_migration.py | 396 ++++++++++++++++
 18 files changed, 1001 insertions(+), 131 deletions(-)
 create mode 100644 tests/functional/test_x86_64_tap_migration.py

-- 
2.48.1
Re: [PATCH v7 00/19] virtio-net: live-TAP local migration
Posted by Lei Yang 1 month ago
Tested this series of patches with virtio-net regression tests,
everything works fine.

Tested-by: Lei Yang <leiyang@redhat.com>

On Sat, Oct 11, 2025 at 1:40 AM Vladimir Sementsov-Ogievskiy
<vsementsov@yandex-team.ru> wrote:
>
> Hi all!
>
> Here is a new migration parameter backend-transfer, which allows to
> enable local migration of TAP virtio-net backend, including its
> properties and open fds.
>
> With this new option, management software doesn't need to
> initialize new TAP and do a switch to it. Nothing should be
> done around virtio-net in local migration: it just migrates
> and continues to use same TAP device. So we avoid extra logic
> in management software, extra allocations in kernel (for new TAP),
> and corresponding extra delay in migration downtime.
>
> v7:
>
> 01-13,18: r-b by Maxim Davydov
>           t-b by Lei Yang
>
> 05: fix tap->script to tap->downscript
> 07: tiny rebase conflict around "NetOffloadsd ol = {}"
>
> 14: reworked to vmsd handler
>     tap is migrated inside virtio-net. And we support backend-transfer
>     only for virtio-net+tap. So, it's better to support initialization
>     postponing directly in virtio-net, the code is simplified, and we
>     don't have to manage global list of taps.
>
> 15: reworked on top of 14
>
> 16: - drop QAPI_LIST_CONTAINS macro
>     - improve commit message
>     - improve QAPI documentation comments
>
> 17: - don't add extra check into virtio_net_update_host_features(),
>       as we now can call it only when needed (more explicit logic)
>     - drop extra includes
>     - no need in "attached_to_virtio_net" variable anymore
>     - add .has_tunnel to the state
>
> 19: add also test-cases for TAP migration without backend-transfer
>     (to be sure, that we don't break it with new feature:)
>
> Vladimir Sementsov-Ogievskiy (19):
>   net/tap: net_init_tap_one(): drop extra error propagation
>   net/tap: net_init_tap_one(): move parameter checking earlier
>   net/tap: rework net_tap_init()
>   net/tap: pass NULL to net_init_tap_one() in cases when scripts are
>     NULL
>   net/tap: rework scripts handling
>   net/tap: setup exit notifier only when needed
>   net/tap: split net_tap_fd_init()
>   net/tap: tap_set_sndbuf(): add return value
>   net/tap: rework tap_set_sndbuf()
>   net/tap: rework sndbuf handling
>   net/tap: introduce net_tap_setup()
>   net/tap: move vhost fd initialization to net_tap_new()
>   net/tap: finalize net_tap_set_fd() logic
>   migration: introduce .pre_incoming() vmsd handler
>   net/tap: postpone tap setup to pre-incoming
>   qapi: add interface for backend-transfer virtio-net/tap migration
>   virtio-net: support backend-transfer migration for virtio-net/tap
>   tests/functional: add skipWithoutSudo() decorator
>   tests/functional: add test_x86_64_tap_migration
>
>  hw/net/virtio-net.c                           | 150 ++++++-
>  include/migration/vmstate.h                   |   1 +
>  include/net/tap.h                             |   5 +
>  migration/migration.c                         |   4 +
>  migration/options.c                           |  33 ++
>  migration/options.h                           |   2 +
>  migration/savevm.c                            |  15 +
>  migration/savevm.h                            |   1 +
>  net/tap-bsd.c                                 |   3 +-
>  net/tap-linux.c                               |  19 +-
>  net/tap-solaris.c                             |   3 +-
>  net/tap-stub.c                                |   3 +-
>  net/tap-win32.c                               |  11 +
>  net/tap.c                                     | 425 +++++++++++++-----
>  net/tap_int.h                                 |   3 +-
>  qapi/migration.json                           |  42 +-
>  tests/functional/qemu_test/decorators.py      |  16 +
>  tests/functional/test_x86_64_tap_migration.py | 396 ++++++++++++++++
>  18 files changed, 1001 insertions(+), 131 deletions(-)
>  create mode 100644 tests/functional/test_x86_64_tap_migration.py
>
> --
> 2.48.1
>