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

Daniel P. Berrange berrange at redhat.com
Mon Oct 5 12:57:55 UTC 2009


On Mon, Oct 05, 2009 at 09:23:34AM +0900, Ryota Ozaki wrote:
> 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)


ACK


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list