qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xen: Log errno rather than return value
@ 2017-10-11 15:52 Ross Lagerwall
  2017-10-11 16:06 ` Anthony PERARD
  2017-10-12  9:46 ` Paul Durrant
  0 siblings, 2 replies; 4+ messages in thread
From: Ross Lagerwall @ 2017-10-11 15:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ross Lagerwall, Stefano Stabellini, Anthony Perard

xen_modified_memory() sets errno to communicate what went wrong so log
this rather than the return value which is not interesting.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 hw/i386/xen/xen-hvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index d9ccd5d..8028bed 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -1446,7 +1446,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
         if (rc) {
             fprintf(stderr,
                     "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
-                    __func__, start, nb_pages, rc, strerror(-rc));
+                    __func__, start, nb_pages, errno, strerror(errno));
         }
     }
 }
-- 
2.9.5

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

* Re: [Qemu-devel] [PATCH] xen: Log errno rather than return value
  2017-10-11 15:52 [Qemu-devel] [PATCH] xen: Log errno rather than return value Ross Lagerwall
@ 2017-10-11 16:06 ` Anthony PERARD
  2017-10-12  9:46 ` Paul Durrant
  1 sibling, 0 replies; 4+ messages in thread
From: Anthony PERARD @ 2017-10-11 16:06 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: qemu-devel, Stefano Stabellini

On Wed, Oct 11, 2017 at 04:52:03PM +0100, Ross Lagerwall wrote:
> xen_modified_memory() sets errno to communicate what went wrong so log
> this rather than the return value which is not interesting.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  hw/i386/xen/xen-hvm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> index d9ccd5d..8028bed 100644
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -1446,7 +1446,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
>          if (rc) {
>              fprintf(stderr,
>                      "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
> -                    __func__, start, nb_pages, rc, strerror(-rc));
> +                    __func__, start, nb_pages, errno, strerror(errno));
>          }
>      }
>  }

There is already a patch, not applied yet for it,
https://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg07541.html
with the only difference is printing the value of rc and not errno (both
patch user errno for strerror).

I guess this patch is better, so
Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD

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

* Re: [Qemu-devel] [PATCH] xen: Log errno rather than return value
  2017-10-11 15:52 [Qemu-devel] [PATCH] xen: Log errno rather than return value Ross Lagerwall
  2017-10-11 16:06 ` Anthony PERARD
@ 2017-10-12  9:46 ` Paul Durrant
  2017-10-12 17:03   ` Paul Durrant
  1 sibling, 1 reply; 4+ messages in thread
From: Paul Durrant @ 2017-10-12  9:46 UTC (permalink / raw)
  To: Ross Lagerwall, qemu-devel@nongnu.org; +Cc: Anthony Perard, Stefano Stabellini

> -----Original Message-----
> From: Qemu-devel [mailto:qemu-devel-
> bounces+paul.durrant=citrix.com@nongnu.org] On Behalf Of Ross Lagerwall
> Sent: 11 October 2017 16:52
> To: qemu-devel@nongnu.org
> Cc: Anthony Perard <anthony.perard@citrix.com>; Ross Lagerwall
> <ross.lagerwall@citrix.com>; Stefano Stabellini <sstabellini@kernel.org>
> Subject: [Qemu-devel] [PATCH] xen: Log errno rather than return value
> 
> xen_modified_memory() sets errno to communicate what went wrong so
> log
> this rather than the return value which is not interesting.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  hw/i386/xen/xen-hvm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> index d9ccd5d..8028bed 100644
> --- a/hw/i386/xen/xen-hvm.c
> +++ b/hw/i386/xen/xen-hvm.c
> @@ -1446,7 +1446,7 @@ void xen_hvm_modified_memory(ram_addr_t
> start, ram_addr_t length)
>          if (rc) {
>              fprintf(stderr,
>                      "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, %s\n",
> -                    __func__, start, nb_pages, rc, strerror(-rc));
> +                    __func__, start, nb_pages, errno, strerror(errno));

I think this is actually a deeper problem. If QEMU is using compat code, which one way or another will go via xencall, then xen_modified_memory() will return a hypercall errno. However, if it goes via libxendevicemodel and an up-to-date privcmd, then it will return -1 and errno will be set. Thus I think the correct fix is not this patch, but a fix in xen_modified_memory() to return -errno and a fix in libxendevicemodel and the compat code in libxencntrl to behave consistently. It's all rather horrible.

  Paul

>          }
>      }
>  }
> --
> 2.9.5
> 

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

* Re: [Qemu-devel] [PATCH] xen: Log errno rather than return value
  2017-10-12  9:46 ` Paul Durrant
