Message ID | 20240220224138.24759-28-farosas@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | migration: File based migration with multifd and fixed-ram | expand |
Fabiano Rosas <farosas@suse.de> writes: > Add the direct-io migration parameter that tells the migration code to > use O_DIRECT when opening the migration stream file whenever possible. > > This is currently only used with the fixed-ram migration that has a > clear window guaranteed to perform aligned writes. > > Signed-off-by: Fabiano Rosas <farosas@suse.de> [...] > diff --git a/qapi/migration.json b/qapi/migration.json > index 3fce5fe53e..41241a2178 100644 > --- a/qapi/migration.json > +++ b/qapi/migration.json > @@ -878,6 +878,9 @@ > # @mode: Migration mode. See description in @MigMode. Default is 'normal'. > # (Since 8.2) > # > +# @direct-io: Open migration files with O_DIRECT when possible. This > +# requires that the 'fixed-ram' capability is enabled. (since 9.0) 'fixed-ram' is a cross-reference to MigrationCapability member fixed-ram. For local members, @name is better than 'name', because @name carries meaning, while 'name' could be anything. Currently, @name is merely shorthand for ``name``, which is an reST "inline literal", commonly used for short code snippets. Rendered in fixed-width font, unlike 'name'. Making @name generating a link to the description would be a nice improvement. For non-local members, we can't make @name a link without also specifying the thing it's a member of. Let's stick to @name for member names, even non-local ones, so we get the same font for all of them. > +# > # Features: > # > # @deprecated: Member @block-incremental is deprecated. Use > @@ -911,7 +914,8 @@ > 'block-bitmap-mapping', > { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, > 'vcpu-dirty-limit', > - 'mode'] } > + 'mode', > + 'direct-io'] } > > ## > # @MigrateSetParameters: > @@ -1070,6 +1074,9 @@ > # @mode: Migration mode. See description in @MigMode. Default is 'normal'. > # (Since 8.2) > # > +# @direct-io: Open migration files with O_DIRECT when possible. This > +# requires that the 'fixed-ram' capability is enabled. (since 9.0) > +# > # Features: > # > # @deprecated: Member @block-incremental is deprecated. Use > @@ -1123,7 +1130,8 @@ > '*x-vcpu-dirty-limit-period': { 'type': 'uint64', > 'features': [ 'unstable' ] }, > '*vcpu-dirty-limit': 'uint64', > - '*mode': 'MigMode'} } > + '*mode': 'MigMode', > + '*direct-io': 'bool' } } > > ## > # @migrate-set-parameters: > @@ -1298,6 +1306,9 @@ > # @mode: Migration mode. See description in @MigMode. Default is 'normal'. > # (Since 8.2) > # > +# @direct-io: Open migration files with O_DIRECT when possible. This > +# requires that the 'fixed-ram' capability is enabled. (since 9.0) > +# > # Features: > # > # @deprecated: Member @block-incremental is deprecated. Use > @@ -1348,7 +1359,8 @@ > '*x-vcpu-dirty-limit-period': { 'type': 'uint64', > 'features': [ 'unstable' ] }, > '*vcpu-dirty-limit': 'uint64', > - '*mode': 'MigMode'} } > + '*mode': 'MigMode', > + '*direct-io': 'bool' } } > > ## > # @query-migrate-parameters: Other than that, QAPI schema Acked-by: Markus Armbruster <armbru@redhat.com>
On Tue, Feb 20, 2024 at 07:41:31PM -0300, Fabiano Rosas wrote: > Add the direct-io migration parameter that tells the migration code to > use O_DIRECT when opening the migration stream file whenever possible. > > This is currently only used with the fixed-ram migration that has a > clear window guaranteed to perform aligned writes. > > Signed-off-by: Fabiano Rosas <farosas@suse.de> I didn't read into this patch and followings yet. I think we have a discussion last time and the plan is we hopefully can merge part of fixed-ram already for 9.0 (March 12th softfreeze). I suggest we focus with the first 26 patches and land them first if possible. If you agree then feel free to respin without direct-ios. Then we can keep the discussions separate, and direct-ios can be concurrently discussed, but then posted as another patchset (with proper based-on: tags)? Thanks,
Peter Xu <peterx@redhat.com> writes: > On Tue, Feb 20, 2024 at 07:41:31PM -0300, Fabiano Rosas wrote: >> Add the direct-io migration parameter that tells the migration code to >> use O_DIRECT when opening the migration stream file whenever possible. >> >> This is currently only used with the fixed-ram migration that has a >> clear window guaranteed to perform aligned writes. >> >> Signed-off-by: Fabiano Rosas <farosas@suse.de> > > I didn't read into this patch and followings yet. > > I think we have a discussion last time and the plan is we hopefully can > merge part of fixed-ram already for 9.0 (March 12th softfreeze). > > I suggest we focus with the first 26 patches and land them first if > possible. If you agree then feel free to respin without direct-ios. Then > we can keep the discussions separate, and direct-ios can be concurrently > discussed, but then posted as another patchset (with proper based-on: > tags)? Ok, I'll be working on the respin without direct-io. Thanks > > Thanks,
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index c7053cdc2b..645c14a65d 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -612,6 +612,8 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive); bool qemu_has_ofd_lock(void); #endif +bool qemu_has_direct_io(void); + #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" #elif defined(WIN64) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99b49df5dd..77313346c2 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -392,6 +392,13 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MODE), qapi_enum_lookup(&MigMode_lookup, params->mode)); + + if (params->has_direct_io) { + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str( + MIGRATION_PARAMETER_DIRECT_IO), + params->direct_io ? "on" : "off"); + } } qapi_free_MigrationParameters(params); @@ -681,6 +688,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_mode = true; visit_type_MigMode(v, param, &p->mode, &err); break; + case MIGRATION_PARAMETER_DIRECT_IO: + p->has_direct_io = true; + visit_type_bool(v, param, &p->direct_io, &err); + break; default: assert(0); } diff --git a/migration/options.c b/migration/options.c index bfcd2d7132..b347dbc670 100644 --- a/migration/options.c +++ b/migration/options.c @@ -823,6 +823,22 @@ int migrate_decompress_threads(void) return s->parameters.decompress_threads; } +bool migrate_direct_io(void) +{ + MigrationState *s = migrate_get_current(); + + /* For now O_DIRECT is only supported with fixed-ram */ + if (!s->capabilities[MIGRATION_CAPABILITY_FIXED_RAM]) { + return false; + } + + if (s->parameters.has_direct_io) { + return s->parameters.direct_io; + } + + return false; +} + uint64_t migrate_downtime_limit(void) { MigrationState *s = migrate_get_current(); @@ -1042,6 +1058,11 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->has_mode = true; params->mode = s->parameters.mode; + if (s->parameters.has_direct_io) { + params->has_direct_io = true; + params->direct_io = s->parameters.direct_io; + } + return params; } @@ -1077,6 +1098,7 @@ void migrate_params_init(MigrationParameters *params) params->has_x_vcpu_dirty_limit_period = true; params->has_vcpu_dirty_limit = true; params->has_mode = true; + params->has_direct_io = qemu_has_direct_io(); } /* @@ -1386,6 +1408,10 @@ static void migrate_params_test_apply(MigrateSetParameters *params, if (params->has_mode) { dest->mode = params->mode; } + + if (params->has_direct_io) { + dest->direct_io = params->direct_io; + } } static void migrate_params_apply(MigrateSetParameters *params, Error **errp) @@ -1530,6 +1556,10 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_mode) { s->parameters.mode = params->mode; } + + if (params->has_direct_io) { + s->parameters.direct_io = params->direct_io; + } } void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 3fce5fe53e..41241a2178 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -878,6 +878,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -911,7 +914,8 @@ 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, 'vcpu-dirty-limit', - 'mode'] } + 'mode', + 'direct-io'] } ## # @MigrateSetParameters: @@ -1070,6 +1074,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1123,7 +1130,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*direct-io': 'bool' } } ## # @migrate-set-parameters: @@ -1298,6 +1306,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1348,7 +1359,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*direct-io': 'bool' } } ## # @query-migrate-parameters:
Add the direct-io migration parameter that tells the migration code to use O_DIRECT when opening the migration stream file whenever possible. This is currently only used with the fixed-ram migration that has a clear window guaranteed to perform aligned writes. Signed-off-by: Fabiano Rosas <farosas@suse.de> --- include/qemu/osdep.h | 2 ++ migration/migration-hmp-cmds.c | 11 +++++++++++ migration/options.c | 30 ++++++++++++++++++++++++++++++ qapi/migration.json | 18 +++++++++++++++--- 4 files changed, 58 insertions(+), 3 deletions(-)