ui: callback & boot actions: kexec -> boot
[petitboot] / ui / twin / pbt-client.c
index ed12e5a993a7d381550d4eac54e70f13d3f8263b..ad418a32e2e95941c9d7186471890f070da3f815 100644 (file)
@@ -23,6 +23,8 @@
 #include <assert.h>
 #include <string.h>
 
+#include <pb-protocol/pb-protocol.h>
+
 #include "pbt-client.h"
 
 #include "log/log.h"
@@ -50,7 +52,7 @@ void pbt_frame_status_printf(struct pbt_frame *frame, const char *format, ...)
        va_end(ap);
 }
 
-static int pbt_client_run_kexec(struct pbt_item *item)
+static int pbt_client_boot(struct pbt_item *item)
 {
        int result;
        struct pb_opt_data *opt_data = pbt_opt_data_from_item(item);
@@ -60,17 +62,17 @@ static int pbt_client_run_kexec(struct pbt_item *item)
        pbt_frame_status_printf(&item->pbt_client->frame, "Booting %s...",
                pbt_item_name(item));
 
-       assert(item->pbt_client->kexec_cb);
-       result = item->pbt_client->kexec_cb(item->pbt_client, opt_data);
+       assert(item->pbt_client->boot_cb);
+       result = item->pbt_client->boot_cb(item->pbt_client, opt_data);
 
        if (!result) {
                sleep(item->pbt_client->dry_run ? 1 : 60);
        }
 
-       pb_log("%s: failed: %s\n", __func__, opt_data->kd->image);
+       pb_log("%s: failed: %s\n", __func__, opt_data->bd->image);
 
        pbt_frame_status_printf(&item->pbt_client->frame, "Failed: kexec %s",
-               opt_data->kd->image);
+               opt_data->bd->image);
 
        return 0;
 }
@@ -138,17 +140,17 @@ static int pbt_device_add(struct device *dev, struct pbt_client *client)
 
                i->pb_opt = opt;
                i->pbt_client = client;
-               i->on_execute = pbt_client_run_kexec;
+               i->on_execute = pbt_client_boot;
                i->on_edit = pbt_client_on_edit;
 
                i->data = opt_data = talloc(i, struct pb_opt_data);
                opt_data->name = opt->name;
-               opt_data->kd = talloc(i, struct pb_kexec_data);
-               opt_data->kd->image = talloc_strdup(opt_data->kd,
+               opt_data->bd = talloc(i, struct pb_boot_data);
+               opt_data->bd->image = talloc_strdup(opt_data->bd,
                        opt->boot_image_file);
-               opt_data->kd->initrd = talloc_strdup(opt_data->kd,
+               opt_data->bd->initrd = talloc_strdup(opt_data->bd,
                        opt->initrd_file);
-               opt_data->kd->args = talloc_strdup(opt_data->kd,
+               opt_data->bd->args = talloc_strdup(opt_data->bd,
                        opt->boot_args);
                opt_data->dev = dev;
                opt_data->opt = opt;
@@ -263,7 +265,7 @@ static void pbt_client_destructor(struct pbt_client *client)
 
 struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
        unsigned int width, unsigned int height,
-       int (*kexec_cb)(struct pbt_client *, struct pb_opt_data *),
+       int (*boot_cb)(struct pbt_client *, struct pb_opt_data *),
        int start_deamon, int dry_run)
 {
        struct pbt_client *pbt_client;
@@ -279,11 +281,14 @@ struct pbt_client *pbt_client_init(enum pbt_twin_backend backend,
 
        talloc_set_destructor(pbt_client, (void *)pbt_client_destructor);
 
+       pbt_client->waitset = waitset_create(pbt_client);
+
        pbt_client->sig = "pbt_client";
-       pbt_client->kexec_cb = kexec_cb;
+       pbt_client->boot_cb = boot_cb;
        pbt_client->dry_run = dry_run;
-       pbt_client->frame.scr = pbt_scr_init(pbt_client, backend, width, height,
-               NULL, NULL);
+       pbt_client->frame.scr = pbt_scr_init(pbt_client, pbt_client->waitset,
+                       backend, width, height, NULL, NULL);
+
 
        if (!pbt_client->frame.scr)
                goto fail_scr_init;
@@ -327,9 +332,10 @@ retry_start:
                goto fail_client_init;
        }
 
-       waiter_register(discover_client_get_fd(pbt_client->discover_client),
-               WAIT_IN, (waiter_cb)discover_client_process,
-               pbt_client->discover_client);
+       waiter_register(pbt_client->waitset,
+                       discover_client_get_fd(pbt_client->discover_client),
+                       WAIT_IN, (waiter_cb)discover_client_process,
+                       pbt_client->discover_client);
 
        return pbt_client;