@ 2017-10-12 17:03   ` Paul Durrant
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Durrant @ 2017-10-12 17:03 UTC (permalink / raw)
  To: Paul Durrant, Ross Lagerwall, qemu-devel@nongnu.org
  Cc: Anthony Perard, Stefano Stabellini

> -----Original Message-----
> From: Qemu-devel [mailto:qemu-devel-
> bounces+paul.durrant=citrix.com@nongnu.org] On Behalf Of Paul Durrant
> Sent: 12 October 2017 10:47
> To: Ross Lagerwall <ross.lagerwall@citrix.com>; qemu-devel@nongnu.org
> Cc: Anthony Perard <anthony.perard@citrix.com>; Ross Lagerwall
> <ross.lagerwall@citrix.com>; Stefano Stabellini <sstabellini@kernel.org>
> Subject: Re: [Qemu-devel] [PATCH] xen: Log errno rather than return value
> 
> > -----Original Message-----
> > From: Qemu-devel [mailto:qemu-devel-
> > bounces+paul.durrant=citrix.com@nongnu.org] On Behalf Of Ross
> Lagerwall
> > Sent: 11 October 2017 16:52
> > To: qemu-devel@nongnu.org
> > Cc: Anthony Perard <anthony.perard@citrix.com>; Ross Lagerwall
> > <ross.lagerwall@citrix.com>; Stefano Stabellini <sstabellini@kernel.org>
> > Subject: [Qemu-devel] [PATCH] xen: Log errno rather than return value
> >
> > xen_modified_memory() sets errno to communicate what went wrong so
> > log
> > this rather than the return value which is not interesting.
> >
> > Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> > ---
> >  hw/i386/xen/xen-hvm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
> > index d9ccd5d..8028bed 100644
> > --- a/hw/i386/xen/xen-hvm.c
> > +++ b/hw/i386/xen/xen-hvm.c
> > @@ -1446,7 +1446,7 @@ void xen_hvm_modified_memory(ram_addr_t
> > start, ram_addr_t length)
> >          if (rc) {
> >              fprintf(stderr,
> >                      "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i,
> %s\n",
> > -                    __func__, start, nb_pages, rc, strerror(-rc));
> > +                    __func__, start, nb_pages, errno, strerror(errno));
> 
> I think this is actually a deeper problem. If QEMU is using compat code, which
> one way or another will go via xencall, then xen_modified_memory() will
> return a hypercall errno.

Having waded through the code now it turns out that (for linux at least) xencall returns the value returned from the underlying ioctl() call so it will actually return -1 with errno set correctly, so the above statement is incorrect. Thus there is no inconsistency and the patch DTRT.

Sorry for the noise.

  Paul

> However, if it goes via libxendevicemodel and an
> up-to-date privcmd, then it will return -1 and errno will be set. Thus I think
> the correct fix is not this patch, but a fix in xen_modified_memory() to return
> -errno and a fix in libxendevicemodel and the compat code in libxencntrl to
> behave consistently. It's all rather horrible.
> 
>   Paul
> 
> >          }
> >      }
> >  }
> > --
> > 2.9.5
> >
> 

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

end of thread, other threads:[~2017-10-12 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-11 15:52 [Qemu-devel] [PATCH] xen: Log errno rather than return value Ross Lagerwall
2017-10-11 16:06 ` Anthony PERARD
2017-10-12  9:46 ` Paul Durrant
2017-10-12 17:03   ` Paul Durrant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).