On 14.07.26 18:42, Vladimir Sementsov-Ogievskiy wrote:
Support transferring of TAP state (including open fd).
Add new property "local-migration-supported", which defines
whether local-migration is actually supported for this TAP device.
Starting from 11.2 QEMU Machine Types it's enabled by default.
Note that local-migration (including migrating opened FDs
through migration channel, which must be UNIX socket) is
enabled by global "local" migration parameters. But individual
devices may have additional options to enable/disable it
per device.
The tricky thing is that we need to know whether to call open/connect in
TAP initialization code, i.e. we need to know the value of migration
parameter "local" when creating the TAP device. For incoming migration,
we can know only for TAP devices created with QMP after setting the
migration parameter with QMP.
So the full picture is:
On source, to start outgoing "local" migration you need:
- migration parameter "local" set to true
- "local-migration-supported" TAP option set to true (the
default, starting from 11.2 QEMU Machine Types)
If at least one of these options is not set, TAP backend
doesn't participate in migration.
On target, things are more difficult:
Same, you need both "local" and "local-migration-supported"
be set. And same, if one of them is not set, TAP backend
is initialized as usual, and doesn't accept any incoming
state.
Additionally, if you are going to set "local", it must be
set before creating the TAP device. If TAP device created
with "local" unset, it initializes as usual. If you enable
"local" after it and start incoming migration, it will fail
in .pre_load handler of TAP backend.
Moreover, there are interface restrictions: if you create TAP
device when QEMU is in INCOMING state, and both "local"
and "local-migration-supported" set, most of TAP options are
not allowed, and script/downscript are required to be explicitly
unset (set to "" or "no").
Signed-off-by: Vladimir Sementsov-Ogievskiy<[email protected]>
---
net/tap.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++--
qapi/net.json | 22 ++++++-
2 files changed, 180 insertions(+), 7 deletions(-)
squash in, to mark it unstable:
diff --git a/net/tap.c b/net/tap.c
index 4162820bcee..250ae15acb7 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -558,7 +558,7 @@ static void tap_class_init(ObjectClass *klass, const void
*data)
vc->get_id = tap_vmstate_if_get_id;
- object_class_property_add_bool(klass, "local-migration-supported",
+ object_class_property_add_bool(klass, "x-local-migration-supported",
tap_get_local_migration_supported_prop,
tap_set_local_migration_supported_prop);
}
@@ -958,8 +958,8 @@ static bool net_init_tap_one(const NetdevTapOptions *tap,
NetClientState *peer,
{
TAPState *s = net_tap_fd_init(peer, tap->helper ? "bridge" : "tap",
name, fd, vnet_hdr, queue_index,
- tap->has_local_migration_supported,
- tap->local_migration_supported);
+ tap->has_x_local_migration_supported,
+ tap->x_local_migration_supported);
bool sndbuf_required = tap->has_sndbuf;
int sndbuf =
(tap->has_sndbuf && tap->sndbuf) ? MIN(tap->sndbuf, INT_MAX) : INT_MAX;
@@ -1130,7 +1130,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
return -1;
}
- incoming_fds = tap->local_migration_supported && migrate_local() &&
+ incoming_fds = tap->x_local_migration_supported && migrate_local() &&
runstate_check(RUN_STATE_INMIGRATE);
if (incoming_fds &&
@@ -1140,7 +1140,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
!tap_is_explicit_no_script("downscript", tap->downscript))) {
error_setg(errp, "Local incoming migration of TAP device (-incoming, "
"migration parameter @local is set, "
- "TAP parameter @local-migration-supported is set) "
+ "TAP parameter @x-local-migration-supported is set) "
"is incompatible with "
"fd=, fds=, helper=, br=, ifname=, sndbuf= and vnet_hdr=, "
"and requires explicit empty script= and downscript=");
@@ -1168,8 +1168,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
if (incoming_fds) {
for (i = 0; i < queues; i++) {
TAPState *s = new_tap(peer, "tap", name, i,
- tap->has_local_migration_supported,
- tap->local_migration_supported);
+ tap->has_x_local_migration_supported,
+ tap->x_local_migration_supported);
qemu_set_info_str(&s->nc, "incoming");
s->fd = -1;
diff --git a/qapi/net.json b/qapi/net.json
index d0d6e303b0d..e244cc62658 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -435,7 +435,7 @@
# @poll-us: maximum number of microseconds that could be spent on busy
# polling for tap (since 2.7)
#
-# @local-migration-supported: enable local migration for this TAP
+# @x-local-migration-supported: enable local migration for this TAP
# backend. When set, local migration is enabled/disabled by
# migration parameter @local for this TAP backend. When unset,
# migration parameter @local is ignored for this TAP backend.
@@ -447,13 +447,17 @@
# after creating TAP backend with @local-migration-supporeted
# parameter set) will simply fail.
# Moreover, when QEMU is in incoming migration state, migration
-# parameter @local is set and @local-migration-supported is set,
+# parameter @local is set and @x-local-migration-supported is set,
# the following options are not supported and must not be set:
# @fd, @fds, @helper, @br, @ifname, @sndbuf, @vnet_hdr.
# Additionally in this case @script and @downscipt must be
# explicitly disabled (empty strings or "no").
# (Since 11.2)
#
+# Features:
+#
+# @unstable: Member @x-local-migration-supported is experimental.
+#
# Since: 1.2
##
{ 'struct': 'NetdevTapOptions',
@@ -473,7 +477,8 @@
'*vhostforce': 'bool',
'*queues': 'uint32',
'*poll-us': 'uint32',
- '*local-migration-supported': 'bool' } }
+ '*x-local-migration-supported': {
+ 'type': 'bool', 'features' : [ 'unstable'] } } }
##
# @NetdevSocketOptions:
diff --git a/tests/functional/x86_64/test_tap_migration.py
b/tests/functional/x86_64/test_tap_migration.py
index bcc0a60dfe9..5edf3f0fee2 100755
--- a/tests/functional/x86_64/test_tap_migration.py
+++ b/tests/functional/x86_64/test_tap_migration.py
@@ -329,7 +329,7 @@ def add_virtio_net(
"queues": 4,
"script": "no",
"downscript": "no",
- "local-migration-supported": local,
+ "x-local-migration-supported": local,
}
if not (local and incoming):
--
Best regards,
Vladimir