debuggers.hg

changeset 21183:c031244c190e

libxl: libxl_domain_restore: Put fd back to blocking mode

libxl_domain_restore calls, indirectly, xc_domain_restore. The
latter, when doing a live migration, sets the fd from blocking mode
(which it must be on entry, or things go wrong) to nonblocking mode
and leaves it this way. Arguably this is a bug in libxc, but to avoid
disrupting any callers we fix it in libxl.

So libxl_domain_restore now puts the fd back into blocking mode
before returning.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Apr 12 17:40:06 2010 +0100 (2010-04-12)
parents df34011884a3
children 5b8362505256
files tools/libxl/libxl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Mon Apr 12 17:39:29 2010 +0100
     1.2 +++ b/tools/libxl/libxl.c	Mon Apr 12 17:40:06 2010 +0100
     1.3 @@ -221,7 +221,7 @@ int libxl_domain_restore(struct libxl_ct
     1.4                           libxl_device_model_info *dm_info)
     1.5  {
     1.6      char **vments = NULL, **localents = NULL;
     1.7 -    int i, ret;
     1.8 +    int i, ret, esave, flags;
     1.9  
    1.10      ret = build_pre(ctx, domid, info, state);
    1.11      if (ret) goto out;
    1.12 @@ -259,6 +259,19 @@ int libxl_domain_restore(struct libxl_ct
    1.13      else
    1.14          dm_info->saved_state = NULL;
    1.15  out:
    1.16 +    esave = errno;
    1.17 +
    1.18 +    flags = fcntl(fd, F_GETFL);
    1.19 +    if (flags == -1) {
    1.20 +        XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to get flags on restore fd");
    1.21 +    } else {
    1.22 +        flags &= ~O_NONBLOCK;
    1.23 +        if (fcntl(fd, F_SETFL, flags) == -1)
    1.24 +            XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to put restore fd"
    1.25 +                         " back to blocking mode");
    1.26 +    }
    1.27 +
    1.28 +    errno = esave;
    1.29      return ret;
    1.30  }
    1.31