Linux Container Development
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: Re: [PATCH 2/3] define function to print error messages to user log
Date: Mon, 26 Oct 2009 13:33:59 -0500	[thread overview]
Message-ID: <20091026183359.GI23564@us.ibm.com> (raw)
In-Reply-To: <4AE491CB.60109-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>

Quoting Oren Laadan (orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org):
> 
> 
> Serge E. Hallyn wrote:
> > Error messages are both sent to an optional user-provided logfile,
> > and, if CONFIG_CHECKPOINT_DEBUG=y, sent to syslog.
> > 
> > Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> > ---
> >  checkpoint/objhash.c             |    2 +
> >  checkpoint/sys.c                 |   61 ++++++++++++++++++++++++++++++++++---
> >  include/linux/checkpoint.h       |    2 +-
> >  include/linux/checkpoint_types.h |    1 +
> >  include/linux/syscalls.h         |    5 ++-
> >  5 files changed, 63 insertions(+), 8 deletions(-)
> > 
> > diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
> > index 730dd82..c441ce6 100644
> > --- a/checkpoint/objhash.c
> > +++ b/checkpoint/objhash.c
> > @@ -858,6 +858,8 @@ int ckpt_obj_contained(struct ckpt_ctx *ctx)
> >  
> >  	/* account for ctx->file reference (if in the table already) */
> >  	ckpt_obj_users_inc(ctx, ctx->file, 1);
> > +	if (ctx->logfile)
> > +		ckpt_obj_users_inc(ctx, ctx->logfile, 1);
> >  	/* account for ctx->root_nsproxy reference (if in the table already) */
> >  	ckpt_obj_users_inc(ctx, ctx->root_nsproxy, 1);
> >  
> > diff --git a/checkpoint/sys.c b/checkpoint/sys.c
> > index 260a1ee..1840f90 100644
> > --- a/checkpoint/sys.c
> > +++ b/checkpoint/sys.c
> > @@ -204,6 +204,8 @@ static void ckpt_ctx_free(struct ckpt_ctx *ctx)
> >  
> >  	if (ctx->file)
> >  		fput(ctx->file);
> > +	if (ctx->logfile)
> > +		fput(ctx->logfile);
> >  
> >  	ckpt_obj_hash_free(ctx);
> >  	path_put(&ctx->fs_mnt);
> > @@ -225,7 +227,7 @@ static void ckpt_ctx_free(struct ckpt_ctx *ctx)
> >  }
> >  
> >  static struct ckpt_ctx *ckpt_ctx_alloc(int fd, unsigned long uflags,
> > -				       unsigned long kflags)
> > +				       unsigned long kflags, int logfd)
> >  {
> >  	struct ckpt_ctx *ctx;
> >  	int err;
> > @@ -238,6 +240,9 @@ static struct ckpt_ctx *ckpt_ctx_alloc(int fd, unsigned long uflags,
> >  	ctx->kflags = kflags;
> >  	ctx->ktime_begin = ktime_get();
> >  
> > +	/* If logfd's a bad fd that's fine, no log output required... */
> > +	ctx->logfile = fget(logfd);
> 
> Can we make it more user-friendly, e.g. f logfd==-1 then no logfile,
> otherwise if fget(logfd) fails then return -EBADF ?
> 
> > +
> >  	atomic_set(&ctx->refcount, 0);
> >  	INIT_LIST_HEAD(&ctx->pgarr_list);
> >  	INIT_LIST_HEAD(&ctx->pgarr_pool);
> > @@ -339,6 +344,51 @@ int walk_task_subtree(struct task_struct *root,
> >  	return (ret < 0 ? ret : total);
> >  }
> >  
> > +/*
> > + * currentpid:targetpid fmt%args
> > + */
> > +void ckpt_log_error(struct ckpt_ctx *ctx, char *fmt, ...)
> > +{
> 
> As I commented before, I really wish not to go through this again.
> Can we come up with a mechanism for error messages, that will set
> a "standard" format (like I tried to do in ckpt_write_err) ?
> 
> (I like Matt's suggestion to use one format string instead of two,
> and allow "%(T)" constructs for our format directives).
> 
> Also, I assume some of that code can be reused here below.

Perhaps we should be using the audit system.

-serge

  parent reply	other threads:[~2009-10-26 18:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-23  4:13 [PATCH 1/3] cr: debug: define ckpt_error() Serge E. Hallyn
     [not found] ` <20091023041325.GA2863-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-23  4:13   ` [PATCH 2/3] define function to print error messages to user log Serge E. Hallyn
     [not found]     ` <20091023041349.GA2915-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-25 17:58       ` Oren Laadan
     [not found]         ` <4AE491CB.60109-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-26 18:33           ` Serge E. Hallyn [this message]
2009-10-23  4:14   ` [PATCH 3/3] use ckpt_error in checkpoint/restart.c 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=20091026183359.GI23564@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=orenl-RdfvBDnrOixBDgjK7y7TUQ@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