Skip to contentSkip to conversation

savevm: set right return value for qemu_file_rate_limit

PATCH In review Lei Li 1 participant 3 messages Jul 21, 2013 – Aug 5, 2013

lore
Share & tools
lore

Lei Li

author
#0 lore raw

PATCH 1/1 savevm: set right return value for qemu_file_rate_limit

Commit 1964a397063967acc5ce71a2a24ed26e74824ee1 refactors rate limiting to QEMUFile, but set the return value for qemu_file_rate_limit to 1 in the case of qemu_file_get_error. It is wrong and should be negative compared to the original function buffered_rate_limit and the current logic in ram_save_iterate. As qemu_file_rate_limit is called manually to determine if it has to exit, add the defination of the meaning of the return values as well.

---
 savevm.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
savevm.c +12 -2
index e0491e7..f406790 100644
@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)
     return f->pos;
 }
 
+/*
+ * The meaning of the return values is:
+ *   0: We can continue sending
+ *   1: Time to stop
+ *   negative: There has been an error
+ */
+
 int qemu_file_rate_limit(QEMUFile *f)
 {
-    if (qemu_file_get_error(f)) {
-        return 1;
+    int ret;
+
+    ret = qemu_file_get_error(f);
+    if (ret) {
+        return ret;
     }
     if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) {
         return 1;
Signature · 1 line
1.7.7.6
author
#1 lore raw

In the logic of ram_save_iterate(), it checks the ret of qemu_file_rate_limit(f) by ret < 0 if there has been an error. But now it will never return negative value because qemu_file_rate_limit() return 1 if qemu_file_get_error().

Also the original implementation of qemu_file_rate_limit() as function buffered_rate_limit() did return negative for this situation.

Quoted 41 lines · Lei Li

Commit 1964a397063967acc5ce71a2a24ed26e74824ee1 refactors rate limiting to QEMUFile, but set the return value for qemu_file_rate_limit to 1 in the case of qemu_file_get_error. It is wrong and should be negative compared to the original function buffered_rate_limit and the current logic in ram_save_iterate. As qemu_file_rate_limit is called manually to determine if it has to exit, add the defination of the meaning of the return values as well.

---
  savevm.c |   14 ++++++++++++--
  1 files changed, 12 insertions(+), 2 deletions(-)
savevm.c +12 -2
index e0491e7..f406790 100644
@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)
      return f->pos;
  }
 
+/*
+ * The meaning of the return values is:
+ *   0: We can continue sending
+ *   1: Time to stop
+ *   negative: There has been an error
+ */
+
  int qemu_file_rate_limit(QEMUFile *f)
  {
-    if (qemu_file_get_error(f)) {
-        return 1;
+    int ret;
+
+    ret = qemu_file_get_error(f);
+    if (ret) {
+        return ret;
      }
      if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) {
          return 1;
Signature · 1 line
Lei
author
#2 lore raw

PING? any comments?

Quoted 52 lines · Lei Li

In the logic of ram_save_iterate(), it checks the ret of qemu_file_rate_limit(f) by ret < 0 if there has been an error. But now it will never return negative value because qemu_file_rate_limit() return 1 if qemu_file_get_error().

Also the original implementation of qemu_file_rate_limit() as function buffered_rate_limit() did return negative for this situation.

Quoted 41 lines · Lei Li

Commit 1964a397063967acc5ce71a2a24ed26e74824ee1 refactors rate limiting to QEMUFile, but set the return value for qemu_file_rate_limit to 1 in the case of qemu_file_get_error. It is wrong and should be negative compared to the original function buffered_rate_limit and the current logic in ram_save_iterate. As qemu_file_rate_limit is called manually to determine if it has to exit, add the defination of the meaning of the return values as well.

---
  savevm.c |   14 ++++++++++++--
  1 files changed, 12 insertions(+), 2 deletions(-)
savevm.c +12 -2
index e0491e7..f406790 100644
@@ -904,10 +904,20 @@ int64_t qemu_ftell(QEMUFile *f)
      return f->pos;
  }
 
+/*
+ * The meaning of the return values is:
+ *   0: We can continue sending
+ *   1: Time to stop
+ *   negative: There has been an error
+ */
+
  int qemu_file_rate_limit(QEMUFile *f)
  {
-    if (qemu_file_get_error(f)) {
-        return 1;
+    int ret;
+
+    ret = qemu_file_get_error(f);
+    if (ret) {
+        return ret;
      }
      if (f->xfer_limit > 0 && f->bytes_xfer > f->xfer_limit) {
          return 1;
Signature · 1 line
Lei