Re: [Xen-devel] [PATCH QEMU-XEN v4 3/9] xen: Switch to libxengnttab interface for compat shims.

2015-10-23 Thread Ian Campbell
On Fri, 2015-10-23 at 12:06 +0100, Stefano Stabellini wrote:
> On Wed, 21 Oct 2015, Ian Campbell wrote:
> > In Xen 4.7 we are refactoring parts libxenctrl into a number of
> > separate libraries which will provide backward and forward API and ABI
> > compatiblity.
> > 
> > One such library will be libxengnttab which provides access to grant
> > tables.
> > 
> > In preparation for this switch the compatibility layer in xen_common.h
> > (which support building with older versions of Xen) to use what will
> > be the new library API. This means that the gnttab shim will disappear
> > for versions of Xen which include libxengnttab.
> > 
> > To simplify things for the <= 4.0.0 support we wrap the int fd in a
> > malloc(sizeof int) such that the handle is always a pointer. This
> > leads to less typedef headaches and the need for
> > XC_HANDLER_INITIAL_VALUE etc for these interfaces.
> > 
> > Build tested with 4.0 and 4.5.
> > 
> > Note that this patch does not add any support for actually using
> > libxengnttab, it just adjusts the existing shims.
> > 
> > Signed-off-by: Ian Campbell 
> 
> The patch looks OK but doesn't apply cleanly to master, please rebase.
> After fixing it up, it fails my 4.0 build test (I probably made a
> mistake).

There was a new xc_gnttab_munmap which needed converting.

BTW, contrary to what every single commit message here says I'm actually
build testing on: xen with my other patches from this mega series, 4.6,
4.1, 4.0, 4.5, 4.4, 4.3, 4.2 and on my dev xen with pvbuilder forced to on.
I'm just going to drop all these "Build tested.." from the commit messages.

(the strange version ordering is so I test the different API classes first
and fail early on problems and then fill in the gaps).

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH QEMU-XEN v4 3/9] xen: Switch to libxengnttab interface for compat shims.

2015-10-23 Thread Stefano Stabellini
On Wed, 21 Oct 2015, Ian Campbell wrote:
> In Xen 4.7 we are refactoring parts libxenctrl into a number of
> separate libraries which will provide backward and forward API and ABI
> compatiblity.
> 
> One such library will be libxengnttab which provides access to grant
> tables.
> 
> In preparation for this switch the compatibility layer in xen_common.h
> (which support building with older versions of Xen) to use what will
> be the new library API. This means that the gnttab shim will disappear
> for versions of Xen which include libxengnttab.
> 
> To simplify things for the <= 4.0.0 support we wrap the int fd in a
> malloc(sizeof int) such that the handle is always a pointer. This
> leads to less typedef headaches and the need for
> XC_HANDLER_INITIAL_VALUE etc for these interfaces.
> 
> Build tested with 4.0 and 4.5.
> 
> Note that this patch does not add any support for actually using
> libxengnttab, it just adjusts the existing shims.
> 
> Signed-off-by: Ian Campbell 

The patch looks OK but doesn't apply cleanly to master, please rebase.
After fixing it up, it fails my 4.0 build test (I probably made a
mistake).


