From patchwork Tue Jan 31 03:56:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 721793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vCC9v3Ssnz9sf9 for ; Tue, 31 Jan 2017 14:56:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MYt2uCSu"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vCC9v2QldzDq9B for ; Tue, 31 Jan 2017 14:56:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MYt2uCSu"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vCC9r1YFHzDq60 for ; Tue, 31 Jan 2017 14:56:32 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="MYt2uCSu"; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 11CD6140059; Tue, 31 Jan 2017 11:56:28 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1485834989; bh=7KbzEQ8nFOGCWe8pWcYanCqVx4BrXQf0X9D3MySDw6c=; h=From:To:Cc:Subject:Date:From; b=MYt2uCSuJcOKya66k2W6M5lYFFLPTjl6AVQTQ+uDV7sofY3KsFte7/+HaWpxj6Hol MrcWYByAztDFsbWD1ow2A55wpoaOeSSwLQCSyq0kyfbJ4UsZChQvskUFxHvY/7vBku kUmf63rl7Cc1rrQZsEpRM1c2iL0AEsdc/isObZHI= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH] discover: Track both configured and current autoboot settings Date: Tue, 31 Jan 2017 14:56:22 +1100 Message-Id: <20170131035622.29601-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.11.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- discover/device-handler.c | 2 +- discover/platform-powerpc.c | 15 +-------------- lib/types/types.c | 12 ++++++++++++ lib/types/types.h | 2 ++ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/discover/device-handler.c b/discover/device-handler.c index 3cf7edf..5b7afd0 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -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); diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index e5c83a0..b5ad682 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -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) diff --git a/lib/types/types.c b/lib/types/types.c index 63045e1..d7f4ead 100644 --- a/lib/types/types.c +++ b/lib/types/types.c @@ -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; +} diff --git a/lib/types/types.h b/lib/types/types.h index 13ff7fc..7f4ae1f 100644 --- a/lib/types/types.h +++ b/lib/types/types.h @@ -183,4 +183,6 @@ struct config { bool debug; }; +bool config_autoboot_active(const struct config *config); + #endif /* _TYPES_H */