All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn.
@ 2015-03-30 14:46 Konrad Rzeszutek Wilk
  2015-03-30 14:52 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Konrad Rzeszutek Wilk @ 2015-03-30 14:46 UTC (permalink / raw)
  To: ian.campbell, ian.jackson, xen-devel, andrew.cooper3
  Cc: Konrad Rzeszutek Wilk

The commit a8f8a590e02d2d2b717257c0bd9a8b396103bdf4
"libxc: Check xc_domain_maximum_gpfn for negative return values"
introduced an regression in tools outside libxc (migrate v2)
which wanted the unfiltered GPFN value. Said commit added
a wrapper which added +1 if there were no errors.

To make it work pre-commit a8f8a59 we add an xc_domain_nr_gpfns
which will add +1 if there are no errors (and change all in-tree
callers to use it). The xc_domain_maximum_gpfn will return the
unfiltered GPFN value.

Suggested-by: Ian Campbell <ian.campbell@citrix.com>
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 tools/libxc/include/xenctrl.h |  2 ++
 tools/libxc/xc_core_arm.c     |  2 +-
 tools/libxc/xc_core_x86.c     |  6 +++---
 tools/libxc/xc_domain.c       | 12 +++++++++++-
 tools/libxc/xc_domain_save.c  |  2 +-
 5 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 4e9537e..552ace8 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1317,6 +1317,8 @@ int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
 
 int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
 
