Patchwork [06/22] savevm: load_vmstate(): Improve error check

login
register
mail settings
Submitter Luiz Capitulino
Date April 20, 2010, 9:09 p.m.
Message ID <1271797792-24571-7-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/50581/
State New
Headers show

Comments

Luiz Capitulino - April 20, 2010, 9:09 p.m.
We should fail if something goes wrong in the call to
bdrv_snapshot_find().

Currently, we only fail if 'sn.vm_state_size' is not what
we expect it to be.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 savevm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/savevm.c b/savevm.c
index 5024829..3ccb246 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1800,8 +1800,11 @@  int load_vmstate(const char *name)
 
     /* Don't even try to load empty VM states */
     ret = bdrv_snapshot_find(bs, &sn, name);
-    if ((ret >= 0) && (sn.vm_state_size == 0))
+    if (ret < 0) {
+        return ret;
+    } else if (sn.vm_state_size == 0) {
         return -EINVAL;
+    }
 
     /* restore the VM state */
     f = qemu_fopen_bdrv(bs, 0);