Skip to contentSkip to conversation

savevm: add comments for qemu_file_get_error()

PATCH Superseded Lei Li 2 participants 5 messages Aug 23, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lei Li

author
#0 lore raw

PATCH 1/3 savevm: add comments for qemu_file_get_error()

Add comments for qemu_file_get_error(), as its return value is not very clear.

---
 savevm.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
savevm.c +7 -0
index 03fc4d9..95a11f9 100644
@@ -566,6 +566,13 @@ QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops)
     return f;
 }
 
+/*
+ * Get last error for stream f
+ *
+ * Return negative error value if there has been an error on previous
+ * operations, return 0 if no error happened.
+ *
+ */
 int qemu_file_get_error(QEMUFile *f)
 {
     return f->last_error;
Signature · 1 line
1.7.7.6
author
#1 lore raw

PATCH 2/3 savevm: wrong error set by ram_control_load_hook()

---
 savevm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
savevm.c +1 -1
index 95a11f9..fb17a6f 100644
@@ -649,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
 
 void ram_control_load_hook(QEMUFile *f, uint64_t flags)
 {
-    int ret = 0;
+    int ret = EINVAL;
 
     if (f->ops->hook_ram_load) {
         ret = f->ops->hook_ram_load(f, f->opaque, flags);
Signature · 1 line
1.7.7.6
#2 lore raw

Re: [Qemu-devel] [PATCH 2/3] savevm: wrong error set by ram_control_load_hook()

Il 23/08/2013 12:03, Lei Li ha scritto:

Quoted 10 lines
---
 savevm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
savevm.c +0 -0
index 95a11f9..fb17a6f 100644

savevm.c void ram_control_after_iterate(QEMUFile *f, uint64_t flags) · line 652

Quoted 5 lines
savevm.c +1 -1
@@ -649,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
 
 void ram_control_load_hook(QEMUFile *f, uint64_t flags)
 {
-    int ret = 0;
+    int ret = EINVAL;

This should be "-EINVAL".

Paolo

Quoted 3 lines
savevm.c +0 -0
     if (f->ops->hook_ram_load) {
         ret = f->ops->hook_ram_load(f, f->opaque, flags);
 
author
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] savevm: wrong error set by ram_control_load_hook()

Quoted 12 lines · Paolo Bonzini

Il 23/08/2013 12:03, Lei Li ha scritto:

Quoted 11 lines
---
  savevm.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
savevm.c +0 -0
index 95a11f9..fb17a6f 100644
@@ -649,7 +649,7 @@ void ram_control_after_iterate(QEMUFile *f, uint64_t flags)
 
Quoted 5 lines

savevm.c void ram_control_after_iterate(QEMUFile *f, uint64_t flags) · line 652

Quoted 4 lines
savevm.c +1 -1
  void ram_control_load_hook(QEMUFile *f, uint64_t flags)
  {
-    int ret = 0;
+    int ret = EINVAL;

This should be "-EINVAL".

Ooops! Sorry for the rush as I was off line to go home... :-[ Resend soon.

Quoted 7 lines

Paolo

Quoted 3 lines
savevm.c +0 -0
      if (f->ops->hook_ram_load) {
          ret = f->ops->hook_ram_load(f, f->opaque, flags);
 
Signature · 1 line
Lei
author
#4 lore raw

PATCH 3/3 arch_init: right return for ram_save_iterate

In reply to Lei Li
---
 arch_init.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
arch_init.c +1 -6
index 94d45e1..a34437c 100644
@@ -709,16 +709,11 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
      */
     ram_control_after_iterate(f, RAM_CONTROL_ROUND);
 
-    if (ret < 0) {
-        bytes_transferred += total_sent;
-        return ret;
-    }
-
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
     total_sent += 8;
     bytes_transferred += total_sent;
 
-    return total_sent;
+    return qemu_file_get_error(f);
 }
 
 static int ram_save_complete(QEMUFile *f, void *opaque)
Signature · 1 line
1.7.7.6