Skip to contentSkip to conversation

migration: Allow postcopy_ram_supported_by_host() to report err

PATCH In review Peter Xu 2 participants 2 messages Apr 26, 2023

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

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
index 8e8753d9be..4026b5e126 100644
@@ -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
index b4867a32d5..442ab89752 100644
@@ -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
index 9671211339..211eff3a8b 100644
@@ -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
Reviewed-by on v3 1/1
#1 lore raw
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" } }

queued.