summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2016-12-08 13:08:15 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-12-20 15:04:29 +1100
commitb5f9e34d85075afe7aa87b5ce4a1a2d911468e36 (patch)
tree2f1daf66c1d80f3141a3cd15d8ce1515606e5e10 /discover/device-handler.c
parentc5ae6f4846ca4bd8e13ffa08a293950433f3096c (diff)
downloadtalos-petitboot-b5f9e34d85075afe7aa87b5ce4a1a2d911468e36.tar.gz
talos-petitboot-b5f9e34d85075afe7aa87b5ce4a1a2d911468e36.zip
discover: Add helpers for status reporting
This change adds a couple of helpers for the status reporting API, allowing callers to provide just a set of printf-style arguments, rather than having to build up a struct status. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 81bdedb..b8825ce 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -416,6 +416,39 @@ void device_handler_status(struct device_handler *handler,
discover_server_notify_boot_status(handler->server, status);
}
+static void _device_handler_vstatus(struct device_handler *handler,
+ enum status_type type, const char *fmt, va_list ap)
+{
+ struct status status;
+
+ status.type = type;
+ status.message = talloc_vasprintf(handler, fmt, ap);
+
+ device_handler_status(handler, &status);
+
+ talloc_free(status.message);
+}
+
+void device_handler_status_info(struct device_handler *handler,
+ const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ _device_handler_vstatus(handler, STATUS_INFO, fmt, ap);
+ va_end(ap);
+}
+
+void device_handler_status_err(struct device_handler *handler,
+ const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ _device_handler_vstatus(handler, STATUS_ERROR, fmt, ap);
+ va_end(ap);
+}
+
static void device_handler_boot_status_cb(void *arg, struct status *status)
{
device_handler_status(arg, status);
OpenPOWER on IntegriCloud