summaryrefslogtreecommitdiffstats
path: root/discover/user-event.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-07-26 15:45:37 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-08-08 13:52:50 +1000
commit83a587b79e9a5a5279f1c7a26918fc8c08523a7f (patch)
tree353a9aff1c1207d3dcb44832606cbc5088218d42 /discover/user-event.c
parent297d2f0cc9c0a233fadf42dacc08708ad3909f77 (diff)
downloadtalos-petitboot-83a587b79e9a5a5279f1c7a26918fc8c08523a7f.tar.gz
talos-petitboot-83a587b79e9a5a5279f1c7a26918fc8c08523a7f.zip
discover: Add 'sync' user event
Add a user event named 'sync' that causes the discover server to merge the devicemapper snapshots of mounted devices. This is particularly useful as a debug aid (for example, when copying logs to a USB device), as the server will otherwise only sync changes to mounted devices in response to parser actions. The command can be called as pb-event sync@device to sync a particular device, or as pb-event sync@all to sync all devices with snapshots. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/user-event.c')
-rw-r--r--discover/user-event.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/discover/user-event.c b/discover/user-event.c
index 15d9c87..7350b6c 100644
--- a/discover/user-event.c
+++ b/discover/user-event.c
@@ -60,6 +60,8 @@ static const char *event_action_name(enum event_action action)
return "dhcp";
case EVENT_ACTION_BOOT:
return "boot";
+ case EVENT_ACTION_SYNC:
+ return "sync";
default:
break;
}
@@ -464,6 +466,18 @@ static int user_event_boot(struct user_event *uev, struct event *event)
return 0;
}
+static int user_event_sync(struct user_event *uev, struct event *event)
+{
+ struct device_handler *handler = uev->handler;
+
+ if (strncasecmp(event->device, "all", strlen("all")) != 0)
+ device_sync_snapshots(handler, event->device);
+ else
+ device_sync_snapshots(handler, NULL);
+
+ return 0;
+}
+
static void user_event_handle_message(struct user_event *uev, char *buf,
int len)
{
@@ -499,6 +513,9 @@ static void user_event_handle_message(struct user_event *uev, char *buf,
case EVENT_ACTION_BOOT:
result = user_event_boot(uev, event);
break;
+ case EVENT_ACTION_SYNC:
+ result = user_event_sync(uev, event);
+ break;
default:
break;
}
OpenPOWER on IntegriCloud