On Fri, Oct 10, 2025 at 08:39:54PM +0300, Vladimir Sementsov-Ogievskiy wrote: > To migrate virtio-net TAP device backend (including open fds) locally, > user should simply set migration parameter > > backend-transfer = ["virtio-net-tap"] > > Why not simple boolean? To simplify migration to further versions, > when more devices will support backend-transfer migration. > > Alternatively, we may add per-device option to disable backend-transfer > migration, but still: > > 1. It's more comfortable to set same capabilities/parameters on both > source and target QEMU, than care about each device.
But it loses per-device control, right? Say, we can have two devices, and the admin can decide if only one of the devices will enable this feature. > > 2. To not break the design, that machine-type + device options + > migration capabilities and parameters are fully define the resulting > migration stream. We'll break this if add in future more > backend-transfer support in devices under same backend-transfer=true > parameter. Could you elaborate? I thought last time we discussed, we planned to have both the global knob and a per-device flag, then the feature is enabled only if both flags are set. If these parameters are all set the same on src/dst, would it also not break the design when new devices start to support it (and the new device will need to introduce its own per-device flags)? > > The commit only brings the interface, the realization will come in later > commit. That's why we add a temporary not-implemented error in > migrate_params_check(). > > Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> > --- > migration/options.c | 39 +++++++++++++++++++++++++++++++++++++++ > migration/options.h | 2 ++ > qapi/migration.json | 42 ++++++++++++++++++++++++++++++++++++------ > 3 files changed, 77 insertions(+), 6 deletions(-) > > diff --git a/migration/options.c b/migration/options.c > index 5183112775..76709af3ab 100644 > --- a/migration/options.c > +++ b/migration/options.c > @@ -13,6 +13,7 @@ > > #include "qemu/osdep.h" > #include "qemu/error-report.h" > +#include "qapi/util.h" > #include "exec/target_page.h" > #include "qapi/clone-visitor.h" > #include "qapi/error.h" > @@ -262,6 +263,20 @@ bool migrate_mapped_ram(void) > return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM]; > } > > +bool migrate_virtio_net_tap(void) > +{ > + MigrationState *s = migrate_get_current(); > + BackendTransferList *el = s->parameters.backend_transfer; > + > + for ( ; el; el = el->next) { > + if (el->value == BACKEND_TRANSFER_VIRTIO_NET_TAP) { So this is also something I want to avoid. The hope is we don't necessarily need to invent new device names into qapi/migration.json. OTOH, we can export a helper in migration/misc.h so that devices can query wehther the global feature is enabled or not, using that to AND the per-device flag. Thanks, > + return true; > + } > + } > + > + return false; > +} > + > bool migrate_ignore_shared(void) > { > MigrationState *s = migrate_get_current(); > @@ -963,6 +978,12 @@ MigrationParameters *qmp_query_migrate_parameters(Error > **errp) > params->cpr_exec_command = QAPI_CLONE(strList, > s->parameters.cpr_exec_command); > > + if (s->parameters.backend_transfer) { > + params->has_backend_transfer = true; > + params->backend_transfer = QAPI_CLONE(BackendTransferList, > + > s->parameters.backend_transfer); > + } > + > return params; > } > > @@ -997,6 +1018,7 @@ void migrate_params_init(MigrationParameters *params) > params->has_zero_page_detection = true; > params->has_direct_io = true; > params->has_cpr_exec_command = true; > + params->has_backend_transfer = true; > } > > /* > @@ -1183,6 +1205,12 @@ bool migrate_params_check(MigrationParameters *params, > Error **errp) > return false; > } > > + /* TODO: implement backend-transfer and remove this check */ > + if (params->has_backend_transfer) { > + error_setg(errp, "Not implemented"); > + return false; > + } > + > return true; > } > > @@ -1305,6 +1333,10 @@ static void > migrate_params_test_apply(MigrateSetParameters *params, > if (params->has_cpr_exec_command) { > dest->cpr_exec_command = params->cpr_exec_command; > } > + > + if (params->has_backend_transfer) { > + dest->backend_transfer = params->backend_transfer; > + } > } > > static void migrate_params_apply(MigrateSetParameters *params, Error **errp) > @@ -1443,6 +1475,13 @@ static void migrate_params_apply(MigrateSetParameters > *params, Error **errp) > s->parameters.cpr_exec_command = > QAPI_CLONE(strList, params->cpr_exec_command); > } > + > + if (params->has_backend_transfer) { > + qapi_free_BackendTransferList(s->parameters.backend_transfer); > + > + s->parameters.backend_transfer = QAPI_CLONE(BackendTransferList, > + > params->backend_transfer); > + } > } > > void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) > diff --git a/migration/options.h b/migration/options.h > index 82d839709e..55c0345433 100644 > --- a/migration/options.h > +++ b/migration/options.h > @@ -87,6 +87,8 @@ const char *migrate_tls_hostname(void); > uint64_t migrate_xbzrle_cache_size(void); > ZeroPageDetection migrate_zero_page_detection(void); > > +bool migrate_virtio_net_tap(void); > + > /* parameters helpers */ > > bool migrate_params_check(MigrationParameters *params, Error **errp); > diff --git a/qapi/migration.json b/qapi/migration.json > index be0f3fcc12..1bfe7df191 100644 > --- a/qapi/migration.json > +++ b/qapi/migration.json > @@ -770,6 +770,19 @@ > '*transform': 'BitmapMigrationBitmapAliasTransform' > } } > > +## > +# @BackendTransfer: > +# > +# @virtio-net-tap: Enable backend-transfer migration for > +# virtio-net/tap. When enabled, TAP fds and all related state are > +# passed to the destination in the migration channel (which must > +# be a UNIX domain socket). > +# > +# Since: 10.2 > +## > +{ 'enum': 'BackendTransfer', > + 'data': [ 'virtio-net-tap' ] } > + > ## > # @BitmapMigrationNodeAlias: > # > @@ -951,9 +964,13 @@ > # is @cpr-exec. The first list element is the program's filename, > # the remainder its arguments. (Since 10.2) > # > +# @backend-transfer: List of targets for backend-transfer migration. > +# See description in `BackendTransfer`. Default is no > +# backend-transfer migration (Since 10.2) > +# > # Features: > # > -# @unstable: Members @x-checkpoint-delay and > +# @unstable: Members @backend-transfer, @x-checkpoint-delay and > # @x-vcpu-dirty-limit-period are experimental. > # > # Since: 2.4 > @@ -978,7 +995,8 @@ > 'mode', > 'zero-page-detection', > 'direct-io', > - 'cpr-exec-command'] } > + 'cpr-exec-command', > + { 'name': 'backend-transfer', 'features': ['unstable'] } ] } > > ## > # @MigrateSetParameters: > @@ -1137,9 +1155,13 @@ > # is @cpr-exec. The first list element is the program's filename, > # the remainder its arguments. (Since 10.2) > # > +# @backend-transfer: List of targets for backend-transfer migration. > +# See description in `BackendTransfer`. Default is no > +# backend-transfer migration (Since 10.2) > +# > # Features: > # > -# @unstable: Members @x-checkpoint-delay and > +# @unstable: Members @backend-transfer, @x-checkpoint-delay and > # @x-vcpu-dirty-limit-period are experimental. > # > # TODO: either fuse back into `MigrationParameters`, or make > @@ -1179,7 +1201,9 @@ > '*mode': 'MigMode', > '*zero-page-detection': 'ZeroPageDetection', > '*direct-io': 'bool', > - '*cpr-exec-command': [ 'str' ]} } > + '*cpr-exec-command': [ 'str' ], > + '*backend-transfer': { 'type': [ 'BackendTransfer' ], > + 'features': [ 'unstable' ] } } } > > ## > # @migrate-set-parameters: > @@ -1352,9 +1376,13 @@ > # is @cpr-exec. The first list element is the program's filename, > # the remainder its arguments. (Since 10.2) > # > +# @backend-transfer: List of targets for backend-transfer migration. > +# See description in `BackendTransfer`. Default is no > +# backend-transfer migration (Since 10.2) > +# > # Features: > # > -# @unstable: Members @x-checkpoint-delay and > +# @unstable: Members @backend-transfer, @x-checkpoint-delay and > # @x-vcpu-dirty-limit-period are experimental. > # > # Since: 2.4 > @@ -1391,7 +1419,9 @@ > '*mode': 'MigMode', > '*zero-page-detection': 'ZeroPageDetection', > '*direct-io': 'bool', > - '*cpr-exec-command': [ 'str' ]} } > + '*cpr-exec-command': [ 'str' ], > + '*backend-transfer': { 'type': [ 'BackendTransfer' ], > + 'features': [ 'unstable' ] } } } > > ## > # @query-migrate-parameters: > -- > 2.48.1 > -- Peter Xu
