[CRIU] [PATCH 3/3] log: log engine slight redesign

Kir Kolyshkin kir at openvz.org
Tue Feb 28 18:03:25 EST 2012


On Feb 29, 2012 2:25 AM, "Cyrill Gorcunov" <gorcunov at openvz.org> wrote:
>
> As being pointed by Kir there must be a clear
> distinction between errors and output messages.

Well, what I was saying there should be distinction between logging and
output. But anyway...

>
> Errors should always go to stderr descriptor
> while any other messages should go to stdout
> descriptor.
>
> To achieve this a log engine was redesigned
> a bit.
>
> The messages are filtered by their type
>
>    LOG_MSG     - [stdout] plain messages, they escape any
>                           log level filtration
>    LOG_ERROR   - [stderr] error messages
>    LOG_WARN    - [strerr] warning messages
>    LOG_INFO    - [stdout] informative messages
>    LOG_DEBUG   - [stdout] debug messages
>
> By default the LOG_WARN log level is used, thus LOG_INFO
> and LOG_DEBUG messages will not appear in output stream.
>
> pr_panic helper was replaced with pr_err, pr_warning
> shorthanded to pr_warn and old printk if rather pr_msg
> now.
>
> Because we share messages between "show" and "dump" actions,
> before the "show" action proceed we need to tune up
> log level and set it to LOG_INFO.
>
> Also note that printing of VMA and siginfo now
> became LOG_INFO messages, it was not really correct
> to print them regardless the log level.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-dump.c          |    2 +-
>  cr-restore.c       |    8 ++--
>  crtools.c          |   65 +++++++++++++++---------------
>  files.c            |    4 +-
>  include/log.h      |   40 ++++++++++--------
>  include/util.h     |    7 +--
>  libnetlink.c       |    2 +-
>  log.c              |  110
++++++++++++++++++++++++++++++++++++---------------
>  parasite-syscall.c |   24 ++++++------
>  ptrace.c           |   14 +++---
>  sockets.c          |    4 +-
>  util.c             |   50 ++++++++++++------------
>  12 files changed, 188 insertions(+), 142 deletions(-)
>
> diff --git a/cr-dump.c b/cr-dump.c
> index 4b4cbe2..31de0b0 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -457,7 +457,7 @@ static int dump_task_mappings(pid_t pid, struct
list_head *vma_area_list, struct
>                                        goto err;
>                        }
>                } else {
> -                       pr_panic("Unknown VMA (pid: %d)\n", pid);
> +                       pr_err("Unknown VMA (pid: %d)\n", pid);
>                        goto err;
>                }
>        }
> diff --git a/cr-restore.c b/cr-restore.c
> index 4d281f1..dc8e791 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -195,7 +195,7 @@ static int collect_shmem(int pid, struct shmem_entry
*e)
>
>        if ((nr_shmems + 1) * sizeof(struct shmem_info) +
>                                        sizeof (struct shmems) >=
SHMEMS_SIZE) {
> -               pr_panic("OOM storing shmems\n");
> +               pr_err("OOM storing shmems\n");
>                return -1;
>        }
>
> @@ -253,7 +253,7 @@ static int collect_pipe(int pid, struct pipe_entry
*e, int p_fd)
>        }
>
>        if ((nr_pipes + 1) * sizeof(struct pipe_info) >= 4096) {
> -               pr_panic("OOM storing pipes\n");
> +               pr_err("OOM storing pipes\n");
>                return -1;
>        }
>
> @@ -1157,7 +1157,7 @@ static int restore_one_zombie(int pid, int
exit_code)
>
>                signr = exit_code & 0x7F;
>                if (!sig_fatal(signr)) {
> -                       pr_warning("Exit with non fatal signal
ignored\n");
> +                       pr_warn("Exit with non fatal signal ignored\n");
>                        signr = SIGABRT;
>                }
>
> @@ -1812,7 +1812,7 @@ static void sigreturn_restore(pid_t pid)
>        task_args->pid          = pid;
>        task_args->fd_core      = fd_core;
>        task_args->fd_self_vmas = fd_self_vmas;
> -       task_args->logfd        = get_logfd();
> +       task_args->logfd        = log_get_fd(LOG_ERROR);
>        task_args->sigchld_act  = sigchld_act;
>        task_args->fd_fdinfo    = fd_fdinfo;
>
> diff --git a/crtools.c b/crtools.c
> index fd7c707..5aed95b 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -336,7 +336,7 @@ int main(int argc, char *argv[])
>                        }
>                        break;
>                case 'o':
> -                       if (init_log(optarg))
> +                       if (log_init(optarg))
>                                return -1;
>                        log_inited = 1;
>                        break;
> @@ -368,10 +368,10 @@ int main(int argc, char *argv[])
>
>        if (log_level < 0)
>                log_level = -log_level;
> -       set_loglevel(log_level);
> +       log_set_loglevel(log_level);
>
>        if (!log_inited) {
> -               ret = init_log(NULL);
> +               ret = log_init(NULL);
>                if (ret)
>                        return ret;
>        }
> @@ -399,6 +399,7 @@ int main(int argc, char *argv[])
>                ret = cr_restore_tasks(pid, &opts);
>                break;
>        case 's':
> +               log_set_loglevel(LOG_INFO);
>                ret = cr_show(pid, &opts);
>                break;
>        default:
> @@ -409,38 +410,38 @@ int main(int argc, char *argv[])
>        return ret;
>
>  usage:
> -       printk("\nUsage:\n");
> -       printk("  %s dump [-c] -p|-t pid [-n ns]\n", argv[0]);
> -       printk("  %s restore -p|-t pid [-n ns]\n", argv[0]);
> -       printk("  %s show [-c] (-p|-t pid)|(-f file)\n", argv[0]);
> -
> -       printk("\nCommands:\n");
> -       printk("  dump           checkpoint a process identified by
pid\n");
> -       printk("  restore        restore a process identified by pid\n");
> -       printk("  show           show dump contents of a process
identified by pid\n");
> -       printk("\nGeneral parameters:\n");
> -       printk("  -p             checkpoint/restore only a single process
identified by pid\n");
> -       printk("  -t             checkpoint/restore the whole process
tree identified by pid\n");
> -       printk("  -f             show contents of a checkpoint file\n");
> -       printk("  -c             show contents of pages dumped in hexdump
format\n");
> -       printk("  -d             detach after restore\n");
> -       printk("  -s             leave tasks in stopped state after
checkpoint instead of killing them\n");
> -       printk("  -n             checkpoint/restore namespaces - values
must be separated by comma\n");
> -       printk("                 supported: uts, ipc\n");
> -
> -       printk("\nAdditional common parameters:\n");
> -       printk("  -D dir         save checkpoint files in specified
directory\n");
> -       printk("  -v [num]       set logging level\n");
> -       printk("                 0 - silent (only error messages)\n");
> -       printk("                 1 - informative (default)\n");
> -       printk("                 2 - debug\n");
> -       printk("  -vv            same as -v 1\n");
> -       printk("  -vvv           same as -v 2\n");
> -       printk("\n");
> +       pr_msg("\nUsage:\n");
> +       pr_msg("  %s dump [-c] -p|-t pid [-n ns]\n", argv[0]);
> +       pr_msg("  %s restore -p|-t pid [-n ns]\n", argv[0]);
> +       pr_msg("  %s show [-c] (-p|-t pid)|(-f file)\n", argv[0]);
> +
> +       pr_msg("\nCommands:\n");
> +       pr_msg("  dump           checkpoint a process identified by
pid\n");
> +       pr_msg("  restore        restore a process identified by pid\n");
> +       pr_msg("  show           show dump contents of a process
identified by pid\n");
> +       pr_msg("\nGeneral parameters:\n");
> +       pr_msg("  -p             checkpoint/restore only a single process
identified by pid\n");
> +       pr_msg("  -t             checkpoint/restore the whole process
tree identified by pid\n");
> +       pr_msg("  -f             show contents of a checkpoint file\n");
> +       pr_msg("  -c             show contents of pages dumped in hexdump
format\n");
> +       pr_msg("  -d             detach after restore\n");
> +       pr_msg("  -s             leave tasks in stopped state after
checkpoint instead of killing them\n");
> +       pr_msg("  -n             checkpoint/restore namespaces - values
must be separated by comma\n");
> +       pr_msg("                 supported: uts, ipc\n");
> +
> +       pr_msg("\nAdditional common parameters:\n");
> +       pr_msg("  -D dir         save checkpoint files in specified
directory\n");
> +       pr_msg("  -v [num]       set logging level\n");
> +       pr_msg("                 0 - silent (only error messages)\n");
> +       pr_msg("                 1 - informative (default)\n");
> +       pr_msg("                 2 - debug\n");
> +       pr_msg("  -vv            same as -v 1\n");
> +       pr_msg("  -vvv           same as -v 2\n");
> +       pr_msg("\n");
>
>        return -1;
>
>  opt_pid_missing:
> -       printk("No pid specified (-t or -p option missing)\n");
> +       pr_msg("No pid specified (-t or -p option missing)\n");
>        return -1;
>  }
> diff --git a/files.c b/files.c
> index 6c3d8b3..4f75047 100644
> --- a/files.c
> +++ b/files.c
> @@ -81,7 +81,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
>
>        nr_fdinfo_list++;
>        if ((nr_fdinfo_list) * sizeof(struct fdinfo_list_entry) >= 4096) {
> -               pr_panic("OOM storing fdinfo_list_entries\n");
> +               pr_err("OOM storing fdinfo_list_entries\n");
>                return -1;
>        }
>
> @@ -108,7 +108,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
>        }
>
>        if ((nr_fdinfo_descs + 1) * sizeof(struct fdinfo_desc) >= 4096) {
> -               pr_panic("OOM storing fdinfo descriptions\n");
> +               pr_err("OOM storing fdinfo descriptions\n");
>                return -1;
>        }
>
> diff --git a/include/log.h b/include/log.h
> index 3c8f678..1527746 100644
> --- a/include/log.h
> +++ b/include/log.h
> @@ -1,35 +1,39 @@
>  #ifndef LOG_H__
>  #define LOG_H__
>
> -extern int init_log(const char *name);
> -extern void fini_log(void);
> -extern int get_logfd(void);
> +extern int log_init(const char *output);
> +extern void log_fini(void);
>
> -#define LOG_ERROR      (0) /* Errors only */
> -#define LOG_WARN       (1) /* Informative */
> -#define LOG_DEBUG      (2) /* Debug ones */
> +extern void log_set_fd(unsigned int loglevel, int fd);
> +extern int log_get_fd(unsigned int loglevel);
>
> -extern void set_loglevel(unsigned int level);
> -extern void printk_level(unsigned int level, const char *format, ...)
> +extern void log_set_loglevel(unsigned int loglevel);
> +
> +extern void print_on_level(unsigned int loglevel, const char *format,
...)
>        __attribute__ ((__format__ (__printf__, 2, 3)));
>
> -#define printk(fmt, ...)       \
> -       printk_level(LOG_WARN, fmt, ##__VA_ARGS__)
> +#define LOG_MSG                (0) /* Print message regardless of log
level */
> +#define LOG_ERROR      (1) /* Errors only, when we're in trouble */
> +#define LOG_WARN       (2) /* Warnings, dazen and confused but trying to
continue */

AFAIR it's "dazed". And a comma before "but" :)

> +#define LOG_INFO       (3) /* Informative, everything is fine */
> +#define LOG_DEBUG      (4) /* Debug only */
> +
> +#define DEFAULT_LOGLEVEL       LOG_WARN
> +
> +#define pr_msg(fmt, ...)       \
> +       print_on_level(LOG_MSG,         fmt, ##__VA_ARGS__)
>
>  #define pr_info(fmt, ...)      \
> -       printk_level(LOG_WARN,  fmt, ##__VA_ARGS__)
> +       print_on_level(LOG_INFO,        fmt, ##__VA_ARGS__)
>
>  #define pr_err(fmt, ...)       \
> -       printk_level(LOG_ERROR, "Error (%s:%d): " fmt, __FILE__,
__LINE__, ##__VA_ARGS__)
> -
> -#define pr_panic(fmt, ...)     \
> -       printk_level(LOG_ERROR, "Panic (%s:%d): " fmt, __FILE__,
__LINE__, ##__VA_ARGS__)
> +       print_on_level(LOG_ERROR,       "Error (%s:%d): " fmt, __FILE__,
__LINE__, ##__VA_ARGS__)
>
> -#define pr_warning(fmt, ...)   \
> -       printk_level(LOG_WARN,  "Warn  (%s:%d): " fmt, __FILE__,
__LINE__, ##__VA_ARGS__)
> +#define pr_warn(fmt, ...)      \
> +       print_on_level(LOG_WARN,        "Warn  (%s:%d): " fmt, __FILE__,
__LINE__, ##__VA_ARGS__)
>
>  #define pr_debug(fmt, ...)     \
> -       printk_level(LOG_DEBUG, fmt, ##__VA_ARGS__)
> +       print_on_level(LOG_DEBUG,       fmt, ##__VA_ARGS__)
>
>  #define pr_perror(fmt, ...)    \
>        pr_err(fmt ": %m\n", ##__VA_ARGS__)
> diff --git a/include/util.h b/include/util.h
> index 18fc61a..0450bda 100644
> --- a/include/util.h
> +++ b/include/util.h
> @@ -131,12 +131,12 @@ static inline int read_img_buf(int fd, void *ptr,
int size)
>  #define memzero_p(p)           memset(p, 0, sizeof(*p))
>  #define memzero(p, size)       memset(p, 0, size)
>
> -extern void printk_siginfo(siginfo_t *siginfo);
> +extern void pr_info_siginfo(siginfo_t *siginfo);
>
>  struct vma_area;
>  struct list_head;
>
> -extern void printk_vma(struct vma_area *vma_area);
> +extern void pr_info_vma(struct vma_area *vma_area);
>
>  #define pr_info_vma_list(head)                                 \
>        do {                                                    \
> @@ -160,9 +160,6 @@ extern void printk_vma(struct vma_area *vma_area);
>                p__;                                            \
>        })
>
> -#define pr_info_vma(vma_area)          printk_vma(vma_area)
> -#define pr_info_siginfo(siginfo)       printk_siginfo(siginfo)
> -
>  extern int move_img_fd(int *img_fd, int want_fd);
>  extern int close_safe(int *fd);
>
> diff --git a/libnetlink.c b/libnetlink.c
> index 7e3f967..9de230e 100644
> --- a/libnetlink.c
> +++ b/libnetlink.c
> @@ -16,7 +16,7 @@ int parse_rtattr(struct rtattr *tb[], int max, struct
rtattr *rta, int len)
>                rta = RTA_NEXT(rta,len);
>        }
>        if (len)
> -               pr_warning("Trimmed RTA: len %d, rta_len %d\n", len,
rta->rta_len);
> +               pr_warn("Trimmed RTA: len %d, rta_len %d\n", len,
rta->rta_len);
>        return 0;
>  }
>
> diff --git a/log.c b/log.c
> index ba617eb..8676db0 100644
> --- a/log.c
> +++ b/log.c
> @@ -16,74 +16,118 @@
>  #include "types.h"
>  #include "util.h"
>
> -/* Note pr_ helpers rely on this descriptor! */
> -static int logfd = STDERR_FILENO;
> +static int stdout_fd = STDOUT_FILENO;
> +static int stderr_fd = STDERR_FILENO;
> +static unsigned int current_loglevel = DEFAULT_LOGLEVEL;
>
> -int get_logfd(void)
> +void log_set_fd(unsigned int loglevel, int fd)
>  {
> -       return logfd;
> +       switch (loglevel) {
> +       case LOG_ERROR:
> +       case LOG_WARN:
> +               stderr_fd = fd;
> +               break;
> +       case LOG_MSG:
> +       case LOG_INFO:
> +       case LOG_DEBUG:
> +               stdout_fd = fd;
> +               break;
> +       default:
> +               break;
> +       }
> +}
> +
> +int log_get_fd(unsigned int loglevel)
> +{
> +       switch (loglevel) {
> +       case LOG_ERROR:
> +       case LOG_WARN:
> +               return stderr_fd;
> +       case LOG_MSG:
> +       case LOG_INFO:
> +       case LOG_DEBUG:
> +               return stdout_fd;
> +       default:
> +               break;
> +       }
> +
> +       return -1;
>  }
>
> -int init_log(const char *name)
> +int log_init(const char *output)
>  {
>        struct rlimit rlimit;
> -       int fd = STDERR_FILENO;
> +       int new_stdout_fd, new_stderr_fd;
>
>        if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
> -               pr_err("can't get rlimit: %m\n");
> +               pr_perror("Can't get rlimit");
>                return -1;
>        }
>
> -       if (name) {
> -               fd = open(name, O_CREAT | O_WRONLY);
> -               if (fd == -1) {
> -                       pr_perror("Can't create log file %s", name);
> +       /*
> +        * We might need to transfer this descriptors
> +        * to another process' address space (and file
> +        * descriptors space) so we try to minimize
> +        * potential conflict between descriptors and
> +        * try to reopen them somewhere near limit.
> +        *
> +        * Still some explicit output file might be
> +        * requested.
> +        */
> +
> +       new_stdout_fd = rlimit.rlim_cur - 1;
> +       new_stderr_fd = rlimit.rlim_cur - 2;
> +
> +       if (output) {
> +               new_stdout_fd = open(output, O_CREAT | O_WRONLY);
> +               if (new_stdout_fd < 0) {
> +                       pr_perror("Can't create log file %s", output);
>                        return -1;
>                }
> +               stdout_fd = new_stdout_fd;
> +       } else {
> +               if (reopen_fd_as(new_stdout_fd, stdout_fd) < 0)
> +                       goto err;
> +               stdout_fd = new_stdout_fd;
>        }
>
> -       logfd = rlimit.rlim_cur - 1;
> -       if (reopen_fd_as(logfd, fd) < 0) {
> -               pr_err("can't duplicate descriptor %d->%d: %m\n",
> -                       fd, logfd);
> -               logfd = STDERR_FILENO;
> +       if (reopen_fd_as(new_stderr_fd, stderr_fd) < 0)
>                goto err;
> -       }
> +       stderr_fd = new_stdout_fd;
>
>        return 0;
> +
>  err:
> -       if (name)
> -               close(fd);
> +       pr_perror("Log engine failure, can't duplicate descriptor");
>        return -1;
>  }
>
> -void fini_log(void)
> +void log_fini(void)
>  {
> -       if (logfd != STDERR_FILENO &&
> -           logfd != STDIN_FILENO &&
> -           logfd != STDOUT_FILENO)
> -               close(logfd);
> +       if (stdout_fd > 2)
> +               close_safe(&stdout_fd);
> +       stdout_fd = STDOUT_FILENO;
>
> -       logfd = STDERR_FILENO;
> +       if (stderr_fd > 2)
> +               close_safe(&stderr_fd);
> +       stderr_fd = STDERR_FILENO;
>  }
>
> -static unsigned int loglevel = LOG_WARN;
> -
> -void set_loglevel(unsigned int level)
> +void log_set_loglevel(unsigned int level)
>  {
>        if (!level)
> -               loglevel = LOG_ERROR;
> +               current_loglevel = DEFAULT_LOGLEVEL;
>        else
> -               loglevel = level;
> +               current_loglevel = level;
>  }
>
> -void printk_level(unsigned int level, const char *format, ...)
> +void print_on_level(unsigned int loglevel, const char *format, ...)
>  {
>        va_list params;
>
> -       if (level <= loglevel) {
> +       if (loglevel <= current_loglevel) {
>                va_start(params, format);
> -               vdprintf(get_logfd(), format, params);
> +               vdprintf(log_get_fd(loglevel), format, params);
>                va_end(params);
>        }
>  }
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index fc04645..a860cbf 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -138,12 +138,12 @@ retry_signal:
>                 */
>
>                if (ptrace(PTRACE_SETREGS, pid, NULL, &ctl->regs_orig)) {
> -                       pr_panic("Can't set registers (pid: %d)\n", pid);
> +                       pr_err("Can't set registers (pid: %d)\n", pid);

Not for this patch, but anyway -- if ptrace() sets some sensible errno,
maybe pr_perror() would be better?

>                        goto err;
>                }
>
>                if (ptrace(PTRACE_INTERRUPT, pid, NULL, NULL)) {
> -                       pr_panic("Can't interrupt (pid: %d)\n", pid);
> +                       pr_err("Can't interrupt (pid: %d)\n", pid);

Same
>                        goto err;
>                }
>
> @@ -190,7 +190,7 @@ retry_signal:
>         * Our code is done.
>         */
>        if (ptrace(PTRACE_INTERRUPT, pid, NULL, NULL)) {
> -               pr_panic("Can't interrupt (pid: %d)\n", pid);
> +               pr_err("Can't interrupt (pid: %d)\n", pid);"
>                goto err;
>        }
>
> @@ -259,7 +259,7 @@ static int parasite_execute_by_pid(unsigned long cmd,
struct parasite_ctl *ctl,
>
>        if (ctl->pid != pid)
>                if (ptrace(PTRACE_SETREGS, pid, NULL, &regs_orig)) {
> -                       pr_panic("Can't restore registers (pid: %d)\n",
ctl->pid);
> +                       pr_err("Can't restore registers (pid: %d)\n",
ctl->pid);
>                        return -1;
>                }
>
> @@ -412,7 +412,7 @@ static int parasite_set_logfd(struct parasite_ctl
*ctl, pid_t pid)
>        parasite_status_t args = { };
>        int ret;
>
> -       ret = parasite_send_fd(ctl, get_logfd());
> +       ret = parasite_send_fd(ctl, log_get_fd(LOG_ERROR));
>        if (ret)
>                return ret;
>
> @@ -482,7 +482,7 @@ int parasite_dump_pages_seized(struct parasite_ctl
*ctl, struct list_head *vma_a
>
>        ret = parasite_execute(PARASITE_CMD_DUMPPAGES_INIT, ctl, st,
sizeof(*st));
>        if (ret < 0) {
> -               pr_panic("Dumping pages failed with %li (%li) at %li\n",
> +               pr_err("Dumping pages failed with %li (%li) at %li\n",
>                                parasite_dumppages.status.ret,
>                                parasite_dumppages.status.sys_ret,
>                                parasite_dumppages.status.line);
> @@ -514,7 +514,7 @@ int parasite_dump_pages_seized(struct parasite_ctl
*ctl, struct list_head *vma_a
>                else if (vma_area_is(vma_area, VMA_ANON_SHARED))
>                        parasite_dumppages.fd_type = PG_SHARED;
>                else {
> -                       pr_warning("Unexpected VMA area found\n");
> +                       pr_warn("Unexpected VMA area found\n");
>                        continue;
>                }
>
> @@ -522,7 +522,7 @@ int parasite_dump_pages_seized(struct parasite_ctl
*ctl, struct list_head *vma_a
>                                       (parasite_status_t *)
&parasite_dumppages,
>                                       sizeof(parasite_dumppages));
>                if (ret) {
> -                       pr_panic("Dumping pages failed with %li (%li) at
%li\n",
> +                       pr_err("Dumping pages failed with %li (%li) at
%li\n",
>                                 parasite_dumppages.status.ret,
>                                 parasite_dumppages.status.sys_ret,
>                                 parasite_dumppages.status.line);
> @@ -567,26 +567,26 @@ int parasite_cure_seized(struct parasite_ctl *ctl)
>
>        if (ctl->remote_map) {
>                if (munmap_seized(ctl, (void *)ctl->remote_map,
ctl->map_length)) {
> -                       pr_panic("munmap_seized failed (pid: %d)\n",
ctl->pid);
> +                       pr_err("munmap_seized failed (pid: %d)\n",
ctl->pid);
>                        ret = -1;
>                }
>        }
>
>        if (ctl->local_map) {
>                if (munmap(ctl->local_map, parasite_size)) {
> -                       pr_panic("munmap failed (pid: %d)\n", ctl->pid);
> +                       pr_err("munmap failed (pid: %d)\n", ctl->pid);
>                        ret = -1;
>                }
>        }
>
>        if (ptrace_poke_area(ctl->pid, (void *)ctl->code_orig,
>                             (void *)ctl->syscall_ip,
sizeof(ctl->code_orig))) {
> -               pr_panic("Can't restore syscall blob (pid: %d)\n",
ctl->pid);
> +               pr_err("Can't restore syscall blob (pid: %d)\n",
ctl->pid);
>                ret = -1;
>        }
>
>        if (ptrace(PTRACE_SETREGS, ctl->pid, NULL, &ctl->regs_orig)) {
> -               pr_panic("Can't restore registers (pid: %d)\n", ctl->pid);
> +               pr_err("Can't restore registers (pid: %d)\n", ctl->pid);
>                ret = -1;
>        }
>
> diff --git a/ptrace.c b/ptrace.c
> index ce1ed7f..748c2c4 100644
> --- a/ptrace.c
> +++ b/ptrace.c
> @@ -109,11 +109,11 @@ int ptrace_show_area_r(pid_t pid, void *addr, long
bytes)
>                else {
>                        unsigned char *c = (unsigned char *)&v;
>                        for (i = sizeof(v)/sizeof(*c); i > 0; i--)
> -                               printk("%02x ", c[i - 1]);
> -                       printk("  ");
> +                               pr_msg("%02x ", c[i - 1]);
> +                       pr_msg("  ");
>                }
>        }
> -       printk("\n");
> +       pr_msg("\n");
>        return 0;
>  err:
>        return -2;
> @@ -124,7 +124,7 @@ int ptrace_show_area(pid_t pid, void *addr, long
bytes)
>        unsigned long w, i;
>        if (bytes & (sizeof(long) - 1))
>                return -1;
> -       printk("%016lx: ", (unsigned long)addr);
> +       pr_msg("%016lx: ", (unsigned long)addr);
>        for (w = 0; w < bytes / sizeof(long); w++) {
>                unsigned long *a = addr;
>                unsigned long v;
> @@ -134,11 +134,11 @@ int ptrace_show_area(pid_t pid, void *addr, long
bytes)
>                else {
>                        unsigned char *c = (unsigned char *)&v;
>                        for (i = 0; i < sizeof(v)/sizeof(*c); i++)
> -                               printk("%02x ", c[i]);
> -                       printk("  ");
> +                               pr_msg("%02x ", c[i]);
> +                       pr_msg("  ");
>                }
>        }
> -       printk("\n");
> +       pr_msg("\n");
>        return 0;
>  err:
>        return -2;
> diff --git a/sockets.c b/sockets.c
> index 2666968..8f32ea9 100644
> --- a/sockets.c
> +++ b/sockets.c
> @@ -452,8 +452,8 @@ static int unix_collect_one(const struct
unix_diag_msg *m,
>                        struct stat st;
>
>                        if (name[0] != '/') {
> -                               pr_warning("Relative bind path '%s' "
> -                                               "unsupported\n", name);
> +                               pr_warn("Relative bind path '%s' "
> +                                       "unsupported\n", name);
>                                xfree(name);
>                                xfree(d);
>                                return 0;
> diff --git a/util.c b/util.c
> index a159416..4f84943 100644
> --- a/util.c
> +++ b/util.c
> @@ -45,41 +45,41 @@ void hex_dump(void *addr, unsigned long len)
>        len = (len + 8) & ~7;
>
>        for (i = 0; i < len; i += 8) {
> -               printk("%p: %02x %02x %02x %02x %02x %02x %02x %02x\n",
> +               pr_msg("%p: %02x %02x %02x %02x %02x %02x %02x %02x\n",
>                       &p[i], p[i+0], p[i+1], p[i+2], p[i+3],
>                       p[i+4], p[i+5], p[i+6], p[i+7]);
>        }
>  }
>
> -void printk_siginfo(siginfo_t *siginfo)
> +void pr_info_siginfo(siginfo_t *siginfo)
>  {
> -       printk("si_signo %d si_errno %d si_code %d\n",
> -              siginfo->si_signo, siginfo->si_errno, siginfo->si_code);
> +       pr_info("si_signo %d si_errno %d si_code %d\n",
> +               siginfo->si_signo, siginfo->si_errno, siginfo->si_code);
>  }
>
> -void printk_vma(struct vma_area *vma_area)
> +void pr_info_vma(struct vma_area *vma_area)
>  {
>        if (!vma_area)
>                return;
>
> -       printk("s: %16lx e: %16lx l: %4liK p: %8x f: %8x pg: %8lx "
> -              "vf: %s st: %s spc: %s\n",
> -              vma_area->vma.start, vma_area->vma.end,
> -              KBYTES(vma_area_len(vma_area)),
> -              vma_area->vma.prot,
> -              vma_area->vma.flags,
> -              vma_area->vma.pgoff,
> -              vma_area->vm_file_fd < 0 ? "n" : "y",
> -              !vma_area->vma.status ? "--" :
> -              ((vma_area->vma.status & VMA_FILE_PRIVATE) ? "FP" :
> -               ((vma_area->vma.status & VMA_FILE_SHARED) ? "FS" :
> -                ((vma_area->vma.status & VMA_ANON_SHARED) ? "AS" :
> -                 ((vma_area->vma.status & VMA_ANON_PRIVATE) ? "AP" :
"--")))),
> -              !vma_area->vma.status ? "--" :
> -              ((vma_area->vma.status & VMA_AREA_STACK) ? "stack" :
> -               ((vma_area->vma.status & VMA_AREA_HEAP) ? "heap" :
> -                ((vma_area->vma.status & VMA_AREA_VSYSCALL) ? "vsyscall"
:
> -                 ((vma_area->vma.status & VMA_AREA_VDSO) ? "vdso" :
"n")))));
> +       pr_info("s: %16lx e: %16lx l: %4liK p: %8x f: %8x pg: %8lx "
> +               "vf: %s st: %s spc: %s\n",
> +               vma_area->vma.start, vma_area->vma.end,
> +               KBYTES(vma_area_len(vma_area)),
> +               vma_area->vma.prot,
> +               vma_area->vma.flags,
> +               vma_area->vma.pgoff,
> +               vma_area->vm_file_fd < 0 ? "n" : "y",
> +               !vma_area->vma.status ? "--" :
> +               ((vma_area->vma.status & VMA_FILE_PRIVATE) ? "FP" :
> +                ((vma_area->vma.status & VMA_FILE_SHARED) ? "FS" :
> +                 ((vma_area->vma.status & VMA_ANON_SHARED) ? "AS" :
> +                  ((vma_area->vma.status & VMA_ANON_PRIVATE) ? "AP" :
"--")))),
> +               !vma_area->vma.status ? "--" :
> +               ((vma_area->vma.status & VMA_AREA_STACK) ? "stack" :
> +                ((vma_area->vma.status & VMA_AREA_HEAP) ? "heap" :
> +                 ((vma_area->vma.status & VMA_AREA_VSYSCALL) ?
"vsyscall" :
> +                  ((vma_area->vma.status & VMA_AREA_VDSO) ? "vdso" :
"n")))));
>  }
>
>  int close_safe(int *fd)
> @@ -108,7 +108,7 @@ int reopen_fd_as_safe(int new_fd, int old_fd, bool
allow_reuse_fd)
>                                        /*
>                                         * Standard descriptors.
>                                         */
> -                                       pr_warning("fd %d already in
use\n", new_fd);
> +                                       pr_warn("fd %d already in use\n",
new_fd);
>                                } else {
>                                        pr_err("fd %d already in use\n",
new_fd);
>                                        return -1;
> @@ -171,7 +171,7 @@ int open_image_ro_nocheck(const char *fmt, int pid)
>        if (tmp == 0)
>                tmp = open(path, O_RDONLY);
>        if (tmp < 0)
> -               pr_warning("Can't open image %s for %d: %m\n", fmt, pid);
> +               pr_warn("Can't open image %s for %d: %m\n", fmt, pid);
>
>        return tmp;
>  }
> --
> 1.7.7.6
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://openvz.org/mailman/listinfo/criu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openvz.org/pipermail/criu/attachments/20120229/2027f237/attachment-0001.html


More information about the CRIU mailing list