Xen-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: xen-devel@lists.xenproject.org, ian.jackson@eu.citrix.com,
	wei.liu2@citrix.com, stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH 12/14] libxl: Check xc_sharing_* for proper return values.
Date: Wed, 18 Mar 2015 14:03:29 -0400	[thread overview]
Message-ID: <20150318180329.GC25199@l.oracle.com> (raw)
In-Reply-To: <1426696600.14291.81.camel@citrix.com>

On Wed, Mar 18, 2015 at 04:36:40PM +0000, Ian Campbell wrote:
> On Mon, 2015-03-16 at 11:39 -0400, Konrad Rzeszutek Wilk wrote:
> > If there is a negative return value - check for that and
> > also use errno for the proper error value.
> 
> Was xc_sharing_freed_pages fixed earlier in the series (which is
> strictly speaking a bisection hazard, but nevermind) or was the existing
> check for l == -E... just buggy?

The existing check for ENOSYS was buggy.
> 
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> > ---
> >  tools/libxl/libxl.c                  |  4 ++--
> >  tools/tests/mem-sharing/memshrtool.c | 12 ++++++++++--
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> > 
> > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> > index 94b4d59..99a99e9 100644
> > --- a/tools/libxl/libxl.c
> > +++ b/tools/libxl/libxl.c
> > @@ -5024,7 +5024,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
> >      physinfo->scrub_pages = xcphysinfo.scrub_pages;
> >      physinfo->outstanding_pages = xcphysinfo.outstanding_pages;
> >      l = xc_sharing_freed_pages(ctx->xch);
> > -    if (l == -ENOSYS) {
> > +    if (l < 0 && errno == ENOSYS) {
> >          l = 0;
> >      } else if (l < 0) {
> >          LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
> > @@ -5033,7 +5033,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
> >      }
> >      physinfo->sharing_freed_pages = l;
> >      l = xc_sharing_used_frames(ctx->xch);
> > -    if (l == -ENOSYS) {
> > +    if (l < 0 && errno == ENOSYS) {
> >          l = 0;
> >      } else if (l < 0) {
> >          LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, l,
> > diff --git a/tools/tests/mem-sharing/memshrtool.c b/tools/tests/mem-sharing/memshrtool.c
> > index db44294..d1dd8a2 100644
> > --- a/tools/tests/mem-sharing/memshrtool.c
> > +++ b/tools/tests/mem-sharing/memshrtool.c
> > @@ -55,11 +55,19 @@ int main(int argc, const char** argv)
> >  
> >      if( !strcasecmp(cmd, "info") )
> >      {
> > +        long rc;
> >          if( argc != 2 )
> >              return usage(argv[0]);
> >  
> > -        printf("used = %ld\n", xc_sharing_used_frames(xch));
> > -        printf("freed = %ld\n", xc_sharing_freed_pages(xch));
> > +        rc = xc_sharing_freed_pages(xch);
> > +        if ( rc < 0 )
> > +            return errno;
> 
> Just return 1 please.
> 
> > +
> > +        printf("used = %ld\n", rc);
> > +        rc = xc_sharing_used_frames(xch);
> > +        if ( rc < 0 )
> > +            return errno;
> 
> Likewise.
> 
> > +        printf("freed = %ld\n", rc);
> >      }
> >      else if( !strcasecmp(cmd, "enable") )
> >      {
> 
> 

  reply	other threads:[~2015-03-18 18:03 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 15:39 [PATCH v1] Fix libxc return -E misusage Konrad Rzeszutek Wilk
2015-03-16 15:39 ` [PATCH 01/14] libxc: Replaces tabs with spaces in xc_cpupool_freeinfo Konrad Rzeszutek Wilk
2015-03-18 16:13   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 02/14] libxl: Propagate errno from hypercall instead of anything else Konrad Rzeszutek Wilk
2015-03-18 16:17   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 03/14] libxc: xc_core_arch_memory_map_get populate errno Konrad Rzeszutek Wilk
2015-03-18 16:18   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 04/14] libxc: Fix xc_domain_get_tsc_info to return -1 instead of -Exx Konrad Rzeszutek Wilk
2015-03-18 16:20   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 05/14] libxl: xc_physdev_map return -1 and populate errno Konrad Rzeszutek Wilk
2015-03-18 16:21   ` Ian Campbell
2015-03-18 16:29     ` Konrad Rzeszutek Wilk
2015-03-16 15:39 ` [PATCH 06/14] libxl: Return negative value and propagate errno for xc_offline_page API Konrad Rzeszutek Wilk
2015-03-18 16:22   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 07/14] libxl: Fix xc_pm API calls to return negative error and stash error in errno Konrad Rzeszutek Wilk
2015-03-18 16:23   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 08/14] libxl: Fix xc_tmem_control to return proper error Konrad Rzeszutek Wilk
2015-03-18 16:26   ` Ian Campbell
2015-03-18 17:37     ` Konrad Rzeszutek Wilk
2015-03-19 10:26       ` Ian Campbell
2015-03-16 15:39 ` [PATCH 09/14] libxl: Check xc_domain_maximum_gpfn for negative return values Konrad Rzeszutek Wilk
2015-03-18 16:30   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 10/14] libxl: Check xc_maximum_ram_page " Konrad Rzeszutek Wilk
2015-03-18 16:32   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 11/14] libxl: If xc_domain_add_to_physmap fails, include errno value Konrad Rzeszutek Wilk
2015-03-18 16:34   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 12/14] libxl: Check xc_sharing_* for proper return values Konrad Rzeszutek Wilk
2015-03-18 16:36   ` Ian Campbell
2015-03-18 18:03     ` Konrad Rzeszutek Wilk [this message]
2015-03-16 15:39 ` [PATCH 13/14] libxl: Don't assign return value to errno for E820 get/set xc_ calls Konrad Rzeszutek Wilk
2015-03-18 16:37   ` Ian Campbell
2015-03-16 15:39 ` [PATCH 14/14] libxl: Fix do_memory_op to return negative value on errors Konrad Rzeszutek Wilk
2015-03-18 16:39   ` Ian Campbell
2015-03-18 16:43 ` [PATCH v1] Fix libxc return -E misusage Ian Campbell
2015-03-18 18:19   ` Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150318180329.GC25199@l.oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox