migration: Allow postcopy_ram_supported_by_host() to report err
PATCH v3 1/1 migration: Allow postcopy_ram_supported_by_host() to report err
Instead of print it to STDERR, bring the error upwards so that it can be reported via QMP responses.
E.g.:
{ "execute": "migrate-set-capabilities" ,
"arguments": { "capabilities":
[ { "capability": "postcopy-ram", "state": true } ] } }
{ "error":
{ "class": "GenericError",
"desc": "Postcopy is not supported: Host backend files need to be TMPFS or HUGETLBFS only" } }
--- migration/options.c | 8 ++---- migration/postcopy-ram.c | 59 ++++++++++++++++++++++------------------ migration/postcopy-ram.h | 3 +- migration/savevm.c | 3 +- 4 files changed, 39 insertions(+), 34 deletions(-)
migration/options.c +3 -5
@@ -285,6 +285,7 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp) {MigrationIncomingState *mis =migration_incoming_get_current (); +ERRP_GUARD ();#ifndef CONFIG_LIVE_BLOCK_MIGRATION if (new_caps[MIGRATION_CAPABILITY_BLOCK ]) { error_setg(errp, "QEMU compiled without old-style (blk/-b, inc/-i) "
@@ -310,11 +311,8 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps, Error **errp)*/ if (!old_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM ] &&runstate_check (RUN_STATE_INMIGRATE ) && - !postcopy_ram_supported_by_host (mis)) { -/* postcopy_ram_supported_by_host will have emitted a more -* detailed message -*/ -error_setg (errp,"Postcopy is not supported" ); + !postcopy_ram_supported_by_host (mis, errp)) { +error_prepend (errp,"Postcopy is not supported: " );return false; }
migration/postcopy-ram.c +32 -27
181 lines not on this page · raw message
migration/postcopy-ram.h +2 -1
@@ -14,7 +14,8 @@#define QEMU_POSTCOPY_RAM_H /* Return true if the host supports everything we need to do postcopy-ram */ -bool postcopy_ram_supported_by_host (MigrationIncomingState *mis); +bool postcopy_ram_supported_by_host (MigrationIncomingState *mis, +Error **errp);/* * Make all of RAM sensitive to accesses to areas that haven't yet been written
migration/savevm.c +2 -1
@@ -1753,7 +1753,8 @@ static int loadvm_postcopy_handle_advise(MigrationIncomingState *mis,return -EINVAL ; } -if (!postcopy_ram_supported_by_host (mis)) { +if (!postcopy_ram_supported_by_host (mis, &local_err)) { +error_report_err (local_err);postcopy_state_set (POSTCOPY_INCOMING_NONE );return -1 ; }
Signature · 1 line
2.39.1
Quoted 9 lines · Peter Xu
Instead of print it to STDERR, bring the error upwards so that it can be reported via QMP responses.
E.g.:
{ "execute": "migrate-set-capabilities" ,
"arguments": { "capabilities":
[ { "capability": "postcopy-ram", "state": true } ] } }
Quoted 6 lines
{ "error":
{ "class": "GenericError",
"desc": "Postcopy is not supported: Host backend files need to be TMPFS or HUGETLBFS only" } }Signed-off-by Peter Xu <[email protected]>
queued.