From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH RFC 03/14] libxc: Fix xc_domain_get_tsc_info returning -Exx instead of -1. Date: Mon, 16 Mar 2015 14:23:22 +0000 Message-ID: <1426515802.18247.60.camel@citrix.com> References: <1426275083-8454-1-git-send-email-konrad.wilk@oracle.com> <1426275083-8454-4-git-send-email-konrad.wilk@oracle.com> <20150313194032.GA9130@l.oracle.com> <1426319739.28029.49.camel@citrix.com> <20150316141110.GB8518@l.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YXVvT-0002aJ-D5 for xen-devel@lists.xenproject.org; Mon, 16 Mar 2015 14:23:27 +0000 In-Reply-To: <20150316141110.GB8518@l.oracle.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: Konrad Rzeszutek Wilk Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com, wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, 2015-03-16 at 10:11 -0400, Konrad Rzeszutek Wilk wrote: > static void hypercall_buffer_cache_lock(xc_interface *xch) > { > + int saved_errno; > if ( xch->flags & XC_OPENFLAG_NON_REENTRANT ) > return; > + saved_errno = errno; You can do the init on declaration. > diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c > index a19e4b6..15d772b 100644 > --- a/tools/libxc/xc_linux_osdep.c > +++ b/tools/libxc/xc_linux_osdep.c > @@ -122,10 +122,13 @@ out: > > static void linux_privcmd_free_hypercall_buffer(xc_interface *xch, xc_osdep_handle h, void *ptr, int npages) > { > + int saved_errno = errno; > /* Recover the VMA flags. Maybe it's not necessary */ > madvise(ptr, npages * XC_PAGE_SIZE, MADV_DOFORK); > > munmap(ptr, npages * XC_PAGE_SIZE); > + /* We MUST propagate the hypercall errno, not unmap calls. */ Hrm, in general you would want to propagate failure here if the mmap had succeeded, otherwise you want the mmap failure. Which would involve pushing the saving into the callers. But since this function is (for better or worse) void (mainly because it may trigger out of band due to the cache) I think you are right to preserve the errno as you've done. > + errno = saved_errno; > } > > static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, privcmd_hypercall_t *hypercall) > > > > > > Ian. > >