]> git.ozlabs.org Git - petitboot/commitdiff
discover/device-handler: Restore autoboot setting on requery v1.7.3
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 27 Aug 2018 01:50:47 +0000 (11:50 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 6 Sep 2018 23:44:29 +0000 (09:44 +1000)
When a device requery is triggered we cancel any default boot option on
the device. This also disables autoboot which we don't want; any boot
options found after the requery will not be able to autoboot.
To avoid this restore the existing autoboot setting after checking for
default options.

This prevents a particular corner case where a default boot option has
been selected for boot but one of its boot files has stalled or is
taking more time to download than the requery timeout and the requery
accidentally cancels autoboot preventing Petitboot from trying to boot
again.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit 3917e88b838001b13a19fc6ea01d08b08c0770ca)

discover/device-handler.c

index 20093a4f8039f50a6e0dd10dc786f22d343eef90..4dfe5379058f2bb6af664666946198364c7df8aa 100644 (file)
@@ -1191,6 +1191,7 @@ static int device_handler_requery_timeout_fn(void *data)
        struct requery_data *rqd = data;
        struct device_handler *handler;
        struct discover_device *device;
+       bool autoboot;
 
        handler = rqd->handler;
        device = rqd->device;
@@ -1213,9 +1214,14 @@ static int device_handler_requery_timeout_fn(void *data)
                talloc_free(opt);
        }
 
+       /* Track whether autoboot was enabled, if we cancel a default option
+        * it will be switched off.
+        */
+       autoboot = handler->autoboot_enabled;
+
        list_for_each_entry_safe(&device->boot_options, opt, tmp, list) {
                if (opt == handler->default_boot_option) {
-                       pb_log("Default option %s cancelled since device is being requeried",
+                       pb_log("Default option %s cancelled since device is being requeried\n",
                                        opt->option->name);
                        device_handler_cancel_default(handler);
                }
@@ -1223,6 +1229,8 @@ static int device_handler_requery_timeout_fn(void *data)
                talloc_free(opt);
        }
 
+       handler->autoboot_enabled = autoboot;
+
        discover_server_notify_device_remove(handler->server, device->device);
        device->notified = false;