+int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
+
 int xc_domain_increase_reservation(xc_interface *xch,
                                    uint32_t domid,
                                    unsigned long nr_extents,
diff --git a/tools/libxc/xc_core_arm.c b/tools/libxc/xc_core_arm.c
index c3f5868..57d4715 100644
--- a/tools/libxc/xc_core_arm.c
+++ b/tools/libxc/xc_core_arm.c
@@ -45,7 +45,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
     xen_pfn_t p2m_size = 0;
     xc_core_memory_map_t *map;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
         return -1;
 
     map = malloc(sizeof(*map));
diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c
index 4552e43..93ebcbb 100644
--- a/tools/libxc/xc_core_x86.c
+++ b/tools/libxc/xc_core_x86.c
@@ -50,7 +50,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
     xen_pfn_t p2m_size = 0;
     xc_core_memory_map_t *map;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
         return -1;
 
     map = malloc(sizeof(*map));
@@ -85,7 +85,7 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc
     int err;
     int i;
 
-    if ( xc_domain_maximum_gpfn(xch, info->domid, &dinfo->p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 )
     {
         ERROR("Could not get maximum GPFN!");
         goto out;
@@ -212,7 +212,7 @@ int
 xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
                               xen_pfn_t *gpfn)
 {
-    return xc_domain_maximum_gpfn(xch, domid, gpfn);
+    return xc_domain_nr_gpfns(xch, domid, gpfn);
 }
 
 /*
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index da88e08..dc62eff 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -795,12 +795,22 @@ int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
 
     if ( rc >= 0 )
     {
-        *gpfns = rc + 1;
+        *gpfns = rc;
         rc = 0;
     }
     return rc;
 }
 
+int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
+{
+    int rc = xc_domain_maximum_gpfn(xch, domid, gpfns);
+
+    if ( rc >= 0 )
+        *gpfns += 1;
+
+    return rc;
+}
+
 int xc_domain_increase_reservation(xc_interface *xch,
                                    uint32_t domid,
                                    unsigned long nr_extents,
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
index b611c07..cef6995 100644
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -939,7 +939,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
     }
 
     /* Get the size of the P2M table */
-    if ( xc_domain_maximum_gpfn(xch, dom, &dinfo->p2m_size) < 0 )
+    if ( xc_domain_nr_gpfns(xch, dom, &dinfo->p2m_size) < 0 )
     {
         ERROR("Could not get maximum GPFN!");
         goto out;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn.
  2015-03-30 14:46 [PATCH] libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn Konrad Rzeszutek Wilk
@ 2015-03-30 14:52 ` Andrew Cooper
  2015-03-30 16:27   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2015-03-30 14:52 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk, ian.campbell, ian.jackson, xen-devel

On 30/03/15 15:46, Konrad Rzeszutek Wilk wrote:
> The commit a8f8a590e02d2d2b717257c0bd9a8b396103bdf4
> "libxc: Check xc_domain_maximum_gpfn for negative return values"
> introduced an regression in tools outside libxc (migrate v2)
> which wanted the unfiltered GPFN value. Said commit added
> a wrapper which added +1 if there were no errors.
>
> To make it work pre-commit a8f8a59 we add an xc_domain_nr_gpfns
> which will add +1 if there are no errors (and change all in-tree
> callers to use it). The xc_domain_maximum_gpfn will return the
> unfiltered GPFN value.
>
> Suggested-by: Ian Campbell <ian.campbell@citrix.com>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
>  tools/libxc/include/xenctrl.h |  2 ++
>  tools/libxc/xc_core_arm.c     |  2 +-
>  tools/libxc/xc_core_x86.c     |  6 +++---
>  tools/libxc/xc_domain.c       | 12 +++++++++++-
>  tools/libxc/xc_domain_save.c  |  2 +-
>  5 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 4e9537e..552ace8 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -1317,6 +1317,8 @@ int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
>  
>  int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
>  
> +int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
> +
>  int xc_domain_increase_reservation(xc_interface *xch,
>                                     uint32_t domid,
>                                     unsigned long nr_extents,
> diff --git a/tools/libxc/xc_core_arm.c b/tools/libxc/xc_core_arm.c
> index c3f5868..57d4715 100644
> --- a/tools/libxc/xc_core_arm.c
> +++ b/tools/libxc/xc_core_arm.c
> @@ -45,7 +45,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
>      xen_pfn_t p2m_size = 0;
>      xc_core_memory_map_t *map;
>  
> -    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
> +    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
>          return -1;
>  
>      map = malloc(sizeof(*map));
> diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c
> index 4552e43..93ebcbb 100644
> --- a/tools/libxc/xc_core_x86.c
> +++ b/tools/libxc/xc_core_x86.c
> @@ -50,7 +50,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
>      xen_pfn_t p2m_size = 0;
>      xc_core_memory_map_t *map;
>  
> -    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
> +    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
>          return -1;
>  
>      map = malloc(sizeof(*map));
> @@ -85,7 +85,7 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc
>      int err;
>      int i;
>  
> -    if ( xc_domain_maximum_gpfn(xch, info->domid, &dinfo->p2m_size) < 0 )
> +    if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 )
>      {
>          ERROR("Could not get maximum GPFN!");
>          goto out;
> @@ -212,7 +212,7 @@ int
>  xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
>                                xen_pfn_t *gpfn)
>  {
> -    return xc_domain_maximum_gpfn(xch, domid, gpfn);
> +    return xc_domain_nr_gpfns(xch, domid, gpfn);
>  }
>  
>  /*
> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> index da88e08..dc62eff 100644
> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -795,12 +795,22 @@ int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
>  
>      if ( rc >= 0 )
>      {
> -        *gpfns = rc + 1;
> +        *gpfns = rc;
>          rc = 0;
>      }
>      return rc;
>  }
>  
> +int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
> +{
> +    int rc = xc_domain_maximum_gpfn(xch, domid, gpfns);
> +
> +    if ( rc >= 0 )
> +        *gpfns += 1;
> +
> +    return rc;
> +}
> +
>  int xc_domain_increase_reservation(xc_interface *xch,
>                                     uint32_t domid,
>                                     unsigned long nr_extents,
> diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
> index b611c07..cef6995 100644
> --- a/tools/libxc/xc_domain_save.c
> +++ b/tools/libxc/xc_domain_save.c
> @@ -939,7 +939,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
>      }
>  
>      /* Get the size of the P2M table */
> -    if ( xc_domain_maximum_gpfn(xch, dom, &dinfo->p2m_size) < 0 )
> +    if ( xc_domain_nr_gpfns(xch, dom, &dinfo->p2m_size) < 0 )
>      {
>          ERROR("Could not get maximum GPFN!");
>          goto out;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn.
  2015-03-30 14:52 ` Andrew Cooper
@ 2015-03-30 16:27   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2015-03-30 16:27 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel, ian.jackson

On Mon, 2015-03-30 at 15:52 +0100, Andrew Cooper wrote:
> On 30/03/15 15:46, Konrad Rzeszutek Wilk wrote:
> > The commit a8f8a590e02d2d2b717257c0bd9a8b396103bdf4
> > "libxc: Check xc_domain_maximum_gpfn for negative return values"
> > introduced an regression in tools outside libxc (migrate v2)
> > which wanted the unfiltered GPFN value. Said commit added
> > a wrapper which added +1 if there were no errors.
> >
> > To make it work pre-commit a8f8a59 we add an xc_domain_nr_gpfns
> > which will add +1 if there are no errors (and change all in-tree
> > callers to use it). The xc_domain_maximum_gpfn will return the
> > unfiltered GPFN value.
> >
> > Suggested-by: Ian Campbell <ian.campbell@citrix.com>
> > Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Applied.

> 
> > ---
> >  tools/libxc/include/xenctrl.h |  2 ++
> >  tools/libxc/xc_core_arm.c     |  2 +-
> >  tools/libxc/xc_core_x86.c     |  6 +++---
> >  tools/libxc/xc_domain.c       | 12 +++++++++++-
> >  tools/libxc/xc_domain_save.c  |  2 +-
> >  5 files changed, 18 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> > index 4e9537e..552ace8 100644
> > --- a/tools/libxc/include/xenctrl.h
> > +++ b/tools/libxc/include/xenctrl.h
> > @@ -1317,6 +1317,8 @@ int xc_domain_disable_migrate(xc_interface *xch, uint32_t domid);
> >  
> >  int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
> >  
> > +int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns);
> > +
> >  int xc_domain_increase_reservation(xc_interface *xch,
> >                                     uint32_t domid,
> >                                     unsigned long nr_extents,
> > diff --git a/tools/libxc/xc_core_arm.c b/tools/libxc/xc_core_arm.c
> > index c3f5868..57d4715 100644
> > --- a/tools/libxc/xc_core_arm.c
> > +++ b/tools/libxc/xc_core_arm.c
> > @@ -45,7 +45,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
> >      xen_pfn_t p2m_size = 0;
> >      xc_core_memory_map_t *map;
> >  
> > -    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
> > +    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
> >          return -1;
> >  
> >      map = malloc(sizeof(*map));
> > diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c
> > index 4552e43..93ebcbb 100644
> > --- a/tools/libxc/xc_core_x86.c
> > +++ b/tools/libxc/xc_core_x86.c
> > @@ -50,7 +50,7 @@ xc_core_arch_memory_map_get(xc_interface *xch, struct xc_core_arch_context *unus
> >      xen_pfn_t p2m_size = 0;
> >      xc_core_memory_map_t *map;
> >  
> > -    if ( xc_domain_maximum_gpfn(xch, info->domid, &p2m_size) < 0 )
> > +    if ( xc_domain_nr_gpfns(xch, info->domid, &p2m_size) < 0 )
> >          return -1;
> >  
> >      map = malloc(sizeof(*map));
> > @@ -85,7 +85,7 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc
> >      int err;
> >      int i;
> >  
> > -    if ( xc_domain_maximum_gpfn(xch, info->domid, &dinfo->p2m_size) < 0 )
> > +    if ( xc_domain_nr_gpfns(xch, info->domid, &dinfo->p2m_size) < 0 )
> >      {
> >          ERROR("Could not get maximum GPFN!");
> >          goto out;
> > @@ -212,7 +212,7 @@ int
> >  xc_core_arch_get_scratch_gpfn(xc_interface *xch, domid_t domid,
> >                                xen_pfn_t *gpfn)
> >  {
> > -    return xc_domain_maximum_gpfn(xch, domid, gpfn);
> > +    return xc_domain_nr_gpfns(xch, domid, gpfn);
> >  }
> >  
> >  /*
> > diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> > index da88e08..dc62eff 100644
> > --- a/tools/libxc/xc_domain.c
> > +++ b/tools/libxc/xc_domain.c
> > @@ -795,12 +795,22 @@ int xc_domain_maximum_gpfn(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
> >  
> >      if ( rc >= 0 )
> >      {
> > -        *gpfns = rc + 1;
> > +        *gpfns = rc;
> >          rc = 0;
> >      }
> >      return rc;
> >  }
> >  
> > +int xc_domain_nr_gpfns(xc_interface *xch, domid_t domid, xen_pfn_t *gpfns)
> > +{
> > +    int rc = xc_domain_maximum_gpfn(xch, domid, gpfns);
> > +
> > +    if ( rc >= 0 )
> > +        *gpfns += 1;
> > +
> > +    return rc;
> > +}
> > +
> >  int xc_domain_increase_reservation(xc_interface *xch,
> >                                     uint32_t domid,
> >                                     unsigned long nr_extents,
> > diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
> > index b611c07..cef6995 100644
> > --- a/tools/libxc/xc_domain_save.c
> > +++ b/tools/libxc/xc_domain_save.c
> > @@ -939,7 +939,7 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t max_iter
> >      }
> >  
> >      /* Get the size of the P2M table */
> > -    if ( xc_domain_maximum_gpfn(xch, dom, &dinfo->p2m_size) < 0 )
> > +    if ( xc_domain_nr_gpfns(xch, dom, &dinfo->p2m_size) < 0 )
> >      {
> >          ERROR("Could not get maximum GPFN!");
> >          goto out;
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-30 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-30 14:46 [PATCH] libxc: Introduce xc_domain_nr_gpfns as a cousin of xc_domain_maximum_gpfn Konrad Rzeszutek Wilk
2015-03-30 14:52 ` Andrew Cooper
2015-03-30 16:27   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.