Looks reasonable to me.
On Thu, Mar 31, 2011 at 4:31 PM, Ben Pfaff <[email protected]> wrote: > If a daemon doesn't start, we need to know why. Being able to > consistently consult the log to find out is helpful. > --- > lib/command-line.c | 19 +++++++++++-------- > lib/daemon.c | 13 ++++++------- > lib/entropy.c | 5 +++-- > lib/fatal-signal.c | 13 +++++-------- > lib/process.c | 22 +++++++--------------- > lib/random.c | 7 +++---- > lib/signals.c | 30 +++++++++++++++++++++++------- > lib/signals.h | 6 +++++- > lib/socket-util.c | 7 +++++++ > lib/socket-util.h | 4 +++- > lib/timeval.c | 25 ++++++++++++++----------- > lib/timeval.h | 4 +++- > lib/uuid.c | 7 +++---- > lib/vlog.c | 27 ++++++++++++++++++++++++++- > lib/vlog.h | 13 ++++++++++++- > tests/test-timeval.c | 4 ++-- > utilities/ovs-ofctl.c | 8 ++++---- > utilities/ovs-openflowd.c | 44 ++++++++++++++++++++++++-------------------- > vswitchd/ovs-brcompatd.c | 18 ++++++++++-------- > vswitchd/ovs-vswitchd.c | 4 ++-- > 20 files changed, 173 insertions(+), 107 deletions(-) > > diff --git a/lib/command-line.c b/lib/command-line.c > index 23ed53f..9adf47f 100644 > --- a/lib/command-line.c > +++ b/lib/command-line.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -20,6 +20,9 @@ > #include <limits.h> > #include <stdlib.h> > #include "util.h" > +#include "vlog.h" > + > +VLOG_DEFINE_THIS_MODULE(command_line); > > /* Given the GNU-style long options in 'options', returns a string that may > be > * passed to getopt() with the corresponding short options. The caller is > @@ -66,25 +69,25 @@ run_command(int argc, char *argv[], const struct command > commands[]) > if (!strcmp(p->name, argv[0])) { > int n_arg = argc - 1; > if (n_arg < p->min_args) { > - ovs_fatal(0, "'%s' command requires at least %d arguments", > - p->name, p->min_args); > + VLOG_FATAL( "'%s' command requires at least %d arguments", > + p->name, p->min_args); > } else if (n_arg > p->max_args) { > - ovs_fatal(0, "'%s' command takes at most %d arguments", > - p->name, p->max_args); > + VLOG_FATAL("'%s' command takes at most %d arguments", > + p->name, p->max_args); > } else { > p->handler(argc, argv); > if (ferror(stdout)) { > - ovs_fatal(0, "write to stdout failed"); > + VLOG_FATAL("write to stdout failed"); > } > if (ferror(stderr)) { > - ovs_fatal(0, "write to stderr failed"); > + VLOG_FATAL("write to stderr failed"); > } > return; > } > } > } > > - ovs_fatal(0, "unknown command '%s'; use --help for help", argv[0]); > + VLOG_FATAL("unknown command '%s'; use --help for help", argv[0]); > } > > /* Process title. */ > diff --git a/lib/daemon.c b/lib/daemon.c > index cb440d1..64e2f9e 100644 > --- a/lib/daemon.c > +++ b/lib/daemon.c > @@ -239,9 +239,7 @@ fork_and_wait_for_startup(int *fdp) > int fds[2]; > pid_t pid; > > - if (pipe(fds) < 0) { > - ovs_fatal(errno, "pipe failed"); > - } > + xpipe(fds); > > pid = fork(); > if (pid > 0) { > @@ -266,7 +264,8 @@ fork_and_wait_for_startup(int *fdp) > exit(WEXITSTATUS(status)); > } > > - ovs_fatal(errno, "fork child failed to signal startup"); > + VLOG_FATAL("fork child failed to signal startup (%s)", > + strerror(errno)); > } > close(fds[0]); > *fdp = -1; > @@ -277,7 +276,7 @@ fork_and_wait_for_startup(int *fdp) > lockfile_postfork(); > *fdp = fds[1]; > } else { > - ovs_fatal(errno, "could not fork"); > + VLOG_FATAL("fork failed (%s)", strerror(errno)); > } > > return pid; > @@ -292,7 +291,7 @@ fork_notify_startup(int fd) > > error = write_fully(fd, "", 1, &bytes_written); > if (error) { > - ovs_fatal(error, "could not write to pipe"); > + VLOG_FATAL("pipe write failed (%s)", strerror(error)); > } > > close(fd); > @@ -346,7 +345,7 @@ monitor_daemon(pid_t daemon_pid) > } while (retval == -1 && errno == EINTR); > > if (retval == -1) { > - ovs_fatal(errno, "waitpid failed"); > + VLOG_FATAL("waitpid failed (%s)", strerror(errno)); > } else if (retval == daemon_pid) { > char *s = process_status_msg(status); > if (should_restart(status)) { > diff --git a/lib/entropy.c b/lib/entropy.c > index 1f1af50..f38655c 100644 > --- a/lib/entropy.c > +++ b/lib/entropy.c > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2008, 2009, 2010 Nicira Networks > +/* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -59,6 +59,7 @@ get_entropy_or_die(void *buffer, size_t n) > { > int error = get_entropy(buffer, n); > if (error) { > - ovs_fatal(error, "%s: read error", urandom); > + VLOG_FATAL("%s: read error (%s)", > + urandom, ovs_retval_to_string(error)); > } > } > diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c > index 81f8f28..58ac4f0 100644 > --- a/lib/fatal-signal.c > +++ b/lib/fatal-signal.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -26,6 +26,7 @@ > #include <unistd.h> > #include "poll-loop.h" > #include "shash.h" > +#include "signals.h" > #include "socket-util.h" > #include "util.h" > #include "vlog.h" > @@ -66,9 +67,7 @@ fatal_signal_init(void) > > inited = true; > > - if (pipe(signal_fds)) { > - ovs_fatal(errno, "could not create pipe"); > - } > + xpipe(signal_fds); > set_nonblocking(signal_fds[0]); > set_nonblocking(signal_fds[1]); > > @@ -78,12 +77,10 @@ fatal_signal_init(void) > struct sigaction old_sa; > > sigaddset(&fatal_signal_set, sig_nr); > - if (sigaction(sig_nr, NULL, &old_sa)) { > - ovs_fatal(errno, "sigaction"); > - } > + xsigaction(sig_nr, NULL, &old_sa); > if (old_sa.sa_handler == SIG_DFL > && signal(sig_nr, fatal_signal_handler) == SIG_ERR) { > - ovs_fatal(errno, "signal"); > + VLOG_FATAL("signal failed (%s)", strerror(errno)); > } > } > atexit(atexit_handler); > diff --git a/lib/process.c b/lib/process.c > index f772833..55092f5 100644 > --- a/lib/process.c > +++ b/lib/process.c > @@ -82,9 +82,7 @@ process_init(void) > inited = true; > > /* Create notification pipe. */ > - if (pipe(fds)) { > - ovs_fatal(errno, "could not create pipe"); > - } > + xpipe(fds); > set_nonblocking(fds[0]); > set_nonblocking(fds[1]); > > @@ -93,9 +91,7 @@ process_init(void) > sa.sa_handler = sigchld_handler; > sigemptyset(&sa.sa_mask); > sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; > - if (sigaction(SIGCHLD, &sa, NULL)) { > - ovs_fatal(errno, "sigaction(SIGCHLD) failed"); > - } > + xsigaction(SIGCHLD, &sa, NULL); > } > > char * > @@ -638,9 +634,8 @@ static bool > sigchld_is_blocked(void) > { > sigset_t sigs; > - if (sigprocmask(SIG_SETMASK, NULL, &sigs)) { > - ovs_fatal(errno, "sigprocmask"); > - } > + > + xsigprocmask(SIG_SETMASK, NULL, &sigs); > return sigismember(&sigs, SIGCHLD); > } > > @@ -648,17 +643,14 @@ static void > block_sigchld(sigset_t *oldsigs) > { > sigset_t sigchld; > + > sigemptyset(&sigchld); > sigaddset(&sigchld, SIGCHLD); > - if (sigprocmask(SIG_BLOCK, &sigchld, oldsigs)) { > - ovs_fatal(errno, "sigprocmask"); > - } > + xsigprocmask(SIG_BLOCK, &sigchld, oldsigs); > } > > static void > unblock_sigchld(const sigset_t *oldsigs) > { > - if (sigprocmask(SIG_SETMASK, oldsigs, NULL)) { > - ovs_fatal(errno, "sigprocmask"); > - } > + xsigprocmask(SIG_SETMASK, oldsigs, NULL); > } > diff --git a/lib/random.c b/lib/random.c > index 6b02446..a802bc7 100644 > --- a/lib/random.c > +++ b/lib/random.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -23,6 +23,7 @@ > #include <sys/time.h> > > #include "entropy.h" > +#include "timeval.h" > #include "util.h" > > /* This is the 32-bit PRNG recommended in G. Marsaglia, "Xorshift RNGs", > @@ -48,9 +49,7 @@ random_init(void) > struct timeval tv; > uint32_t entropy; > > - if (gettimeofday(&tv, NULL) < 0) { > - ovs_fatal(errno, "gettimeofday"); > - } > + xgettimeofday(&tv); > get_entropy_or_die(&entropy, 4); > > seed = tv.tv_sec ^ tv.tv_usec ^ entropy; > diff --git a/lib/signals.c b/lib/signals.c > index b5bacea..37f0637 100644 > --- a/lib/signals.c > +++ b/lib/signals.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009 Nicira Networks. > + * Copyright (c) 2008, 2009, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -25,6 +25,9 @@ > #include "socket-util.h" > #include "type-props.h" > #include "util.h" > +#include "vlog.h" > + > +VLOG_DEFINE_THIS_MODULE(signals); > > #if defined(_NSIG) > #define N_SIGNALS _NSIG > @@ -58,9 +61,7 @@ signal_init(void) > static bool inited; > if (!inited) { > inited = true; > - if (pipe(fds)) { > - ovs_fatal(errno, "could not create pipe"); > - } > + xpipe(fds); > set_nonblocking(fds[0]); > set_nonblocking(fds[1]); > } > @@ -83,9 +84,7 @@ signal_register(int signr) > sa.sa_handler = signal_handler; > sigemptyset(&sa.sa_mask); > sa.sa_flags = SA_RESTART; > - if (sigaction(signr, &sa, NULL)) { > - ovs_fatal(errno, "sigaction(%d) failed", signr); > - } > + xsigaction(signr, &sa, NULL); > > /* Return structure. */ > s = xmalloc(sizeof *s); > @@ -148,3 +147,20 @@ signal_name(int signum) > } > return name; > } > + > +void > +xsigaction(int signum, const struct sigaction *new, struct sigaction *old) > +{ > + if (sigaction(signum, new, old)) { > + VLOG_FATAL("sigaction(%s) failed (%s)", > + signal_name(signum), strerror(errno)); > + } > +} > + > +void > +xsigprocmask(int how, const sigset_t *new, sigset_t *old) > +{ > + if (sigprocmask(how, new, old)) { > + VLOG_FATAL("sigprocmask failed (%s)", strerror(errno)); > + } > +} > diff --git a/lib/signals.h b/lib/signals.h > index 41066c4..12fb311 100644 > --- a/lib/signals.h > +++ b/lib/signals.h > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008 Nicira Networks. > + * Copyright (c) 2008, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -17,6 +17,7 @@ > #ifndef SIGNALS_H > #define SIGNALS_H 1 > > +#include <signal.h> > #include <stdbool.h> > > void signal_init(void); > @@ -26,4 +27,7 @@ void signal_wait(struct signal *); > > const char *signal_name(int signum); > > +void xsigaction(int signum, const struct sigaction *, struct sigaction *old); > +void xsigprocmask(int how, const sigset_t *, sigset_t *old); > + > #endif /* signals.h */ > diff --git a/lib/socket-util.c b/lib/socket-util.c > index e0f34e7..12bbc71 100644 > --- a/lib/socket-util.c > +++ b/lib/socket-util.c > @@ -767,3 +767,10 @@ get_mtime(const char *file_name, struct timespec *mtime) > } > } > > +void > +xpipe(int fds[2]) > +{ > + if (pipe(fds)) { > + VLOG_FATAL("failed to create pipe (%s)", strerror(errno)); > + } > +} > diff --git a/lib/socket-util.h b/lib/socket-util.h > index f4e617a..8c5af39 100644 > --- a/lib/socket-util.h > +++ b/lib/socket-util.h > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -48,4 +48,6 @@ int write_fully(int fd, const void *, size_t, size_t > *bytes_written); > int fsync_parent_dir(const char *file_name); > int get_mtime(const char *file_name, struct timespec *mtime); > > +void xpipe(int fds[2]); > + > #endif /* socket-util.h */ > diff --git a/lib/timeval.c b/lib/timeval.c > index 84c90f3..099730e 100644 > --- a/lib/timeval.c > +++ b/lib/timeval.c > @@ -26,6 +26,7 @@ > #include <unistd.h> > #include "coverage.h" > #include "fatal-signal.h" > +#include "signals.h" > #include "util.h" > #include "vlog.h" > > @@ -96,9 +97,7 @@ set_up_signal(int flags) > sa.sa_handler = sigalrm_handler; > sigemptyset(&sa.sa_mask); > sa.sa_flags = flags; > - if (sigaction(SIGALRM, &sa, NULL)) { > - ovs_fatal(errno, "sigaction(SIGALRM) failed"); > - } > + xsigaction(SIGALRM, &sa, NULL); > } > > /* Remove SA_RESTART from the flags for SIGALRM, so that any system call that > @@ -137,7 +136,7 @@ set_up_timer(void) > struct itimerspec itimer; > > if (timer_create(monotonic_clock, NULL, &timer_id)) { > - ovs_fatal(errno, "timer_create failed"); > + VLOG_FATAL("timer_create failed (%s)", strerror(errno)); > } > > itimer.it_interval.tv_sec = 0; > @@ -145,7 +144,7 @@ set_up_timer(void) > itimer.it_value = itimer.it_interval; > > if (timer_settime(timer_id, 0, &itimer, NULL)) { > - ovs_fatal(errno, "timer_settime failed"); > + VLOG_FATAL("timer_settime failed (%s)", strerror(errno)); > } > } > > @@ -364,17 +363,13 @@ block_sigalrm(sigset_t *oldsigs) > sigset_t sigalrm; > sigemptyset(&sigalrm); > sigaddset(&sigalrm, SIGALRM); > - if (sigprocmask(SIG_BLOCK, &sigalrm, oldsigs)) { > - ovs_fatal(errno, "sigprocmask"); > - } > + xsigprocmask(SIG_BLOCK, &sigalrm, oldsigs); > } > > static void > unblock_sigalrm(const sigset_t *oldsigs) > { > - if (sigprocmask(SIG_SETMASK, oldsigs, NULL)) { > - ovs_fatal(errno, "sigprocmask"); > - } > + xsigprocmask(SIG_SETMASK, oldsigs, NULL); > } > > long long int > @@ -389,6 +384,14 @@ timeval_to_msec(const struct timeval *tv) > return (long long int) tv->tv_sec * 1000 + tv->tv_usec / 1000; > } > > +void > +xgettimeofday(struct timeval *tv) > +{ > + if (gettimeofday(tv, NULL) == -1) { > + VLOG_FATAL("gettimeofday failed (%s)", strerror(errno)); > + } > +} > + > static long long int > timeval_diff_msec(const struct timeval *a, const struct timeval *b) > { > diff --git a/lib/timeval.h b/lib/timeval.h > index 9040233..303461a 100644 > --- a/lib/timeval.h > +++ b/lib/timeval.h > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -60,6 +60,8 @@ int time_poll(struct pollfd *, int n_pollfds, int timeout); > long long int timespec_to_msec(const struct timespec *); > long long int timeval_to_msec(const struct timeval *); > > +void xgettimeofday(struct timeval *); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/uuid.c b/lib/uuid.c > index e259024..8b02bf5 100644 > --- a/lib/uuid.c > +++ b/lib/uuid.c > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2008, 2009, 2010 Nicira Networks > +/* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -27,6 +27,7 @@ > #include "aes128.h" > #include "entropy.h" > #include "sha1.h" > +#include "timeval.h" > #include "util.h" > > static struct aes128 key; > @@ -212,9 +213,7 @@ do_init(void) > > /* Get seed data. */ > get_entropy_or_die(random_seed, sizeof random_seed); > - if (gettimeofday(&now, NULL)) { > - ovs_fatal(errno, "gettimeofday failed"); > - } > + xgettimeofday(&now); > pid = getpid(); > ppid = getppid(); > uid = getuid(); > diff --git a/lib/vlog.c b/lib/vlog.c > index 2598111..4f6523f 100644 > --- a/lib/vlog.c > +++ b/lib/vlog.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2008, 2009, 2010 Nicira Networks. > + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -680,6 +680,31 @@ vlog(const struct vlog_module *module, enum vlog_level > level, > va_end(args); > } > > +void > +vlog_fatal_valist(const struct vlog_module *module_, enum vlog_level level, > + const char *message, va_list args) > +{ > + struct vlog_module *module = (struct vlog_module *) module_; > + > + /* Don't log this message to the console to avoid redundancy with the > + * message written by the later ovs_fatal_valist(). */ > + module->levels[VLF_CONSOLE] = VLL_EMER; > + > + vlog_valist(module, level, message, args); > + ovs_fatal_valist(0, message, args); > +} > + > +void > +vlog_fatal(const struct vlog_module *module, enum vlog_level level, > + const char *message, ...) > +{ > + va_list args; > + > + va_start(args, message); > + vlog_fatal_valist(module, level, message, args); > + va_end(args); > +} > + > bool > vlog_should_drop(const struct vlog_module *module, enum vlog_level level, > struct vlog_rate_limit *rl) > diff --git a/lib/vlog.h b/lib/vlog.h > index 00d324f..d982db2 100644 > --- a/lib/vlog.h > +++ b/lib/vlog.h > @@ -149,14 +149,24 @@ const char *vlog_get_log_file(void); > int vlog_set_log_file(const char *file_name); > int vlog_reopen_log_file(void); > > -/* Function for actual logging. */ > +/* Initialization. */ > void vlog_init(void); > void vlog_exit(void); > + > +/* Functions for actual logging. */ > void vlog(const struct vlog_module *, enum vlog_level, const char *format, > ...) > PRINTF_FORMAT (3, 4); > void vlog_valist(const struct vlog_module *, enum vlog_level, > const char *, va_list) > PRINTF_FORMAT (3, 0); > + > +void vlog_fatal(const struct vlog_module *, enum vlog_level, > + const char *format, ...) > + PRINTF_FORMAT (3, 4) NO_RETURN; > +void vlog_fatal_valist(const struct vlog_module *, enum vlog_level, > + const char *, va_list) > + PRINTF_FORMAT (3, 0) NO_RETURN; > + > void vlog_rate_limit(const struct vlog_module *, enum vlog_level, > struct vlog_rate_limit *, const char *, ...) > PRINTF_FORMAT (4, 5); > @@ -174,6 +184,7 @@ void vlog_rate_limit(const struct vlog_module *, enum > vlog_level, > * > * Guaranteed to preserve errno. > */ > +#define VLOG_FATAL(...) vlog_fatal(THIS_MODULE, VLL_ERR, __VA_ARGS__) > #define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__) > #define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__) > #define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__) > diff --git a/tests/test-timeval.c b/tests/test-timeval.c > index 99a600b..442b27a 100644 > --- a/tests/test-timeval.c > +++ b/tests/test-timeval.c > @@ -1,5 +1,5 @@ > /* > - * Copyright (c) 2009, 2010 Nicira Networks. > + * Copyright (c) 2009, 2010, 2011 Nicira Networks. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -37,7 +37,7 @@ gettimeofday_in_msec(void) > { > struct timeval tv; > > - assert(!gettimeofday(&tv, NULL)); > + xgettimeofday(&tv); > return timeval_to_msec(&tv); > } > > diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c > index e8479fc..9d9ff7a 100644 > --- a/utilities/ovs-ofctl.c > +++ b/utilities/ovs-ofctl.c > @@ -827,9 +827,9 @@ do_ping(int argc, char *argv[]) > OFPT_ECHO_REQUEST, &request); > random_bytes(rq_hdr + 1, payload); > > - gettimeofday(&start, NULL); > + xgettimeofday(&start); > run(vconn_transact(vconn, ofpbuf_clone(request), &reply), "transact"); > - gettimeofday(&end, NULL); > + xgettimeofday(&end); > > rpy_hdr = reply->data; > if (reply->size != request->size > @@ -874,7 +874,7 @@ do_benchmark(int argc OVS_UNUSED, char *argv[]) > count, message_size, count * message_size); > > open_vconn(argv[1], &vconn); > - gettimeofday(&start, NULL); > + xgettimeofday(&start); > for (i = 0; i < count; i++) { > struct ofpbuf *request, *reply; > struct ofp_header *rq_hdr; > @@ -884,7 +884,7 @@ do_benchmark(int argc OVS_UNUSED, char *argv[]) > run(vconn_transact(vconn, request, &reply), "transact"); > ofpbuf_delete(reply); > } > - gettimeofday(&end, NULL); > + xgettimeofday(&end); > vconn_close(vconn); > > duration = ((1000*(double)(end.tv_sec - start.tv_sec)) > diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c > index d2e0336..1494209 100644 > --- a/utilities/ovs-openflowd.c > +++ b/utilities/ovs-openflowd.c > @@ -119,7 +119,7 @@ main(int argc, char *argv[]) > > error = dpif_create_and_open(s.dp_name, s.dp_type, &dpif); > if (error) { > - ovs_fatal(error, "could not create datapath"); > + VLOG_FATAL("could not create datapath (%s)", strerror(error)); > } > > /* Add ports to the datapath if requested by the user. */ > @@ -132,12 +132,14 @@ main(int argc, char *argv[]) > > error = netdev_open_default(port, &netdev); > if (error) { > - ovs_fatal(error, "%s: failed to open network device", port); > + VLOG_FATAL("%s: failed to open network device (%s)", > + port, strerror(error)); > } > > error = dpif_port_add(dpif, netdev, NULL); > if (error) { > - ovs_fatal(error, "failed to add %s as a port", port); > + VLOG_FATAL("failed to add %s as a port (%s)", > + port, strerror(error)); > } > > netdev_close(netdev); > @@ -147,7 +149,8 @@ main(int argc, char *argv[]) > /* Start OpenFlow processing. */ > error = ofproto_create(s.dp_name, s.dp_type, NULL, NULL, &ofproto); > if (error) { > - ovs_fatal(error, "could not initialize openflow switch"); > + VLOG_FATAL("could not initialize openflow switch (%s)", > + strerror(error)); > } > if (s.datapath_id) { > ofproto_set_datapath_id(ofproto, s.datapath_id); > @@ -156,14 +159,15 @@ main(int argc, char *argv[]) > s.serial_desc, s.dp_desc); > error = ofproto_set_snoops(ofproto, &s.snoops); > if (error) { > - ovs_fatal(error, > - "failed to configure controller snooping connections"); > + VLOG_FATAL("failed to configure controller snooping connections > (%s)", > + strerror(error)); > } > memset(&nf_options, 0, sizeof nf_options); > nf_options.collectors = s.netflow; > error = ofproto_set_netflow(ofproto, &nf_options); > if (error) { > - ovs_fatal(error, "failed to configure NetFlow collectors"); > + VLOG_FATAL("failed to configure NetFlow collectors (%s)", > + strerror(error)); > } > ofproto_set_controllers(ofproto, s.controllers, s.n_controllers); > ofproto_set_fail_mode(ofproto, s.fail_mode); > @@ -174,7 +178,7 @@ main(int argc, char *argv[]) > while (!exiting && (s.run_forever || ofproto_is_alive(ofproto))) { > error = ofproto_run(ofproto); > if (error) { > - ovs_fatal(error, "unrecoverable datapath error"); > + VLOG_FATAL("unrecoverable datapath error (%s)", strerror(error)); > } > unixctl_server_run(unixctl); > dp_run(); > @@ -306,8 +310,8 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > switch (c) { > case OPT_DATAPATH_ID: > if (!dpid_from_string(optarg, &s->datapath_id)) { > - ovs_fatal(0, "argument to --datapath-id must be " > - "exactly 16 hex digits and may not be all-zero"); > + VLOG_FATAL("argument to --datapath-id must be exactly 16 hex > " > + "digits and may not be all-zero"); > } > break; > > @@ -338,15 +342,15 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > || !strcmp(optarg, "secure")) { > s->fail_mode = OFPROTO_FAIL_SECURE; > } else { > - ovs_fatal(0, "--fail argument must be \"standalone\" " > - "or \"secure\""); > + VLOG_FATAL("--fail argument must be \"standalone\" " > + "or \"secure\""); > } > break; > > case OPT_INACTIVITY_PROBE: > controller_opts.probe_interval = atoi(optarg); > if (controller_opts.probe_interval < 5) { > - ovs_fatal(0, "--inactivity-probe argument must be at least > 5"); > + VLOG_FATAL("--inactivity-probe argument must be at least 5"); > } > break; > > @@ -356,8 +360,8 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > } else { > s->max_idle = atoi(optarg); > if (s->max_idle < 1 || s->max_idle > 65535) { > - ovs_fatal(0, "--max-idle argument must be between 1 and " > - "65535 or the word 'permanent'"); > + VLOG_FATAL("--max-idle argument must be between 1 and " > + "65535 or the word 'permanent'"); > } > } > break; > @@ -365,7 +369,7 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > case OPT_MAX_BACKOFF: > controller_opts.max_backoff = atoi(optarg); > if (controller_opts.max_backoff < 1) { > - ovs_fatal(0, "--max-backoff argument must be at least 1"); > + VLOG_FATAL("--max-backoff argument must be at least 1"); > } else if (controller_opts.max_backoff > 3600) { > controller_opts.max_backoff = 3600; > } > @@ -375,7 +379,7 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > if (optarg) { > controller_opts.rate_limit = atoi(optarg); > if (controller_opts.rate_limit < 1) { > - ovs_fatal(0, "--rate-limit argument must be at least 1"); > + VLOG_FATAL("--rate-limit argument must be at least 1"); > } > } else { > controller_opts.rate_limit = 1000; > @@ -385,7 +389,7 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > case OPT_BURST_LIMIT: > controller_opts.burst_limit = atoi(optarg); > if (controller_opts.burst_limit < 1) { > - ovs_fatal(0, "--burst-limit argument must be at least 1"); > + VLOG_FATAL("--burst-limit argument must be at least 1"); > } > break; > > @@ -454,8 +458,8 @@ parse_options(int argc, char *argv[], struct ofsettings > *s) > argc -= optind; > argv += optind; > if (argc < 2) { > - ovs_fatal(0, "need at least two non-option arguments; " > - "use --help for usage"); > + VLOG_FATAL("need at least two non-option arguments; " > + "use --help for usage"); > } > > /* Rate limiting. */ > diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c > index f874a4d..7b341aa 100644 > --- a/vswitchd/ovs-brcompatd.c > +++ b/vswitchd/ovs-brcompatd.c > @@ -1304,8 +1304,8 @@ main(int argc, char *argv[]) > } > > if (brc_open(&brc_sock)) { > - ovs_fatal(0, "could not open brcompat socket. Check " > - "\"brcompat\" kernel module."); > + VLOG_FATAL("could not open brcompat socket. Check " > + "\"brcompat\" kernel module."); > } > > if (prune_timeout) { > @@ -1313,12 +1313,14 @@ main(int argc, char *argv[]) > > error = nl_sock_create(NETLINK_ROUTE, &rtnl_sock); > if (error) { > - ovs_fatal(error, "could not create rtnetlink socket"); > + VLOG_FATAL("could not create rtnetlink socket (%s)", > + strerror(error)); > } > > error = nl_sock_join_mcgroup(rtnl_sock, RTNLGRP_LINK); > if (error) { > - ovs_fatal(error, "could not join RTNLGRP_LINK multicast group"); > + VLOG_FATAL("could not join RTNLGRP_LINK multicast group (%s)", > + strerror(error)); > } > } > > @@ -1384,11 +1386,11 @@ validate_appctl_command(void) > } else if (p[1] == 's') { > n++; > } else { > - ovs_fatal(0, "only '%%s' and '%%%%' allowed in > --appctl-command"); > + VLOG_FATAL("only '%%s' and '%%%%' allowed in --appctl-command"); > } > } > if (n != 1) { > - ovs_fatal(0, "'%%s' must appear exactly once in --appctl-command"); > + VLOG_FATAL("'%%s' must appear exactly once in --appctl-command"); > } > } > > @@ -1459,8 +1461,8 @@ parse_options(int argc, char *argv[]) > argv += optind; > > if (argc != 1) { > - ovs_fatal(0, "database socket is non-option argument; " > - "use --help for usage"); > + VLOG_FATAL("database socket is non-option argument; " > + "use --help for usage"); > } > > return argv[0]; > diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c > index 1303e08..bae03dd 100644 > --- a/vswitchd/ovs-vswitchd.c > +++ b/vswitchd/ovs-vswitchd.c > @@ -199,8 +199,8 @@ parse_options(int argc, char *argv[]) > argv += optind; > > if (argc != 1) { > - ovs_fatal(0, "database socket is only non-option argument; " > - "use --help for usage"); > + VLOG_FATAL("database socket is only non-option argument; " > + "use --help for usage"); > } > > return argv[0]; > -- > 1.7.1 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
