From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v3 COLOPre 16/26] tools/libx{l, c}: add back channel to libxc Date: Tue, 30 Jun 2015 11:17:09 +0100 Message-ID: <1435659429.21469.72.camel@citrix.com> References: <1435213552-10556-1-git-send-email-yanghy@cn.fujitsu.com> <1435213552-10556-17-git-send-email-yanghy@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1435213552-10556-17-git-send-email-yanghy@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Yang Hongyang Cc: wei.liu2@citrix.com, wency@cn.fujitsu.com, andrew.cooper3@citrix.com, yunhong.jiang@intel.com, eddie.dong@intel.com, xen-devel@lists.xen.org, guijianfeng@cn.fujitsu.com, rshriram@cs.ubc.ca, Ian Jackson List-Id: xen-devel@lists.xenproject.org On Thu, 2015-06-25 at 14:25 +0800, Yang Hongyang wrote: > diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c > index 12cc57e..25817d6 100644 > --- a/tools/libxl/libxl_save_callout.c > +++ b/tools/libxl/libxl_save_callout.c > @@ -27,7 +27,7 @@ > */ > static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, > const char *mode_arg, > - int stream_fd, > + int stream_fd, int back_fd, > const int *preserve_fds, int num_preserve_fds, > const unsigned long *argnums, int num_argnums); > > @@ -70,8 +70,8 @@ void libxl__xc_domain_restore(libxl__egc *egc, libxl__domain_create_state *dcs, > dcs->shs.need_results = 1; > dcs->shs.toolstack_data_file = 0; > > - run_helper(egc, &dcs->shs, "--restore-domain", restore_fd, 0,0, > - argnums, ARRAY_SIZE(argnums)); > + run_helper(egc, &dcs->shs, "--restore-domain", restore_fd, dcs->send_fd, restore_fd comes from convenience aliases, it would be in keeping to do the same for send_fd too (and elsewhere) > @@ -174,6 +175,16 @@ static void run_helper(libxl__egc *egc, libxl__save_helper_state *shs, > libxl_fd_set_cloexec(CTX, stream_fd, 0); > *stream_fd_arg = GCSPRINTF("%d", stream_fd); > > + if (back_fd <= 2) { > + back_fd = dup(back_fd); > + if (back_fd < 0) { > + LOGE(ERROR,"dup migration back channel"); > + exit(-1); > + } > + } > + libxl_fd_set_cloexec(CTX, back_fd, 0); > + *back_fd_arg = GCSPRINTF("%d", back_fd); This is an exact duplicate of the stream_fd setup, I think you should make it a helper which takes a gc, an fd and a const char *what (=="stream" or "backchannel" for logging) and returns a string representing a safe (i.e. possibly dupd) version of the fd. Ian.