From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wen Congyang Subject: Re: [RFC Patch v4 7/9] correct xc_domain_save()'s return value Date: Mon, 22 Sep 2014 16:41:15 +0800 Message-ID: <541FE0AB.1050808@cn.fujitsu.com> References: <1411365561-29242-1-git-send-email-wency@cn.fujitsu.com> <1411365561-29242-8-git-send-email-wency@cn.fujitsu.com> <20140922073053.GA6584@aepfle.de> <541FD0F4.8080400@cn.fujitsu.com> <20140922074625.GA9788@aepfle.de> <541FD88B.5080209@cn.fujitsu.com> <20140922081334.GA16085@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140922081334.GA16085@aepfle.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Olaf Hering Cc: Ian Campbell , Ian Jackson , Jiang Yunhong , Dong Eddie , xen devel , Yang Hongyang , Lai Jiangshan List-Id: xen-devel@lists.xenproject.org On 09/22/2014 04:13 PM, Olaf Hering wrote: > On Mon, Sep 22, Wen Congyang wrote: > >> The callbacks may be implemented in libxl, which is another process. >> xc_domain_save() is a public API, and the caller may forget to set >> the errno... >> >> So we cannot assume that the callbacks has set the errno > > Then the caller is using xc_domain_save incorrectly. > Looks like there is no API documentation, other than the source code. What about correcting the errno before xc_domain_save() returns: diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index 6e14112..de8974a 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -2188,10 +2188,14 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter outbuf_free(&ob_pagebuf); errno = rc; + rc = !!errno; + if (errno == -1) + /* We cannot get the correct errno */ + errno = 0; exit: DPRINTF("Save exit of domid %u with errno=%d\n", dom, errno); - return !!errno; + return rc; } /* > > Olaf > . >