]> git.ozlabs.org Git - petitboot/commitdiff
discover: Track both configured and current autoboot settings
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 25 Jan 2017 03:45:37 +0000 (14:45 +1100)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 15 Mar 2017 05:30:13 +0000 (16:30 +1100)
If autoboot is enabled but later disabled or cancelled by, for example,
an IPMI override then the nc-config screen will set the autoboot widget
as disabled. If the user then makes and saves a change in nc-config,
autoboot will also be saved as disabled. This accidental change is
particularly awkward if the user is attempting to remove an IPMI
override.

Instead only ever change the autoboot setting if the user explicitly
changes it. Use a new helper function 'config_autoboot_active()' to
determine the current autoboot status where needed.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/device-handler.c
discover/platform-powerpc.c
lib/types/types.c
lib/types/types.h

index 3cf7edff082d9f6f880ccdd19c18fa698490cbce..5b7afd0d3f56d7be992d3725f757d80d2c2c412a 100644 (file)
@@ -321,7 +321,7 @@ struct device_handler *device_handler_init(struct discover_server *server,
        handler->server = server;
        handler->waitset = waitset;
        handler->dry_run = dry_run;
-       handler->autoboot_enabled = config_get()->autoboot_enabled;
+       handler->autoboot_enabled = config_autoboot_active(config_get());
 
        list_init(&handler->unresolved_boot_options);
 
index e5c83a07e1c46039f2fcdf0fca7c3ce778d678a5..b5ad682eae3b9e7136de412602648a8ee72b8510 100644 (file)
@@ -755,21 +755,8 @@ static void set_ipmi_bootdev(struct config *config, enum ipmi_bootdev bootdev,
        config->ipmi_bootdev = bootdev;
        config->ipmi_bootdev_persistent = persistent;
 
-       switch (bootdev) {
-       case IPMI_BOOTDEV_NONE:
-       case IPMI_BOOTDEV_DISK:
-       case IPMI_BOOTDEV_NETWORK:
-       case IPMI_BOOTDEV_CDROM:
-       default:
-               break;
-       case IPMI_BOOTDEV_SETUP:
-               config->autoboot_enabled = false;
-               break;
-       case IPMI_BOOTDEV_SAFE:
-               config->autoboot_enabled = false;
+       if (bootdev == IPMI_BOOTDEV_SAFE)
                config->safe_mode = true;
-               break;
-       }
 }
 
 static int read_bootdev_sysparam(const char *name, uint8_t *val)
index 63045e1a29d2a933abd98bb8ed8826f2adea7a9c..d7f4ead791d2e7e312bdd531f834cbbee65ac67e 100644 (file)
@@ -75,3 +75,15 @@ enum device_type find_device_type(const char *str)
 
        return DEVICE_TYPE_UNKNOWN;
 }
+
+bool config_autoboot_active(const struct config *config)
+{
+       enum ipmi_bootdev bootdev = config->ipmi_bootdev;
+
+       if (!config->autoboot_enabled)
+               return false;
+       if (bootdev == IPMI_BOOTDEV_SETUP || bootdev == IPMI_BOOTDEV_SAFE)
+               return false;
+
+       return true;
+}
index 13ff7fc79f83bf3f4787a08198db019be9f9749b..7f4ae1fced1fa182055398d838dd441258680323 100644 (file)
@@ -183,4 +183,6 @@ struct config {
        bool                    debug;
 };
 
+bool config_autoboot_active(const struct config *config);
+
 #endif /* _TYPES_H */