[Devel] Re: [PATCH 04/22] Change to the new enhanced error string format

Matt Helsley matthltc at us.ibm.com
Mon Nov 2 09:34:02 PST 2009


On Fri, Oct 30, 2009 at 06:00:26PM -0500, serue at us.ibm.com wrote:
> From: Serge E. Hallyn <serue at us.ibm.com>
> 
> Signed-off-by: Serge E. Hallyn <serue at us.ibm.com>
> ---

<snip>

> diff --git a/checkpoint/sys.c b/checkpoint/sys.c
> index 8810576..e2c01df 100644
> --- a/checkpoint/sys.c
> +++ b/checkpoint/sys.c
> @@ -345,83 +345,83 @@ int walk_task_subtree(struct task_struct *root,
>  }
> 
>  /*
> - * ckpt_generate_fmt - generate standard checkpoint error message
> + * ckpt_generate_fmt - handle the special flags in the enhanced format
> + * strings used by checkpoint/restart error messages.
>   * @ctx: checkpoint context
> - * @fmt0: c/r-format string
>   * @fmt: message format
>   *
> - * This generates a unified format of checkpoint error messages, to
> - * ease (after the failure) inspection by userspace tools. It converts
> - * the (printf) message @fmt into a new format: "[PREFMT]: fmt".
> + * The special flags are surrounded by %() to help them visually stand
> + * out.  For instance, %(O) means an objref.  The following special
> + * flags are recognized:
> + *	E: error
> + *	O: objref
> + *	P: pointer
> + *	T: task
> + *	S: string
> + *	V: variable
>   *
> - * PREFMT is constructed from @fmt0 by subtituting format snippets
> - * according to the contents of @fmt0.  The format characters in
> - * @fmt0 can be E (error), O (objref), P (pointer), S (string) and
> - * V (variable/symbol). For example, E will generate a "err %d" in
> - * PREFMT (see prefmt_array below).
> - *
> - * If @fmt0 begins with T, PREFMT will begin with "pid %d tsk %s"
> - * with the pid and the tsk->comm of the currently checkpointed task.
> - * The latter is taken from ctx->tsk, and is it the responsbilility of
> - * the caller to have a valid pointer there (in particular, functions
> - * that iterate on the processes: collect_objects, checkpoint_task,
> - * and tree_count_tasks).
> + * %(E) will be expanded to "[err %d]".  Likewise O, P, S, and V, will
> + * also expand to format flags requiring an argument to the subsequent
> + * sprintf or printk.  T will be expanded to a string with no flags,
> + * requiring no further arguments.
>   *
>   * The caller of ckpt_write_err() and _ckpt_write_err() must provide
> - * the additional variabes, in order, to match the @fmt0 (except for
> + * the additional variabes, in order, to match the @fmt (except for
>   * the T key), e.g.:
>   *
> - *   ckpt_writ_err(ctx, "TEO", "FILE flags %d", err, objref, flags);
> - *
> - * Here, T is simply passed, E expects an integer (err), O expects an
> - * integer (objref), and the last argument matches the format string.
> + *	ckpt_write_err(ctx, "%(T)FILE flags %d %O %E\n", flags, objref, err);
>   *
>   * Must be called with ctx->fmt_buf_lock held.  The expanded format
>   * will be placed in ctx->fmt_buf.

It might also be good to note that, unlike normal conversion
specifications, these do not allow any flags, minimum field width,
precision, length modifiers, or argument numbers ("%*" or "%*m$").
This keeps these portions of the log(s) somewhat uniform and also
simplifies the code.

<snip>

Cheers,
	-Matt Helsley
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list