xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: "Cédric Bosdonnat" <cbosdonnat@suse.com>
Cc: "Cédric Bosdonnat" <cedric.bosdonnat@free.fr>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
Date: Thu, 17 Nov 2016 14:41:05 +0000	[thread overview]
Message-ID: <20161117144105.GB23528@citrix.com> (raw)
In-Reply-To: <20161115101913.10396-2-cbosdonnat@suse.com>

On Tue, Nov 15, 2016 at 11:18:39AM +0100, Cédric Bosdonnat wrote:
> From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
> 
> These functions should be used to log messages when the domain
> id is known. libxl__log will now prepend the log message by
> "Domain %PRIu32:" if the domain id is a valid one.
> 
> This aims at helping consumers filter logs on domain IDs.
> 
> Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> ---
>  tools/libxl/libxl_event.c    |  6 +++---
>  tools/libxl/libxl_internal.c | 16 ++++++++++------
>  tools/libxl/libxl_internal.h | 38 +++++++++++++++++++++++++++++++-------
>  3 files changed, 44 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> index 02b39e6..fc9bdc9 100644
> --- a/tools/libxl/libxl_event.c
> +++ b/tools/libxl/libxl_event.c
> @@ -1362,7 +1362,7 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
>  {
>      EGC_GC;
>  
> -    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func,
> +    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
>                 "DISASTER in event loop: %s%s%s%s",
>                 msg,
>                 type ? " (relates to event type " : "",
> @@ -1943,7 +1943,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid,
>          ao->poller = libxl__poller_get(&ao->gc);
>          if (!ao->poller) goto out;
>      }
> -    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,
> +    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,domid,
>                 "ao %p: create: how=%p callback=%p poller=%p",
>                 ao, how, ao->how.callback, ao->poller);
>  
> @@ -1968,7 +1968,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
>      assert(ao->in_initiator);
>      ao->constructing = 0;
>  
> -    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,
> +    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,INVALID_DOMID,

You should be able to use ao->domid here, right?

>                 "ao %p: inprogress: poller=%p, flags=%s%s%s%s",
>                 ao, ao->poller,
>                 ao->constructing ? "o" : "",
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index 448dd61..78ed2f6 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -22,7 +22,7 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func,
>  #define M "libxl: FATAL ERROR: memory allocation failure"
>  #define L (size ? M " (%s, %lu x %lu)\n" : M " (%s)\n"), \
>            func, (unsigned long)nmemb, (unsigned long)size
> -    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, L);
> +    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L);
>      fprintf(stderr, L);
>      fflush(stderr);
>      _exit(-1);
> @@ -202,7 +202,7 @@ char *libxl__dirname(libxl__gc *gc, const char *s)
>  
>  void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>               const char *file, int line, const char *func,
> -             const char *fmt, va_list ap)
> +             uint32_t domid, const char *fmt, va_list ap)
>  {
>      /* WARNING this function may not call any libxl-provided
>       * memory allocation function, as those may
> @@ -211,6 +211,7 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>      char *base = NULL;
>      int rc, esave;
>      char fileline[256];
> +    char domain[256];
>  
>      esave = errno;
>  
> @@ -221,22 +222,25 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>      if (file) snprintf(fileline, sizeof(fileline), "%s:%d",file,line);
>      fileline[sizeof(fileline)-1] = 0;
>  
> +    domain[0] = 0;
> +    if (domid != INVALID_DOMID) snprintf(domain, sizeof(domain), "Domain %"PRIu32":", domid);

Coding style issue, please put snprintf in a new line.

> +    domain[sizeof(domain)-1] = 0;

This probably does do what you want it to do - sizeof(domain) -> 256.  I
don't think you need this at all because IIRC snprintf puts a \0 at the
end.

Overall I think this is in line with what we discussed before.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-11-17 14:41 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
2016-11-17 14:41   ` Wei Liu [this message]
2016-11-17 16:01     ` Cedric Bosdonnat
2016-11-17 16:12       ` Wei Liu
2016-11-17 16:29       ` Ian Jackson
2016-11-17 16:34         ` Wei Liu
2016-11-17 16:36           ` Ian Jackson
2016-11-17 16:38             ` Wei Liu
2016-11-15 10:18 ` [PATCH 02/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages) Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 04/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
2016-11-17 14:50   ` Wei Liu
2016-11-17 16:03     ` Cedric Bosdonnat
2016-11-17 16:15       ` Wei Liu
2016-11-17 16:30       ` Ian Jackson
2016-11-15 10:18 ` [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 06/35] libxl/libxl_checkpoint_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 07/35] libxl/libxl_colo.h: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 08/35] libxl/libxl_colo_nic.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 09/35] libxl/libxl_colo_proxy.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 10/35] libxl/libxl_colo_qdisk.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 11/35] libxl/libxl_colo_restore.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 12/35] libxl/libxl_colo_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 13/35] libxl/libxl_create.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 14/35] libxl/libxl_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 15/35] libxl/libxl_dm.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 16/35] libxl/libxl_dom_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 17/35] libxl/libxl_dom_suspend.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 18/35] libxl/libxl_freebsd.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 19/35] libxl/libxl_internal.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 20/35] libxl/libxl_linux.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 21/35] libxl/libxl_netbsd.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 22/35] libxl/libxl_netbuffer.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 23/35] libxl/libxl_nic.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 24/35] libxl/libxl_no_colo.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 25/35] libxl/libxl_pci.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 26/35] libxl/libxl_psr.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 27/35] libxl/libxl_pvusb.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 28/35] libxl/libxl_qmp.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 29/35] libxl/libxl_remus.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 30/35] libxl/libxl_save_callout.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 31/35] libxl/libxl_stream_write.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 32/35] libxl/libxl_vnuma.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 33/35] libxl/libxl_vtpm.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 34/35] libxl/libxl_x86.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 35/35] libxl/libxl_xshelp.c: " Cédric Bosdonnat

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=20161117144105.GB23528@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=cbosdonnat@suse.com \
    --cc=cedric.bosdonnat@free.fr \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).