debuggers.hg

changeset 22890:29eaad8e388a

libxl: during domain destruction, do not complain if no devices dir to destroy

Previously calling libxl__devices_destroy on a half-constructed or
half-destroyed domain would sometimes complain along these lines:
libxl: error: libxl_device.c:327:libxl__devices_destroy /local/domain/29/device is empty
This is (a) not a reasonable thing to complain about and (b) not an
accurate description of all the things that that particular failure of
libxl__xs_directory might mean.

Change the code to check errno, so that if errno==ENOENT we silently
continue, not destroying any devices, and if errno!=ENOENT, properly
log the problem and fail.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Ian Jackson <Ian.Jackson@eu.citrix.com>
date Fri Jan 28 18:38:26 2011 +0000 (2011-01-28)
parents 5eaf9405ed51
children 88cf07fed7d2
files tools/libxl/libxl_device.c
line diff
     1.1 --- a/tools/libxl/libxl_device.c	Fri Jan 28 18:37:25 2011 +0000
     1.2 +++ b/tools/libxl/libxl_device.c	Fri Jan 28 18:38:26 2011 +0000
     1.3 @@ -324,8 +324,12 @@ int libxl__devices_destroy(libxl_ctx *ct
     1.4      path = libxl__sprintf(&gc, "/local/domain/%d/device", domid);
     1.5      l1 = libxl__xs_directory(&gc, XBT_NULL, path, &num1);
     1.6      if (!l1) {
     1.7 -        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "%s is empty", path);
     1.8 -        goto out;
     1.9 +        if (errno != ENOENT) {
    1.10 +            LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "unable to get xenstore"
    1.11 +                             " device listing %s", path);
    1.12 +            goto out;
    1.13 +        }
    1.14 +        num1 = 0;
    1.15      }
    1.16      for (i = 0; i < num1; i++) {
    1.17          if (!strcmp("vfs", l1[i]))