Linux Container Development
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH 10/17] define function to print error messages to user log
Date: Thu, 29 Oct 2009 18:43:10 -0400	[thread overview]
Message-ID: <4AEA1A7E.1050509@librato.com> (raw)
In-Reply-To: <1256849682-858-11-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>



serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org wrote:
> From: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> 
> Error messages are both sent to an optional user-provided logfile,
> and, if CONFIG_CHECKPOINT_DEBUG=y, sent to syslog.
> 
> Changelog:
> 	Oct 29: Split ckpt_log_error() into ckpt_log_error_v() and have
> 		ckpt_write_err() call it to duplicate the checkpoint
> 		error message into the optional user-provided log file and
> 		(if CONFIG_CHECKPOINT_DEBUG=y) syslog as well.
> 		Define a fn writing an error prefix (containing
> 		current->pid etc) for ckpt_error().
> 	Oct 28: Don't use a third va_args, and use smaller on-stack
> 		buffer (mhelsley comments).  It still might be cleaner
> 		to always kmalloc, but always using two kmallocs per
> 		ckpt_error is getting kinda gross...  (open to comments
> 		on that).
> 	Oct 26: Per Oren suggestion, return -EBADF for bad
> 		logfile in ckpt_ctx_alloc().
> 
> Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  checkpoint/checkpoint.c          |    8 +++-
>  checkpoint/objhash.c             |    2 +
>  checkpoint/sys.c                 |   91 ++++++++++++++++++++++++++++++++++----
>  include/linux/checkpoint.h       |    5 ++
>  include/linux/checkpoint_types.h |    5 ++
>  include/linux/syscalls.h         |    5 +-
>  6 files changed, 103 insertions(+), 13 deletions(-)
> 
> diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
> index 35fce15..30ec622 100644
> --- a/checkpoint/checkpoint.c
> +++ b/checkpoint/checkpoint.c
> @@ -123,8 +123,6 @@ static void __ckpt_generate_err(struct ckpt_ctx *ctx, char *fmt, va_list ap)
>  
>  	va_end(aq);
>  	kfree(format);
> -
> -	ckpt_debug("c/r: checkpoint error: %s\n", str);
>  }
>  
>  /**
> @@ -140,9 +138,15 @@ void __ckpt_write_err(struct ckpt_ctx *ctx, char *fmt, ...)
>  {
>  	va_list ap;
>  
> +	/* write to checkpoint file */
>  	va_start(ap, fmt);
>  	__ckpt_generate_err(ctx, fmt, ap);
>  	va_end(ap);
> +
> +	/* write to user log and syslog */
> +	va_start(ap, fmt);
> +	ckpt_log_error_v(ctx, fmt, ap);
> +	va_end(ap);
>  }

__ckpt_write_err() can be called from spinlock context, so
it needs to remain as is.

Instead, call ckpt_log_error_v() from ckpt_write_err(), and if
the have ckpt_log_error_v() also avoid calling __ckpt_generate_err()
if the @fmt string is NULL, instead take from @ctx->err_string.

To be complete, we probably also need ckpt_log_{un,}lock(), that
are used in ckpt_log_error_v() and should also be used by whoever
uses _ckpt_write_err() directly.

Also, in light of my suggestion in the other email, maybe rename
ckpt_generate_err() to ckpt_generate_msg().

Oren.

  parent reply	other threads:[~2009-10-29 22:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-29 20:54 [PATCH 00/17] Standardize c/r error reporting serue-r/Jw6+rmf7HQT0dZR+AlfA
     [not found] ` <1256849682-858-1-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-29 20:54   ` [PATCH 01/17] ckpt_write_err: use single format with %(T) style tokens serue-r/Jw6+rmf7HQT0dZR+AlfA
     [not found]     ` <1256849682-858-2-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-29 22:20       ` Oren Laadan
     [not found]         ` <4AEA1527.7090907-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-30  2:18           ` Serge E. Hallyn
     [not found]             ` <20091030021819.GB10379-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-30 15:45               ` Oren Laadan
2009-10-30  6:37       ` Sukadev Bhattiprolu
     [not found]         ` <20091030063712.GA409-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-30 13:33           ` Serge E. Hallyn
2009-10-29 20:54   ` [PATCH 02/17] ckpt_write_err update arch/x86/mm/checkpoint.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 03/17] ckpt_write_err update checkpoint/checkpoint.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 04/17] ckpt_write_err update checkpoint/files.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 05/17] ckpt_write_err update checkpoint/memory.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 06/17] ckpt_write_err update checkpoint/objhash.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 07/17] ckpt_write_err update checkpoint/process.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 08/17] ckpt_write_err update checkpoint/signal.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 09/17] ckpt_write_err update fs/eventpoll.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 10/17] define function to print error messages to user log serue-r/Jw6+rmf7HQT0dZR+AlfA
     [not found]     ` <1256849682-858-11-git-send-email-serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-29 22:43       ` Oren Laadan [this message]
2009-10-29 20:54   ` [PATCH 11/17] have restore_debug_free use ckpt_error serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 12/17] use ckpt_error in checkpoint/restart.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 13/17] ckpt_error in checkpoint/files.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 14/17] ckpt_error in checkpoint/process.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 15/17] ckpt_error in ipc/checkpoint_msg.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 16/17] ckpt_error in ipc/checkpoint_sem.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 20:54   ` [PATCH 17/17] ckpt_error in ipc/checkpoint_shm.c serue-r/Jw6+rmf7HQT0dZR+AlfA
2009-10-29 22:32   ` [PATCH 00/17] Standardize c/r error reporting Oren Laadan
     [not found]     ` <4AEA17E6.6050609-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-30  2:12       ` Serge E. Hallyn

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=4AEA1A7E.1050509@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.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