[Devel] Re: [PATCH 2/3] define function to print error messages to user log
Serge E. Hallyn
serue at us.ibm.com
Mon Oct 26 11:33:59 PDT 2009
Quoting Oren Laadan (orenl at librato.com):
>
>
> 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 at us.ibm.com>
> > ---
> > 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
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list