Patchwork [3/5] Don't ignore load_state() error return values.

login
register
mail settings
Submitter Juan Quintela
Date Aug. 18, 2009, 1:34 p.m.
Message ID <362c8a9927d32b023a3a18394003d095c9fe0095.1250601335.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/31558/
State Superseded
Headers show

Comments

Juan Quintela - Aug. 18, 2009, 1:34 p.m.
An error value here means that some device was not able to load it state.  There is no hope at this point.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 savevm.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

Patch

diff --git a/savevm.c b/savevm.c
index 7779c0e..55a1b50 100644
--- a/savevm.c
+++ b/savevm.c
@@ -955,7 +955,13 @@  int qemu_loadvm_state(QEMUFile *f)
             le->next = first_le;
             first_le = le;

-            le->se->load_state(f, le->se->opaque, le->version_id);
+            ret = le->se->load_state(f, le->se->opaque, le->version_id);
+            if (ret < 0) {
+                fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n",
+                        instance_id, idstr);
+                ret = -EINVAL;
+                goto out;
+            }
             break;
         case QEMU_VM_SECTION_PART:
         case QEMU_VM_SECTION_END:
@@ -968,7 +974,13 @@  int qemu_loadvm_state(QEMUFile *f)
                 goto out;
             }

-            le->se->load_state(f, le->se->opaque, le->version_id);
+            ret = le->se->load_state(f, le->se->opaque, le->version_id);
+            if (ret != 0) {
+                fprintf(stderr, "qemu: warning: error while loading state section '%d'\n",
+                        section_id);
+                ret = -EINVAL;
+                goto out;
+            }
             break;
         default:
             fprintf(stderr, "Unknown savevm section type %d\n", section_type);