debuggers.hg

changeset 20843:517364d0823d

libxenlight: add some return values testing in stubdom

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 14 09:40:01 2010 +0000 (2010-01-14)
parents 13d4e78ede97
children 94442ca0423d
files tools/libxl/libxl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Wed Jan 13 08:33:34 2010 +0000
     1.2 +++ b/tools/libxl/libxl.c	Thu Jan 14 09:40:01 2010 +0000
     1.3 @@ -824,7 +824,7 @@ static int libxl_create_stubdom(struct l
     1.4                                  libxl_device_vkb *vkb,
     1.5                                  libxl_device_model_starting **starting_r)
     1.6  {
     1.7 -    int i, num_console = 1;
     1.8 +    int i, num_console = 1, ret;
     1.9      libxl_device_console *console;
    1.10      libxl_domain_create_info c_info;
    1.11      libxl_domain_build_info b_info;
    1.12 @@ -855,12 +855,18 @@ static int libxl_create_stubdom(struct l
    1.13      b_info.u.pv.features = "";
    1.14      b_info.hvm = 0;
    1.15  
    1.16 -    libxl_domain_make(ctx, &c_info, &domid);
    1.17 -    libxl_domain_build(ctx, &b_info, domid, &state);
    1.18 +    ret = libxl_domain_make(ctx, &c_info, &domid);
    1.19 +    if (ret) return ret;
    1.20 +    ret = libxl_domain_build(ctx, &b_info, domid, &state);
    1.21 +    if (ret) return ret;
    1.22  
    1.23      libxl_write_dmargs(ctx, domid, info->domid, args);
    1.24 -    libxl_xs_write(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/image/device-model-domid", libxl_xs_get_dompath(ctx, info->domid)), "%d", domid);
    1.25 -    libxl_xs_write(ctx, XBT_NULL, libxl_sprintf(ctx, "%s/target", libxl_xs_get_dompath(ctx, domid)), "%d", info->domid);
    1.26 +    libxl_xs_write(ctx, XBT_NULL,
    1.27 +                   libxl_sprintf(ctx, "%s/image/device-model-domid", libxl_xs_get_dompath(ctx, info->domid)),
    1.28 +                   "%d", domid);
    1.29 +    libxl_xs_write(ctx, XBT_NULL,
    1.30 +                   libxl_sprintf(ctx, "%s/target", libxl_xs_get_dompath(ctx, domid)),
    1.31 +                   "%d", info->domid);
    1.32      xc_domain_set_target(ctx->xch, domid, info->domid);
    1.33      xs_set_target(ctx->xsh, domid, info->domid);
    1.34  
    1.35 @@ -880,27 +886,36 @@ retry_transaction:
    1.36  
    1.37      for (i = 0; i < num_disks; i++) {
    1.38          disks[i].domid = domid;
    1.39 -        libxl_device_disk_add(ctx, domid, &disks[i]);
    1.40 +        ret = libxl_device_disk_add(ctx, domid, &disks[i]);
    1.41 +        if (ret) return ret;
    1.42      }
    1.43      for (i = 0; i < num_vifs; i++) {
    1.44          vifs[i].domid = domid;
    1.45 -        libxl_device_nic_add(ctx, domid, &vifs[i]);
    1.46 +        ret = libxl_device_nic_add(ctx, domid, &vifs[i]);
    1.47 +        if (ret) return ret;
    1.48      }
    1.49      vfb->domid = domid;
    1.50 -    libxl_device_vfb_add(ctx, domid, vfb);
    1.51 +    ret = libxl_device_vfb_add(ctx, domid, vfb);
    1.52 +    if (ret) return ret;
    1.53      vkb->domid = domid;
    1.54 -    libxl_device_vkb_add(ctx, domid, vkb);
    1.55 +    ret = libxl_device_vkb_add(ctx, domid, vkb);
    1.56 +    if (ret) return ret;
    1.57  
    1.58      if (info->serial)
    1.59          num_console++;
    1.60 +
    1.61      console = libxl_calloc(ctx, num_console, sizeof(libxl_device_console));
    1.62 +    if (!console)
    1.63 +        return ERROR_NOMEM;
    1.64 +
    1.65      for (i = 0; i < num_console; i++) {
    1.66          console[i].devid = i;
    1.67          console[i].constype = CONSTYPE_IOEMU;
    1.68          console[i].domid = domid;
    1.69          if (!i)
    1.70              console[i].build_state = &state;
    1.71 -        libxl_device_console_add(ctx, domid, &console[i]);
    1.72 +        ret = libxl_device_console_add(ctx, domid, &console[i]);
    1.73 +        if (ret) return ret;
    1.74      }
    1.75      if (libxl_create_xenpv_qemu(ctx, vfb, num_console, console, &dm_starting) < 0) {
    1.76          free(args);