> v4: Ran checkpatch, fixed all errors
> Allocate correct size for handle (i.e. not size of the ptr)
> Rebase onto "xen_console: correctly cleanup primary console on
> teardown."
> ---
>  hw/block/xen_disk.c  | 38 --
>  hw/char/xen_console.c|  4 ++--
>  hw/net/xen_nic.c | 16 
>  hw/xen/xen_backend.c | 10 +-
>  include/hw/xen/xen_backend.h |  2 +-
>  include/hw/xen/xen_common.h  | 42 --
>  6 files changed, 68 insertions(+), 44 deletions(-)
> 
> diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
> index 21842a0..15413f6 100644
> --- a/hw/block/xen_disk.c
> +++ b/hw/block/xen_disk.c
> @@ -172,11 +172,11 @@ static gint int_cmp(gconstpointer a, gconstpointer b, 
> gpointer user_data)
>  static void destroy_grant(gpointer pgnt)
>  {
>  PersistentGrant *grant = pgnt;
> -XenGnttab gnt = grant->blkdev->xendev.gnttabdev;
> +xengnttab_handle *gnt = grant->blkdev->xendev.gnttabdev;
>  
> -if (xc_gnttab_munmap(gnt, grant->page, 1) != 0) {
> +if (xengnttab_munmap(gnt, grant->page, 1) != 0) {
>  xen_be_printf(>blkdev->xendev, 0,
> -  "xc_gnttab_munmap failed: %s\n",
> +  "xengnttab_munmap failed: %s\n",
>strerror(errno));
>  }
>  grant->blkdev->persistent_gnt_count--;
> @@ -189,11 +189,11 @@ static void remove_persistent_region(gpointer data, 
> gpointer dev)
>  {
>  PersistentRegion *region = data;
>  struct XenBlkDev *blkdev = dev;
> -XenGnttab gnt = blkdev->xendev.gnttabdev;
> +xengnttab_handle *gnt = blkdev->xendev.gnttabdev;
>  
> -if (xc_gnttab_munmap(gnt, region->addr, region->num) != 0) {
> +if (xengnttab_munmap(gnt, region->addr, region->num) != 0) {
>  xen_be_printf(>xendev, 0,
> -  "xc_gnttab_munmap region %p failed: %s\n",
> +  "xengnttab_munmap region %p failed: %s\n",
>region->addr, strerror(errno));
>  }
>  xen_be_printf(>xendev, 3,
> @@ -328,7 +328,7 @@ err:
>  
>  static void ioreq_unmap(struct ioreq *ioreq)
>  {
> -XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
> +xengnttab_handle *gnt = ioreq->blkdev->xendev.gnttabdev;
>  int i;
>  
>  if (ioreq->num_unmap == 0 || ioreq->mapped == 0) {
> @@ -338,8 +338,9 @@ static void ioreq_unmap(struct ioreq *ioreq)
>  if (!ioreq->pages) {
>  return;
>  }
> -if (xc_gnttab_munmap(gnt, ioreq->pages, ioreq->num_unmap) != 0) {
> -xen_be_printf(>blkdev->xendev, 0, "xc_gnttab_munmap 
> failed: %s\n",
> +if (xengnttab_munmap(gnt, ioreq->pages, ioreq->num_unmap) != 0) {
> +xen_be_printf(>blkdev->xendev, 0,
> +  "xengnttab_munmap failed: %s\n",
>strerror(errno));
>  }
>  ioreq->blkdev->cnt_map -= ioreq->num_unmap;
> @@ -349,8 +350,9 @@ static void ioreq_unmap(struct ioreq *ioreq)
>  if (!ioreq->page[i]) {
>  continue;
>  }
> -if (xc_gnttab_munmap(gnt, ioreq->page[i], 1) != 0) {
> -xen_be_printf(>blkdev->xendev, 0, "xc_gnttab_munmap 
> failed: %s\n",
> +if (xengnttab_munmap(gnt, ioreq->page[i], 1) != 0) {
> +xen_be_printf(>blkdev->xendev, 0,
> +  "xengnttab_munmap failed: %s\n",
>strerror(errno));
>  }
>  ioreq->blkdev->cnt_map--;
> @@ -362,7 +364,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
>  
>  static int ioreq_map(struct ioreq *ioreq)
>  {
> -XenGnttab gnt = ioreq->blkdev->xendev.gnttabdev;
> +xengnttab_handle *gnt = 

Re: [Xen-devel] [PATCH QEMU-XEN v4 3/9] xen: Switch to libxengnttab interface for compat shims.

2015-10-23 Thread Ian Campbell
On Fri, 2015-10-23 at 12:06 +0100, Stefano Stabellini wrote:
> On Wed, 21 Oct 2015, Ian Campbell wrote:
> > In Xen 4.7 we are refactoring parts libxenctrl into a number of
> > separate libraries which will provide backward and forward API and ABI
> > compatiblity.
> > 
> > One such library will be libxengnttab which provides access to grant
> > tables.
> > 
> > In preparation for this switch the compatibility layer in xen_common.h
> > (which support building with older versions of Xen) to use what will
> > be the new library API. This means that the gnttab shim will disappear
> > for versions of Xen which include libxengnttab.
> > 
> > To simplify things for the <= 4.0.0 support we wrap the int fd in a
> > malloc(sizeof int) such that the handle is always a pointer. This
> > leads to less typedef headaches and the need for
> > XC_HANDLER_INITIAL_VALUE etc for these interfaces.
> > 
> > Build tested with 4.0 and 4.5.
> > 
> > Note that this patch does not add any support for actually using
> > libxengnttab, it just adjusts the existing shims.
> > 
> > Signed-off-by: Ian Campbell 
> 
> The patch looks OK but doesn't apply cleanly to master, please rebase.
> After fixing it up, it fails my 4.0 build test (I probably made a
> mistake).

It was based on:

commit 816609b2841297925a223ec377c336360e044ee5
Author: Gerd Hoffmann 
Date:   Tue Jun 9 21:08:47 2015 +0200

spice-display: fix segfault in qemu_spice_create_update

Ah, I'm pointing at our xenbits qemu upstream tree (master branch, not even
upstream-tested) not the qemu.org one. I'll update to base on proper
mainline for v5 next time.

(I thought things were awfully quite on the incoming patches front when I
ran git remote update!)


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel