We are going to implement local-migration feature: some devices will be
able to transfer open file descriptors through migration stream (which
must UNIX domain socket for that purpose). This allows to transfer the
whole backend state without reconnecting and restarting the backend
service. For example, virtio-net will migrate its attached TAP netdev,
together with its connected file descriptors.
In this commit we introduce a migration parameter, which enables
the feature for supporting devices (no one at the moment).
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
include/migration/misc.h | 2 ++
migration/options.c | 18 +++++++++++++++++-
qapi/migration.json | 15 +++++++++++++--
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/include/migration/misc.h b/include/migration/misc.h
index 3159a5e53c3..b14dc70ea3d 100644
--- a/include/migration/misc.h
+++ b/include/migration/misc.h
@@ -156,4 +156,6 @@ bool multifd_device_state_save_thread_should_exit(void);
void multifd_abort_device_state_save_threads(void);
bool multifd_join_device_state_save_threads(void);
+bool migrate_local(void);
+
#endif
diff --git a/migration/options.c b/migration/options.c
index 1ffe85a2d8c..92144da3acb 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"
@@ -24,6 +25,7 @@
#include "migration/colo.h"
#include "migration/cpr.h"
#include "migration/misc.h"
+#include "migration/options.h"
#include "migration.h"
#include "migration-stats.h"
#include "qemu-file.h"
@@ -336,6 +338,12 @@ bool migrate_mapped_ram(void)
return s->capabilities[MIGRATION_CAPABILITY_MAPPED_RAM];
}
+bool migrate_local(void)
+{
+ MigrationState *s = migrate_get_current();
+ return s->parameters.local;
+}
+
bool migrate_ignore_shared(void)
{
MigrationState *s = migrate_get_current();
@@ -1047,7 +1055,7 @@ static void migrate_mark_all_params_present(MigrationParameters *p)
&p->has_announce_step, &p->has_block_bitmap_mapping,
&p->has_x_vcpu_dirty_limit_period, &p->has_vcpu_dirty_limit,
&p->has_mode, &p->has_zero_page_detection, &p->has_direct_io,
- &p->has_cpr_exec_command,
+ &p->has_cpr_exec_command, &p->has_local,
};
len = ARRAY_SIZE(has_fields);
@@ -1386,6 +1394,10 @@ static void migrate_params_test_apply(MigrationParameters *params,
if (params->has_cpr_exec_command) {
dest->cpr_exec_command = params->cpr_exec_command;
}
+
+ if (params->has_local) {
+ dest->local = params->local;
+ }
}
static void migrate_params_apply(MigrationParameters *params)
@@ -1514,6 +1526,10 @@ static void migrate_params_apply(MigrationParameters *params)
s->parameters.cpr_exec_command =
QAPI_CLONE(strList, params->cpr_exec_command);
}
+
+ if (params->has_local) {
+ s->parameters.local = params->local;
+ }
}
void qmp_migrate_set_parameters(MigrationParameters *params, Error **errp)
diff --git a/qapi/migration.json b/qapi/migration.json
index f925e5541bf..2c8d85f5834 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -828,7 +828,8 @@
'mode',
'zero-page-detection',
'direct-io',
- 'cpr-exec-command'] }
+ 'cpr-exec-command',
+ 'local'] }
##
# @migrate-set-parameters:
@@ -1004,6 +1005,15 @@
# is @cpr-exec. The first list element is the program's filename,
# the remainder its arguments. (Since 10.2)
#
+# @local: Enable local migration feature for devices that support
+# it. The feature is for local migration only and rely on the
+# channel support for passing file descriptors (it must be a UNIX
+# socket). In general that means that backend state and its file
+# descriptors are passed to the destination in the migration
+# channel. In general devices may have an option which in
+# conjunction with @local set to true enables the local-migration
+# feature for that device. (Since 11.0)
+#
# Features:
#
# @unstable: Members @x-checkpoint-delay and
@@ -1043,7 +1053,8 @@
'*mode': 'MigMode',
'*zero-page-detection': 'ZeroPageDetection',
'*direct-io': 'bool',
- '*cpr-exec-command': [ 'str' ]} }
+ '*cpr-exec-command': [ 'str' ],
+ '*local': 'bool' } }
##
# @query-migrate-parameters:
--
2.52.0
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > We are going to implement local-migration feature: some devices will be > able to transfer open file descriptors through migration stream (which > must UNIX domain socket for that purpose). This allows to transfer the > whole backend state without reconnecting and restarting the backend > service. For example, virtio-net will migrate its attached TAP netdev, > together with its connected file descriptors. > > In this commit we introduce a migration parameter, which enables > the feature for supporting devices (no one at the moment). for devices that support it (none at the moment). > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> > Reviewed-by: Peter Xu <peterx@redhat.com> [...] > diff --git a/qapi/migration.json b/qapi/migration.json > index f925e5541bf..2c8d85f5834 100644 > --- a/qapi/migration.json > +++ b/qapi/migration.json > @@ -828,7 +828,8 @@ > 'mode', > 'zero-page-detection', > 'direct-io', > - 'cpr-exec-command'] } > + 'cpr-exec-command', > + 'local'] } > > ## > # @migrate-set-parameters: > @@ -1004,6 +1005,15 @@ > # is @cpr-exec. The first list element is the program's filename, > # the remainder its arguments. (Since 10.2) > # > +# @local: Enable local migration feature for devices that support > +# it. The feature is for local migration only and rely on the > +# channel support for passing file descriptors (it must be a UNIX > +# socket). In general that means that backend state and its file > +# descriptors are passed to the destination in the migration > +# channel. In general devices may have an option which in > +# conjunction with @local set to true enables the local-migration > +# feature for that device. (Since 11.0) This needs polish. Let me try. # @local: Enable local migration for devices that support it. Backend # state and its file descriptors are then passed to the # destination in the migration channel. The migration channel # must be a Unix domain socket. Also needs to be enabled per # device by setting device property "local" to true. > +# > # Features: > # > # @unstable: Members @x-checkpoint-delay and > @@ -1043,7 +1053,8 @@ > '*mode': 'MigMode', > '*zero-page-detection': 'ZeroPageDetection', > '*direct-io': 'bool', > - '*cpr-exec-command': [ 'str' ]} } > + '*cpr-exec-command': [ 'str' ], > + '*local': 'bool' } } > > ## > # @query-migrate-parameters:
On 10.03.26 16:53, Markus Armbruster wrote: > Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > >> We are going to implement local-migration feature: some devices will be >> able to transfer open file descriptors through migration stream (which >> must UNIX domain socket for that purpose). This allows to transfer the >> whole backend state without reconnecting and restarting the backend >> service. For example, virtio-net will migrate its attached TAP netdev, >> together with its connected file descriptors. >> >> In this commit we introduce a migration parameter, which enables >> the feature for supporting devices (no one at the moment). > > for devices that support it (none at the moment). > >> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> >> Reviewed-by: Peter Xu <peterx@redhat.com> > > [...] > >> diff --git a/qapi/migration.json b/qapi/migration.json >> index f925e5541bf..2c8d85f5834 100644 >> --- a/qapi/migration.json >> +++ b/qapi/migration.json >> @@ -828,7 +828,8 @@ >> 'mode', >> 'zero-page-detection', >> 'direct-io', >> - 'cpr-exec-command'] } >> + 'cpr-exec-command', >> + 'local'] } >> >> ## >> # @migrate-set-parameters: >> @@ -1004,6 +1005,15 @@ >> # is @cpr-exec. The first list element is the program's filename, >> # the remainder its arguments. (Since 10.2) >> # >> +# @local: Enable local migration feature for devices that support >> +# it. The feature is for local migration only and rely on the >> +# channel support for passing file descriptors (it must be a UNIX >> +# socket). In general that means that backend state and its file >> +# descriptors are passed to the destination in the migration >> +# channel. In general devices may have an option which in >> +# conjunction with @local set to true enables the local-migration >> +# feature for that device. (Since 11.0) > > This needs polish. Let me try. > > # @local: Enable local migration for devices that support it. Backend > # state and its file descriptors are then passed to the > # destination in the migration channel. The migration channel > # must be a Unix domain socket. Also needs to be enabled per > # device by setting device property "local" to true. As discussed in v11, we don't want to require neither concrete property name nor even the existence of such property, that why it was worded "may have an option". https://lore.kernel.org/qemu-devel/aZyS4UizvDq1Wnpq@x1.local/ > >> +# >> # Features: >> # >> # @unstable: Members @x-checkpoint-delay and >> @@ -1043,7 +1053,8 @@ >> '*mode': 'MigMode', >> '*zero-page-detection': 'ZeroPageDetection', >> '*direct-io': 'bool', >> - '*cpr-exec-command': [ 'str' ]} } >> + '*cpr-exec-command': [ 'str' ], >> + '*local': 'bool' } } >> >> ## >> # @query-migrate-parameters: > -- Best regards, Vladimir
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > On 10.03.26 16:53, Markus Armbruster wrote: >> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: >> >>> We are going to implement local-migration feature: some devices will be >>> able to transfer open file descriptors through migration stream (which >>> must UNIX domain socket for that purpose). This allows to transfer the >>> whole backend state without reconnecting and restarting the backend >>> service. For example, virtio-net will migrate its attached TAP netdev, >>> together with its connected file descriptors. >>> >>> In this commit we introduce a migration parameter, which enables >>> the feature for supporting devices (no one at the moment). >> >> for devices that support it (none at the moment). >> >>> >>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> >>> Reviewed-by: Peter Xu <peterx@redhat.com> >> >> [...] >> >>> diff --git a/qapi/migration.json b/qapi/migration.json >>> index f925e5541bf..2c8d85f5834 100644 >>> --- a/qapi/migration.json >>> +++ b/qapi/migration.json >>> @@ -828,7 +828,8 @@ >>> 'mode', >>> 'zero-page-detection', >>> 'direct-io', >>> - 'cpr-exec-command'] } >>> + 'cpr-exec-command', >>> + 'local'] } >>> >>> ## >>> # @migrate-set-parameters: >>> @@ -1004,6 +1005,15 @@ >>> # is @cpr-exec. The first list element is the program's filename, >>> # the remainder its arguments. (Since 10.2) >>> # >>> +# @local: Enable local migration feature for devices that support >>> +# it. The feature is for local migration only and rely on the >>> +# channel support for passing file descriptors (it must be a UNIX >>> +# socket). In general that means that backend state and its file >>> +# descriptors are passed to the destination in the migration >>> +# channel. In general devices may have an option which in >>> +# conjunction with @local set to true enables the local-migration >>> +# feature for that device. (Since 11.0) >> >> This needs polish. Let me try. >> >> # @local: Enable local migration for devices that support it. Backend >> # state and its file descriptors are then passed to the >> # destination in the migration channel. The migration channel >> # must be a Unix domain socket. Also needs to be enabled per >> # device by setting device property "local" to true. > > As discussed in v11, we don't want to require neither concrete property name > nor even the existence of such property, that why it was worded "may have an option". > > https://lore.kernel.org/qemu-devel/aZyS4UizvDq1Wnpq@x1.local/ Scratch "by setting ..." then, and maybe replace "also" by "usually". [...]
On 10.03.26 18:22, Markus Armbruster wrote: > Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > >> On 10.03.26 16:53, Markus Armbruster wrote: >>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: >>> >>>> We are going to implement local-migration feature: some devices will be >>>> able to transfer open file descriptors through migration stream (which >>>> must UNIX domain socket for that purpose). This allows to transfer the >>>> whole backend state without reconnecting and restarting the backend >>>> service. For example, virtio-net will migrate its attached TAP netdev, >>>> together with its connected file descriptors. >>>> >>>> In this commit we introduce a migration parameter, which enables >>>> the feature for supporting devices (no one at the moment). >>> >>> for devices that support it (none at the moment). >>> >>>> >>>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> >>>> Reviewed-by: Peter Xu <peterx@redhat.com> >>> >>> [...] >>> >>>> diff --git a/qapi/migration.json b/qapi/migration.json >>>> index f925e5541bf..2c8d85f5834 100644 >>>> --- a/qapi/migration.json >>>> +++ b/qapi/migration.json >>>> @@ -828,7 +828,8 @@ >>>> 'mode', >>>> 'zero-page-detection', >>>> 'direct-io', >>>> - 'cpr-exec-command'] } >>>> + 'cpr-exec-command', >>>> + 'local'] } >>>> >>>> ## >>>> # @migrate-set-parameters: >>>> @@ -1004,6 +1005,15 @@ >>>> # is @cpr-exec. The first list element is the program's filename, >>>> # the remainder its arguments. (Since 10.2) >>>> # >>>> +# @local: Enable local migration feature for devices that support >>>> +# it. The feature is for local migration only and rely on the >>>> +# channel support for passing file descriptors (it must be a UNIX >>>> +# socket). In general that means that backend state and its file >>>> +# descriptors are passed to the destination in the migration >>>> +# channel. In general devices may have an option which in >>>> +# conjunction with @local set to true enables the local-migration >>>> +# feature for that device. (Since 11.0) >>> >>> This needs polish. Let me try. >>> >>> # @local: Enable local migration for devices that support it. Backend >>> # state and its file descriptors are then passed to the >>> # destination in the migration channel. The migration channel >>> # must be a Unix domain socket. Also needs to be enabled per >>> # device by setting device property "local" to true. >> >> As discussed in v11, we don't want to require neither concrete property name >> nor even the existence of such property, that why it was worded "may have an option". >> >> https://lore.kernel.org/qemu-devel/aZyS4UizvDq1Wnpq@x1.local/ > > Scratch "by setting ..." then, and maybe replace "also" by "usually". > so, # @local: Enable local migration for devices that support it. Backend # state and its file descriptors are then passed to the # destination in the migration channel. The migration channel # must be a Unix domain socket. Usually needs to be enabled per # device. Sounds good to me. Will use it for v13, if no more comments. -- Best regards, Vladimir
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > On 10.03.26 18:22, Markus Armbruster wrote: >> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: >> >>> On 10.03.26 16:53, Markus Armbruster wrote: [...] >>>> This needs polish. Let me try. >>>> >>>> # @local: Enable local migration for devices that support it. Backend >>>> # state and its file descriptors are then passed to the >>>> # destination in the migration channel. The migration channel >>>> # must be a Unix domain socket. Also needs to be enabled per >>>> # device by setting device property "local" to true. >>> >>> As discussed in v11, we don't want to require neither concrete property name >>> nor even the existence of such property, that why it was worded "may have an option". >>> >>> https://lore.kernel.org/qemu-devel/aZyS4UizvDq1Wnpq@x1.local/ >> Scratch "by setting ..." then, and maybe replace "also" by "usually". >> > > so, > > # @local: Enable local migration for devices that support it. Backend > # state and its file descriptors are then passed to the Perhaps "can then passed", to further emphasize the need for per device enabling. > # destination in the migration channel. The migration channel > # must be a Unix domain socket. Usually needs to be enabled per > # device. > > > Sounds good to me. Will use it for v13, if no more comments.
On 10.03.26 18:58, Markus Armbruster wrote: > Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: > >> On 10.03.26 18:22, Markus Armbruster wrote: >>> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes: >>> >>>> On 10.03.26 16:53, Markus Armbruster wrote: > > [...] > >>>>> This needs polish. Let me try. >>>>> >>>>> # @local: Enable local migration for devices that support it. Backend >>>>> # state and its file descriptors are then passed to the >>>>> # destination in the migration channel. The migration channel >>>>> # must be a Unix domain socket. Also needs to be enabled per >>>>> # device by setting device property "local" to true. >>>> >>>> As discussed in v11, we don't want to require neither concrete property name >>>> nor even the existence of such property, that why it was worded "may have an option". >>>> >>>> https://lore.kernel.org/qemu-devel/aZyS4UizvDq1Wnpq@x1.local/ >>> Scratch "by setting ..." then, and maybe replace "also" by "usually". >>> >> >> so, >> >> # @local: Enable local migration for devices that support it. Backend >> # state and its file descriptors are then passed to the > > Perhaps "can then passed", to further emphasize the need for per device > enabling. Ok > >> # destination in the migration channel. The migration channel >> # must be a Unix domain socket. Usually needs to be enabled per >> # device. >> >> >> Sounds good to me. Will use it for v13, if no more comments. > -- Best regards, Vladimir
© 2016 - 2026 Red Hat, Inc.