[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Fix handling the return value of qemuMonitorSetBalloon



Hi,

The current code doesn't correctly handle the positive return value
of qemuMonitorSetBalloon, i.e., the success case. The return value is
directly passed to the return of qemudDomainSetMemory which treats
a positive value as a failure.

This patch fixes the defect.

Thanks,
  ozaki-r

>From f94b4c920ea30ae4a7f55fda343b4fff3bba040f Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki ryota gmail com>
Date: Mon, 5 Oct 2009 03:14:58 +0900
Subject: [PATCH] Fix handling the return value of qemuMonitorSetBalloon

* src/qemu/qemu_driver.c: The positive return value of
  qemuMonitorSetBalloon should be handled as a success
---
 src/qemu/qemu_driver.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 95e672b..8cf9002 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3020,17 +3020,20 @@ static int qemudDomainSetMemory(virDomainPtr
dom, unsigned long newmem) {
     }

     if (virDomainIsActive(vm)) {
-        ret = qemuMonitorSetBalloon(vm, newmem);
-        /* Turn lack of balloon support into a fatal error */
-        if (ret == 0) {
+        int r = qemuMonitorSetBalloon(vm, newmem);
+        if (r < 0)
+            goto cleanup;
+
+        /* Lack of balloon support is a fatal error */
+        if (r == 0) {
             qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
                              "%s", _("cannot set memory of an active domain"));
-            ret = -1;
+            goto cleanup;
         }
     } else {
         vm->def->memory = newmem;
-        ret = 0;
     }
+    ret = 0;

 cleanup:
     if (vm)
-- 
1.6.5.rc2

Attachment: 0001-Fix-handling-the-return-value-of-qemuMonitorSetBallo.patch
Description: Binary data


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]