diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-06 17:02:25 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-07 09:46:25 +0800 |
commit | 4fee70ab7c67e268eff0ba16b42a71d36c11e727 (patch) | |
tree | a673d1401f330da37ac7b33e57b2019bfe5f72fa | |
parent | b12d51994790ef2896d99f24b0bfb3e20a4f0912 (diff) | |
download | talos-petitboot-4fee70ab7c67e268eff0ba16b42a71d36c11e727.tar.gz talos-petitboot-4fee70ab7c67e268eff0ba16b42a71d36c11e727.zip |
discover/user-event: better event debugging output
We don't currently handle conf events very well:
user_event remove event:
device: /net/eth0
name => (null)
image => (null)
args => (null)
This change prints the event action properly, and prints all event
params.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | discover/parser.c | 4 | ||||
-rw-r--r-- | discover/user-event.c | 28 |
2 files changed, 22 insertions, 10 deletions
diff --git a/discover/parser.c b/discover/parser.c index 42ee2e5..11728b7 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -142,8 +142,10 @@ void iterate_parsers(struct discover_context *ctx, enum conf_method method) case CONF_METHOD_DHCP: rc = download_config(ctx, &buf, &len); - if (rc) + if (rc) { + pb_log("\tdownload failed, aborting\n"); return; + } for (i = 0; i < n_parsers; i++) { if (parsers[i]->method != method) diff --git a/discover/user-event.c b/discover/user-event.c index db12bd1..23842e1 100644 --- a/discover/user-event.c +++ b/discover/user-event.c @@ -42,22 +42,32 @@ struct user_event { int socket; }; +static const char *event_action_name(enum event_action action) +{ + switch (action) { + case EVENT_ACTION_ADD: + return "add"; + case EVENT_ACTION_REMOVE: + return "remove"; + case EVENT_ACTION_CONF: + return "conf"; + default: + break; + } + + return "unknown"; +} + static void user_event_print_event(struct event __attribute__((unused)) *event) { - const char *action, *params[] = { - "name", "image", "args", - NULL, - }; int i; - action = event->action == EVENT_ACTION_ADD ? "add" : "remove"; - - pb_log("user_event %s event:\n", action); + pb_log("user_event %s event:\n", event_action_name(event->action)); pb_log("\tdevice: %s\n", event->device); - for (i = 0; params[i]; i++) + for (i = 0; i < event->n_params; i++) pb_log("\t%-12s => %s\n", - params[i], event_get_param(event, params[i])); + event->params[i].name, event->params[i].value); } static void user_event_handle_message(struct user_event *uev, char *buf, |