From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [v6][PATCH 2/7] tools/libxc: introduce hypercall for xc_reserved_device_memory_map Date: Fri, 12 Sep 2014 10:43:37 +0800 Message-ID: <54125DD9.2010805@intel.com> References: <1410328190-6372-1-git-send-email-tiejun.chen@intel.com> <1410328190-6372-3-git-send-email-tiejun.chen@intel.com> <5411DA280200007800034036@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5411DA280200007800034036@mail.emea.novell.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: Jan Beulich Cc: kevin.tian@intel.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org On 2014/9/11 23:21, Jan Beulich wrote: >>>> On 10.09.14 at 07:49, wrote: >> + if ( errno == ENOBUFS ) >> + *max_entries = memmap.nr_entries; >> + >> + return rc ? -errno : memmap.nr_entries; >> +} > > Isn't libxc generally aiming at using POSIX style return values, i.e. -1 > one error with errno indicating the details? Furthermore you're even > inconsistent with yourself, as you return -1 in an earlier error path. > tools/libxc/xc_domain.c: int xc_get_machine_memory_map(xc_interface *xch, struct e820entry entries[], uint32_t max_entries) { int rc; struct xen_memory_map memmap = { .nr_entries = max_entries }; DECLARE_HYPERCALL_BOUNCE(entries, sizeof(struct e820entry) * max_entries, XC_HYPERCALL_BUFFER_BOUNCE_OUT); if ( !entries || xc_hypercall_bounce_pre(xch, entries) || max_entries <= 1) return -1; set_xen_guest_handle(memmap.buffer, entries); rc = do_memory_op(xch, XENMEM_machine_memory_map, &memmap, sizeof(memmap)); xc_hypercall_bounce_post(xch, entries); return rc ? rc : memmap.nr_entries; } Here I just change last line as follows: return rc ? -errno : memmap.nr_entries; Because if I don't return '-errno', how will the caller know the detailed error? rc = xc_reserved_device_memory_map(xch, xmrdm, &nr_entries); if ( rc < 0 ) { /* DRM doesn't exist. */ if ( rc == -ENOENT ) rc = 0; Or are you saying we should use errno ditectly, + + rc = xc_reserved_device_memory_map(xch, xmrdm, &nr_entries); + if (rc < 0 ) { + switch (errno) { + case ENOENT: /* RDM doesn't exist. */ Right? Thanks Tiejun