debuggers.hg

changeset 22549:ab785e37499c

add missing libxl__free_all() calls

In various libxl functions libxl__free_all() was missing before return

Signed-off-by: juergen.gross@ts.fujitsu.com
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
committer: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Juergen Gross <juergen.gross@ts.fujitsu.com>
date Thu Dec 09 14:50:56 2010 +0100 (2010-12-09)
parents f57026cd5d19
children fd4cbfbbd83e
files tools/libxl/libxl.c tools/libxl/libxl_dom.c tools/libxl/libxl_pci.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Mon Dec 13 17:59:45 2010 +0000
     1.2 +++ b/tools/libxl/libxl.c	Thu Dec 09 14:50:56 2010 +0100
     1.3 @@ -514,7 +514,10 @@ int libxl_domain_preserve(libxl_ctx *ctx
     1.4  
     1.5      xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/vm", dom_path), vm_path, strlen(vm_path));
     1.6      rc = libxl_domain_rename(ctx, domid, info->name, preserved_name, t);
     1.7 -    if (rc) return rc;
     1.8 +    if (rc) {
     1.9 +        libxl__free_all(&gc);
    1.10 +        return rc;
    1.11 +    }
    1.12  
    1.13      xs_write(ctx->xsh, t, libxl__sprintf(&gc, "%s/uuid", vm_path), uuid_string, strlen(uuid_string));
    1.14  
    1.15 @@ -756,17 +759,20 @@ int libxl_domain_shutdown(libxl_ctx *ctx
    1.16          ret = xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_ACPI_S_STATE, &acpi_s_state);
    1.17          if (ret<0) {
    1.18              LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting ACPI S-state");
    1.19 +            libxl__free_all(&gc);
    1.20              return ERROR_FAIL;
    1.21          }
    1.22          ret = xc_get_hvm_param(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
    1.23          if (ret<0) {
    1.24              LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "getting HVM callback IRQ");
    1.25 +            libxl__free_all(&gc);
    1.26              return ERROR_FAIL;
    1.27          }
    1.28          if (!pvdriver || acpi_s_state != 0) {
    1.29              ret = xc_domain_shutdown(ctx->xch, domid, req);
    1.30              if (ret<0) {
    1.31                  LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unpausing domain");
    1.32 +                libxl__free_all(&gc);
    1.33                  return ERROR_FAIL;
    1.34              }
    1.35         }
    1.36 @@ -3677,13 +3683,16 @@ int libxl_create_cpupool(libxl_ctx *ctx,
    1.37      char *uuid_string;
    1.38  
    1.39      uuid_string = libxl__uuid2string(&gc, *uuid);
    1.40 -    if (!uuid_string)
    1.41 +    if (!uuid_string) {
    1.42 +        libxl__free_all(&gc);
    1.43          return ERROR_NOMEM;
    1.44 +    }
    1.45  
    1.46      rc = xc_cpupool_create(ctx->xch, poolid, schedid);
    1.47      if (rc) {
    1.48          LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
    1.49             "Could not create cpupool");
    1.50 +        libxl__free_all(&gc);
    1.51          return ERROR_FAIL;
    1.52      }
    1.53  
    1.54 @@ -3694,6 +3703,7 @@ int libxl_create_cpupool(libxl_ctx *ctx,
    1.55                  LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
    1.56                      "Error moving cpu to cpupool");
    1.57                  libxl_destroy_cpupool(ctx, *poolid);
    1.58 +                libxl__free_all(&gc);
    1.59                  return ERROR_FAIL;
    1.60              }
    1.61          }
    1.62 @@ -3709,8 +3719,10 @@ int libxl_create_cpupool(libxl_ctx *ctx,
    1.63                          libxl__sprintf(&gc, "/local/pool/%d/name", *poolid),
    1.64                          "%s", name);
    1.65  
    1.66 -        if (xs_transaction_end(ctx->xsh, t, 0) || (errno != EAGAIN))
    1.67 +        if (xs_transaction_end(ctx->xsh, t, 0) || (errno != EAGAIN)) {
    1.68 +            libxl__free_all(&gc);
    1.69              return 0;
    1.70 +        }
    1.71      }
    1.72  }
    1.73  
    1.74 @@ -3723,8 +3735,10 @@ int libxl_destroy_cpupool(libxl_ctx *ctx
    1.75      libxl_cpumap cpumap;
    1.76  
    1.77      info = xc_cpupool_getinfo(ctx->xch, poolid);
    1.78 -    if (info == NULL)
    1.79 +    if (info == NULL) {
    1.80 +        libxl__free_all(&gc);
    1.81          return ERROR_NOMEM;
    1.82 +    }
    1.83  
    1.84      rc = ERROR_INVAL;
    1.85      if ((info->cpupool_id != poolid) || (info->n_dom))
    1.86 @@ -3768,6 +3782,7 @@ out1:
    1.87      libxl_cpumap_destroy(&cpumap);
    1.88  out:
    1.89      xc_cpupool_infofree(ctx->xch, info);
    1.90 +    libxl__free_all(&gc);
    1.91  
    1.92      return rc;
    1.93  }
    1.94 @@ -3809,6 +3824,7 @@ int libxl_cpupool_movedomain(libxl_ctx *
    1.95  
    1.96      dom_path = libxl__xs_get_dompath(&gc, domid);
    1.97      if (!dom_path) {
    1.98 +        libxl__free_all(&gc);
    1.99          return ERROR_FAIL;
   1.100      }
   1.101  
   1.102 @@ -3816,6 +3832,7 @@ int libxl_cpupool_movedomain(libxl_ctx *
   1.103      if (rc) {
   1.104          LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc,
   1.105              "Error moving domain to cpupool");
   1.106 +        libxl__free_all(&gc);
   1.107          return ERROR_FAIL;
   1.108      }
   1.109  
   1.110 @@ -3834,5 +3851,6 @@ int libxl_cpupool_movedomain(libxl_ctx *
   1.111              break;
   1.112      }
   1.113  
   1.114 +    libxl__free_all(&gc);
   1.115      return 0;
   1.116  }
     2.1 --- a/tools/libxl/libxl_dom.c	Mon Dec 13 17:59:45 2010 +0000
     2.2 +++ b/tools/libxl/libxl_dom.c	Thu Dec 09 14:50:56 2010 +0100
     2.3 @@ -121,8 +121,10 @@ int libxl__build_post(libxl_ctx *ctx, ui
     2.4      }
     2.5  
     2.6      dom_path = libxl__xs_get_dompath(&gc, domid);
     2.7 -    if (!dom_path)
     2.8 +    if (!dom_path) {
     2.9 +        libxl__free_all(&gc);
    2.10          return ERROR_FAIL;
    2.11 +    }
    2.12  
    2.13      vm_path = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/vm", dom_path), NULL);
    2.14  retry_transaction:
    2.15 @@ -469,6 +471,7 @@ int libxl__domain_save_device_model(libx
    2.16      if (stat(filename, &st) < 0)
    2.17      {
    2.18          LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to stat qemu save file\n");
    2.19 +        libxl__free_all(&gc);
    2.20          return ERROR_FAIL;
    2.21      }
    2.22  
    2.23 @@ -477,13 +480,17 @@ int libxl__domain_save_device_model(libx
    2.24  
    2.25      c = libxl_write_exactly(ctx, fd, QEMU_SIGNATURE, strlen(QEMU_SIGNATURE),
    2.26                              "saved-state file", "qemu signature");
    2.27 -    if (c)
    2.28 +    if (c) {
    2.29 +        libxl__free_all(&gc);
    2.30          return c;
    2.31 +    }
    2.32  
    2.33      c = libxl_write_exactly(ctx, fd, &qemu_state_len, sizeof(qemu_state_len),
    2.34                              "saved-state file", "saved-state length");
    2.35 -    if (c)
    2.36 +    if (c) {
    2.37 +        libxl__free_all(&gc);
    2.38          return c;
    2.39 +    }
    2.40  
    2.41      fd2 = open(filename, O_RDONLY);
    2.42      while ((c = read(fd2, buf, sizeof(buf))) != 0) {
     3.1 --- a/tools/libxl/libxl_pci.c	Mon Dec 13 17:59:45 2010 +0000
     3.2 +++ b/tools/libxl/libxl_pci.c	Thu Dec 09 14:50:56 2010 +0100
     3.3 @@ -525,8 +525,10 @@ int libxl_device_pci_list_assignable(lib
     3.4      *list = NULL;
     3.5  
     3.6      rc = get_all_assigned_devices(&gc, &assigned, &num_assigned);
     3.7 -    if ( rc )
     3.8 +    if ( rc ) {
     3.9 +        libxl__free_all(&gc);
    3.10          return rc;
    3.11 +    }
    3.12  
    3.13      dir = opendir(SYSFS_PCIBACK_DRIVER);
    3.14      if ( NULL == dir ) {