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

Ryota Ozaki ozaki.ryota at gmail.com
Mon Oct 5 00:23:34 UTC 2009


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-handling-the-return-value-of-qemuMonitorSetBallo.patch
Type: application/octet-stream
Size: 1383 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20091005/c88a2b2d/attachment-0001.obj>


More information about the libvir-list mailing list