]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
discover: Ensure destroy_device is called on reinit
[petitboot] / discover / device-handler.c
index 487f2e73506221a316cd8e3b72928cccc733b167..d2b50b5e36c3e170ad478ca12bbd93e819fcef50 100644 (file)
@@ -330,9 +330,11 @@ void device_handler_reinit(struct device_handler *handler)
        list_init(&handler->unresolved_boot_options);
 
        /* drop all devices */
-       for (i = 0; i < handler->n_devices; i++)
+       for (i = 0; i < handler->n_devices; i++) {
                discover_server_notify_device_remove(handler->server,
                                handler->devices[i]->device);
+               talloc_free(handler->devices[i]);
+       }
 
        talloc_free(handler->devices);
        handler->devices = NULL;
@@ -755,8 +757,16 @@ int device_handler_discover(struct device_handler *handler,
                struct discover_device *dev)
 {
        struct discover_context *ctx;
+       struct boot_status *status;
        int rc;
 
+       status = talloc_zero(handler, struct boot_status);
+       status->type = BOOT_STATUS_INFO;
+       status->message = talloc_asprintf(status, "Processing %s device %s",
+                               device_type_display_name(dev->device->type),
+                               dev->device->id);
+       boot_status(handler, status);
+
        process_boot_option_queue(handler);
 
        /* create our context */
@@ -777,6 +787,11 @@ int device_handler_discover(struct device_handler *handler,
        device_handler_discover_context_commit(handler, ctx);
 
 out:
+       status->message = talloc_asprintf(status,"Processing %s complete\n",
+                               dev->device->id);
+       boot_status(handler, status);
+
+       talloc_free(status);
        talloc_free(ctx);
 
        return 0;
@@ -787,6 +802,13 @@ int device_handler_dhcp(struct device_handler *handler,
                struct discover_device *dev, struct event *event)
 {
        struct discover_context *ctx;
+       struct boot_status *status;
+
+       status = talloc_zero(handler, struct boot_status);
+       status->type = BOOT_STATUS_INFO;
+       status->message = talloc_asprintf(status, "Processing dhcp event on %s",
+                               dev->device->id);
+       boot_status(handler, status);
 
        /* create our context */
        ctx = device_handler_discover_context_create(handler, dev);
@@ -796,6 +818,11 @@ int device_handler_dhcp(struct device_handler *handler,
 
        device_handler_discover_context_commit(handler, ctx);
 
+       status->message = talloc_asprintf(status,"Processing %s complete\n",
+                               dev->device->id);
+       boot_status(handler, status);
+
+       talloc_free(status);
        talloc_free(ctx);
 
        return 0;
@@ -805,19 +832,30 @@ int device_handler_dhcp(struct device_handler *handler,
 int device_handler_conf(struct device_handler *handler,
                struct discover_device *dev, struct pb_url *url)
 {
-        struct discover_context *ctx;
+       struct discover_context *ctx;
+       struct boot_status *status;
 
-        /* create our context */
-        ctx = device_handler_discover_context_create(handler, dev);
-        ctx->conf_url = url;
+       status = talloc_zero(handler, struct boot_status);
+       status->type = BOOT_STATUS_INFO;
+       status->message = talloc_asprintf(status, "Processing user config");
+       boot_status(handler, status);
 
-        iterate_parsers(ctx);
+       /* create our context */
+       ctx = device_handler_discover_context_create(handler, dev);
+       ctx->conf_url = url;
 
-        device_handler_discover_context_commit(handler, ctx);
+       iterate_parsers(ctx);
 
-        talloc_free(ctx);
+       device_handler_discover_context_commit(handler, ctx);
+
+       status->message = talloc_asprintf(status,
+                               "Processing user config complete");
+       boot_status(handler, status);
 
-        return 0;
+       talloc_free(status);
+       talloc_free(ctx);
+
+       return 0;
 }
 
 static struct discover_boot_option *find_boot_option_by_id(