Message ID | 20210121185113.66277-1-dgilbert@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | migration: Provide a test for migratability | expand |
On Thu, 21 Jan 2021 18:51:13 +0000 "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > Provide a simple way to see if there's currently a migration blocker in > operation: > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n > > (qemu) info migratable > Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial' FWIW, a vfio device gets: (qemu) info migratable Error: VFIO device doesn't support migration I think your example is getting the device string because you're testing something with unmigratable = 1 in the vmsd and the iterator prints a generic string plus the device, we'd need to make our error message include the device info. But even without that it seems more useful than we have currently. Thanks Tested-by: Alex Williamson <alex.williamson@redhat.com> > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic > > (qemu) info migratable > Migratable > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > hmp-commands-info.hx | 14 ++++++++++++++ > include/monitor/hmp.h | 1 + > migration/migration.c | 5 +++++ > monitor/hmp-cmds.c | 13 +++++++++++++ > qapi/migration.json | 14 ++++++++++++++ > 5 files changed, 47 insertions(+) > > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > index 117ba25f91..c2d7ac2f11 100644 > --- a/hmp-commands-info.hx > +++ b/hmp-commands-info.hx > @@ -541,6 +541,20 @@ SRST > Show migration status. > ERST > > + { > + .name = "migratable", > + .args_type = "", > + .params = "", > + .help = "tests if VM is migratable", > + .cmd = hmp_info_migratable, > + }, > + > +SRST > + ''info migratable'' > + Tests whether the VM is currently migratable. > +ERST > + > + > { > .name = "migrate_capabilities", > .args_type = "", > diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h > index ed2913fd18..0dd7941daf 100644 > --- a/include/monitor/hmp.h > +++ b/include/monitor/hmp.h > @@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict); > void hmp_info_uuid(Monitor *mon, const QDict *qdict); > void hmp_info_chardev(Monitor *mon, const QDict *qdict); > void hmp_info_mice(Monitor *mon, const QDict *qdict); > +void hmp_info_migratable(Monitor *mon, const QDict *qdict); > void hmp_info_migrate(Monitor *mon, const QDict *qdict); > void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict); > void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict); > diff --git a/migration/migration.c b/migration/migration.c > index 5e330cc6eb..8745a5b9f9 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp) > return migrate_xbzrle_cache_size(); > } > > +void qmp_query_migratable(Error **errp) > +{ > + migration_is_blocked(errp); > +} > + > void qmp_migrate_set_speed(int64_t value, Error **errp) > { > MigrateSetParameters p = { > diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c > index ef569035f8..a7f48b3512 100644 > --- a/monitor/hmp-cmds.c > +++ b/monitor/hmp-cmds.c > @@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr) > } > } > > +void hmp_info_migratable(Monitor *mon, const QDict *qdict) > +{ > + Error *err = NULL; > + /* It's migratable if this succeeds */ > + qmp_query_migratable(&err); > + if (err) { > + hmp_handle_error(mon, err); > + return; > + } > + > + monitor_printf(mon, "Migratable\n"); > +} > + > void hmp_info_migrate(Monitor *mon, const QDict *qdict) > { > MigrationInfo *info; > diff --git a/qapi/migration.json b/qapi/migration.json > index d1d9632c2a..07aee9907c 100644 > --- a/qapi/migration.json > +++ b/qapi/migration.json > @@ -366,6 +366,20 @@ > ## > { 'command': 'query-migrate', 'returns': 'MigrationInfo' } > > +## > +# @query-migratable: > +# Tests whether it will be possible to migrate the VM in the current state. > +# > +# Returns: nothing on success (i.e. if the VM is migratable) > +# > +# Since: 6.0 > +# Example: > +# > +# -> { "execute": "query-migratable" } > +# <- { "return": {} } > +## > +{ 'command': 'query-migratable' } > + > ## > # @MigrationCapability: > #
* Alex Williamson (alex.williamson@redhat.com) wrote: > On Thu, 21 Jan 2021 18:51:13 +0000 > "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote: > > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > Provide a simple way to see if there's currently a migration blocker in > > operation: > > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n > > > > (qemu) info migratable > > Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial' > > FWIW, a vfio device gets: > > (qemu) info migratable > Error: VFIO device doesn't support migration > > I think your example is getting the device string because you're > testing something with unmigratable = 1 in the vmsd and the iterator > prints a generic string plus the device, we'd need to make our error > message include the device info. But even without that it seems more > useful than we have currently. Thanks The 'migrate_add_blocker' function just takes the error you give it; it would be nice to add something like a device_add_migrate_blocker that filled in the name. > Tested-by: Alex Williamson <alex.williamson@redhat.com> Thanks. Dave > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic > > > > (qemu) info migratable > > Migratable > > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > --- > > hmp-commands-info.hx | 14 ++++++++++++++ > > include/monitor/hmp.h | 1 + > > migration/migration.c | 5 +++++ > > monitor/hmp-cmds.c | 13 +++++++++++++ > > qapi/migration.json | 14 ++++++++++++++ > > 5 files changed, 47 insertions(+) > > > > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > > index 117ba25f91..c2d7ac2f11 100644 > > --- a/hmp-commands-info.hx > > +++ b/hmp-commands-info.hx > > @@ -541,6 +541,20 @@ SRST > > Show migration status. > > ERST > > > > + { > > + .name = "migratable", > > + .args_type = "", > > + .params = "", > > + .help = "tests if VM is migratable", > > + .cmd = hmp_info_migratable, > > + }, > > + > > +SRST > > + ''info migratable'' > > + Tests whether the VM is currently migratable. > > +ERST > > + > > + > > { > > .name = "migrate_capabilities", > > .args_type = "", > > diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h > > index ed2913fd18..0dd7941daf 100644 > > --- a/include/monitor/hmp.h > > +++ b/include/monitor/hmp.h > > @@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict); > > void hmp_info_uuid(Monitor *mon, const QDict *qdict); > > void hmp_info_chardev(Monitor *mon, const QDict *qdict); > > void hmp_info_mice(Monitor *mon, const QDict *qdict); > > +void hmp_info_migratable(Monitor *mon, const QDict *qdict); > > void hmp_info_migrate(Monitor *mon, const QDict *qdict); > > void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict); > > void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict); > > diff --git a/migration/migration.c b/migration/migration.c > > index 5e330cc6eb..8745a5b9f9 100644 > > --- a/migration/migration.c > > +++ b/migration/migration.c > > @@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp) > > return migrate_xbzrle_cache_size(); > > } > > > > +void qmp_query_migratable(Error **errp) > > +{ > > + migration_is_blocked(errp); > > +} > > + > > void qmp_migrate_set_speed(int64_t value, Error **errp) > > { > > MigrateSetParameters p = { > > diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c > > index ef569035f8..a7f48b3512 100644 > > --- a/monitor/hmp-cmds.c > > +++ b/monitor/hmp-cmds.c > > @@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr) > > } > > } > > > > +void hmp_info_migratable(Monitor *mon, const QDict *qdict) > > +{ > > + Error *err = NULL; > > + /* It's migratable if this succeeds */ > > + qmp_query_migratable(&err); > > + if (err) { > > + hmp_handle_error(mon, err); > > + return; > > + } > > + > > + monitor_printf(mon, "Migratable\n"); > > +} > > + > > void hmp_info_migrate(Monitor *mon, const QDict *qdict) > > { > > MigrationInfo *info; > > diff --git a/qapi/migration.json b/qapi/migration.json > > index d1d9632c2a..07aee9907c 100644 > > --- a/qapi/migration.json > > +++ b/qapi/migration.json > > @@ -366,6 +366,20 @@ > > ## > > { 'command': 'query-migrate', 'returns': 'MigrationInfo' } > > > > +## > > +# @query-migratable: > > +# Tests whether it will be possible to migrate the VM in the current state. > > +# > > +# Returns: nothing on success (i.e. if the VM is migratable) > > +# > > +# Since: 6.0 > > +# Example: > > +# > > +# -> { "execute": "query-migratable" } > > +# <- { "return": {} } > > +## > > +{ 'command': 'query-migratable' } > > + > > ## > > # @MigrationCapability: > > # >
On 1/21/21 12:51 PM, Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > Provide a simple way to see if there's currently a migration blocker in > operation: > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n > > (qemu) info migratable > Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial' > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic > > (qemu) info migratable > Migratable > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > +++ b/qapi/migration.json > @@ -366,6 +366,20 @@ > ## > { 'command': 'query-migrate', 'returns': 'MigrationInfo' } > > +## > +# @query-migratable: > +# Tests whether it will be possible to migrate the VM in the current state. > +# > +# Returns: nothing on success (i.e. if the VM is migratable) Do we really need a new command? Or can we get away with enhancing the existing 'query-migrate' to add another bool field to 'MigrationInfo'?
* Eric Blake (eblake@redhat.com) wrote: > On 1/21/21 12:51 PM, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > Provide a simple way to see if there's currently a migration blocker in > > operation: > > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n > > > > (qemu) info migratable > > Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial' > > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic > > > > (qemu) info migratable > > Migratable > > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > --- > > > > +++ b/qapi/migration.json > > @@ -366,6 +366,20 @@ > > ## > > { 'command': 'query-migrate', 'returns': 'MigrationInfo' } > > > > +## > > +# @query-migratable: > > +# Tests whether it will be possible to migrate the VM in the current state. > > +# > > +# Returns: nothing on success (i.e. if the VM is migratable) > > Do we really need a new command? Or can we get away with enhancing the > existing 'query-migrate' to add another bool field to 'MigrationInfo'? In the case where the VM is not migratable this command errors with the message set in a migration-blocker (Our migration blocker mechanism always takes an Error* as the reason). It didn't seem right to make that change for the existing commands; so how would you like the existing MigrationInfo to change; a boolean to say yes/no, and an error/list of errors for the reason? Dave > -- > Eric Blake, Principal Software Engineer > Red Hat, Inc. +1-919-301-3226 > Virtualization: qemu.org | libvirt.org
* Eric Blake (eblake@redhat.com) wrote: > On 1/21/21 12:51 PM, Dr. David Alan Gilbert (git) wrote: > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > Provide a simple way to see if there's currently a migration blocker in > > operation: > > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic -M pc,usb=on -chardev null,id=n -device usb-serial,chardev=n > > > > (qemu) info migratable > > Error: State blocked by non-migratable device '0000:00:01.2/1/usb-serial' > > > > $ ./x86_64-softmmu/qemu-system-x86_64 -nographic > > > > (qemu) info migratable > > Migratable > > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > --- > > > > +++ b/qapi/migration.json > > @@ -366,6 +366,20 @@ > > ## > > { 'command': 'query-migrate', 'returns': 'MigrationInfo' } > > > > +## > > +# @query-migratable: > > +# Tests whether it will be possible to migrate the VM in the current state. > > +# > > +# Returns: nothing on success (i.e. if the VM is migratable) > > Do we really need a new command? Or can we get away with enhancing the > existing 'query-migrate' to add another bool field to 'MigrationInfo'? OK, new version of this coming up, glued into query-migrate. Dave > -- > Eric Blake, Principal Software Engineer > Red Hat, Inc. +1-919-301-3226 > Virtualization: qemu.org | libvirt.org
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 117ba25f91..c2d7ac2f11 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -541,6 +541,20 @@ SRST Show migration status. ERST + { + .name = "migratable", + .args_type = "", + .params = "", + .help = "tests if VM is migratable", + .cmd = hmp_info_migratable, + }, + +SRST + ''info migratable'' + Tests whether the VM is currently migratable. +ERST + + { .name = "migrate_capabilities", .args_type = "", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index ed2913fd18..0dd7941daf 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -25,6 +25,7 @@ void hmp_info_status(Monitor *mon, const QDict *qdict); void hmp_info_uuid(Monitor *mon, const QDict *qdict); void hmp_info_chardev(Monitor *mon, const QDict *qdict); void hmp_info_mice(Monitor *mon, const QDict *qdict); +void hmp_info_migratable(Monitor *mon, const QDict *qdict); void hmp_info_migrate(Monitor *mon, const QDict *qdict); void hmp_info_migrate_capabilities(Monitor *mon, const QDict *qdict); void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict); diff --git a/migration/migration.c b/migration/migration.c index 5e330cc6eb..8745a5b9f9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2234,6 +2234,11 @@ int64_t qmp_query_migrate_cache_size(Error **errp) return migrate_xbzrle_cache_size(); } +void qmp_query_migratable(Error **errp) +{ + migration_is_blocked(errp); +} + void qmp_migrate_set_speed(int64_t value, Error **errp) { MigrateSetParameters p = { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ef569035f8..a7f48b3512 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -216,6 +216,19 @@ static char *SocketAddress_to_str(SocketAddress *addr) } } +void hmp_info_migratable(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + /* It's migratable if this succeeds */ + qmp_query_migratable(&err); + if (err) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "Migratable\n"); +} + void hmp_info_migrate(Monitor *mon, const QDict *qdict) { MigrationInfo *info; diff --git a/qapi/migration.json b/qapi/migration.json index d1d9632c2a..07aee9907c 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -366,6 +366,20 @@ ## { 'command': 'query-migrate', 'returns': 'MigrationInfo' } +## +# @query-migratable: +# Tests whether it will be possible to migrate the VM in the current state. +# +# Returns: nothing on success (i.e. if the VM is migratable) +# +# Since: 6.0 +# Example: +# +# -> { "execute": "query-migratable" } +# <- { "return": {} } +## +{ 'command': 'query-migratable' } + ## # @MigrationCapability: #