From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wen Congyang Subject: Re: [Patch v2 2/3] correct xc_domain_save()'s return value Date: Mon, 17 Nov 2014 09:26:02 +0800 Message-ID: <54694EAA.7080403@cn.fujitsu.com> References: <1412820314-323-1-git-send-email-wency@cn.fujitsu.com> <1412820314-323-3-git-send-email-wency@cn.fujitsu.com> <21606.6212.353346.560825@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21606.6212.353346.560825@mariner.uk.xensource.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: Ian Jackson Cc: Lai Jiangshan , Andrew Cooper , Jiang Yunhong , Dong Eddie , xen devel , Yang Hongyang , Ian Campbell List-Id: xen-devel@lists.xenproject.org On 11/14/2014 10:57 PM, Ian Jackson wrote: > Wen Congyang writes ("[Patch v2 2/3] correct xc_domain_save()'s return value"): >> If suspend_and_state() fails, the errno may be 0. But we assume >> that the errno is not 0. So remove assert(). > > Thanks for spotting this. > > I think this is going in the wrong direction. Perhaps we could > instead do something like the patch below ? Please let me know what > you think. > > If you think this is a better idea, please submit it as a proper patch > with a proper commit message. OK, I will do it. > > (Ideally we would fix the actual suspend hook in libxl, to always set > errno, but that's too invasive a set of changes to do now, I think.) libxl and helper program are two programs, and we should update the interface between libxl and the hepler program first. We can do it later. Thanks Wen Congyang > > Thanks, > Ian. > > Signed-off-by: Ian Jackson > > diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h > index 40bbac8..3ab9dd8 100644 > --- a/tools/libxc/include/xenguest.h > +++ b/tools/libxc/include/xenguest.h > @@ -35,7 +35,9 @@ > /* callbacks provided by xc_domain_save */ > struct save_callbacks { > /* Called after expiration of checkpoint interval, > - * to suspend the guest. > + * to suspend the guest. Returns 1 for success, or 0 for failure. > + * On failure it should ideally set errno. (If it leaves errno > + * as 0, EIO will be used instead.) > */ > int (*suspend)(void* data); > > diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c > index 254fdb3..444aac6 100644 > --- a/tools/libxc/xc_domain_save.c > +++ b/tools/libxc/xc_domain_save.c > @@ -361,9 +361,15 @@ static int suspend_and_state(int (*suspend)(void*), void* data, > xc_interface *xch, int io_fd, int dom, > xc_dominfo_t *info) > { > + errno = 0; > if ( !(*suspend)(data) ) > { > - ERROR("Suspend request failed"); > + if (!errno) { > + errno = EIO; > + ERROR("Suspend request failed (without errno, using EINVAL)"); > + } else { > + ERROR("Suspend request failed"); > + } > return -1; > } > > . >