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>
case CONF_METHOD_DHCP:
rc = download_config(ctx, &buf, &len);
case CONF_METHOD_DHCP:
rc = download_config(ctx, &buf, &len);
+ if (rc) {
+ pb_log("\tdownload failed, aborting\n");
for (i = 0; i < n_parsers; i++) {
if (parsers[i]->method != method)
for (i = 0; i < n_parsers; i++) {
if (parsers[i]->method != method)
+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)
{
static void user_event_print_event(struct event __attribute__((unused)) *event)
{
- const char *action, *params[] = {
- "name", "image", "args",
- NULL,
- };
- 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);
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",
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,
}
static void user_event_handle_message(struct user_event *uev, char *buf,