From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 04/11] libxl: libxl_domain_restore: Put fd back to blocking mode Date: Thu, 25 Mar 2010 19:04:07 +0000 Message-ID: <1269543854-7780-5-git-send-email-ian.jackson@eu.citrix.com> References: <1269543854-7780-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1269543854-7780-1-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Ian Jackson , Ian Jackson List-Id: xen-devel@lists.xenproject.org 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 --- tools/libxl/libxl.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 0b1b6db..308273d 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -221,7 +221,7 @@ int libxl_domain_restore(struct libxl_ctx *ctx, libxl_domain_build_info *info, libxl_device_model_info *dm_info) { char **vments = NULL, **localents = NULL; - int i, ret; + int i, ret, esave, flags; ret = build_pre(ctx, domid, info, state); if (ret) goto out; @@ -259,6 +259,19 @@ int libxl_domain_restore(struct libxl_ctx *ctx, libxl_domain_build_info *info, else dm_info->saved_state = NULL; out: + esave = errno; + + flags = fcntl(fd, F_GETFL); + if (flags == -1) { + XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to get flags on restore fd"); + } else { + flags &= ~O_NONBLOCK; + if (fcntl(fd, F_SETFL, flags) == -1) + XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "unable to put restore fd" + " back to blocking mode"); + } + + errno = esave; return ret; } -- 1.5.6.5