* [PATCH 0/2] Fix machine-id operation
@ 2019-06-14 20:35 Cory Tusar
2019-06-14 20:35 ` [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id Cory Tusar
2019-06-14 20:35 ` [PATCH 2/2] common: blspec: Both environment and config file machine-id must match Cory Tusar
0 siblings, 2 replies; 5+ messages in thread
From: Cory Tusar @ 2019-06-14 20:35 UTC (permalink / raw)
To: barebox; +Cc: Chris Healy
Hi all,
What follows is a short series that fixes a pair of problems I
encountered when trying to use a machine-id value to boot a specific
disk partition on several of our platforms.
Best regards,
-Cory
Cory Tusar (2):
common: boot: Instantiate storage for global.boot.machine_id
common: blspec: Both environment and config file machine-id must match
common/blspec.c | 14 ++++++--------
common/boot.c | 9 +++++++++
2 files changed, 15 insertions(+), 8 deletions(-)
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id
2019-06-14 20:35 [PATCH 0/2] Fix machine-id operation Cory Tusar
@ 2019-06-14 20:35 ` Cory Tusar
2019-06-17 12:21 ` Sascha Hauer
2019-06-14 20:35 ` [PATCH 2/2] common: blspec: Both environment and config file machine-id must match Cory Tusar
1 sibling, 1 reply; 5+ messages in thread
From: Cory Tusar @ 2019-06-14 20:35 UTC (permalink / raw)
To: barebox; +Cc: Chris Healy
There are references throughout the documentation (and elsewhere in the
boot code) regarding the use of machine-id in a bootloader spec file.
However, there was no global storage allocated for this variable.
This commit adds the necessary storage and associated initialization.
Signed-off-by: Cory Tusar <cory.tusar@zii.aero>
---
common/boot.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/common/boot.c b/common/boot.c
index 974eaf5d0..fae2ff935 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -348,4 +348,13 @@ void bootsources_list(struct bootentries *bootentries)
printf("%-20s %s\n", entry->title, entry->description);
}
+static int boot_init(void)
+{
+ globalvar_add_simple("boot.machine_id", NULL);
+
+ return 0;
+}
+late_initcall(boot_init);
+
BAREBOX_MAGICVAR_NAMED(global_boot_default, global.boot.default, "default boot order");
+BAREBOX_MAGICVAR_NAMED(global_boot_machine_id, global.boot.machine_id, "optional machine-id, per Bootloader Spec");
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id
2019-06-14 20:35 ` [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id Cory Tusar
@ 2019-06-17 12:21 ` Sascha Hauer
2019-06-17 18:06 ` Cory Tusar
0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2019-06-17 12:21 UTC (permalink / raw)
To: Cory Tusar; +Cc: barebox, Chris Healy
On Fri, Jun 14, 2019 at 08:35:08PM +0000, Cory Tusar wrote:
> There are references throughout the documentation (and elsewhere in the
> boot code) regarding the use of machine-id in a bootloader spec file.
> However, there was no global storage allocated for this variable.
>
> This commit adds the necessary storage and associated initialization.
>
> Signed-off-by: Cory Tusar <cory.tusar@zii.aero>
> ---
> common/boot.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/common/boot.c b/common/boot.c
> index 974eaf5d0..fae2ff935 100644
> --- a/common/boot.c
> +++ b/common/boot.c
> @@ -348,4 +348,13 @@ void bootsources_list(struct bootentries *bootentries)
> printf("%-20s %s\n", entry->title, entry->description);
> }
>
> +static int boot_init(void)
> +{
> + globalvar_add_simple("boot.machine_id", NULL);
> +
> + return 0;
> +}
> +late_initcall(boot_init);
There already is an initcall in this file adding a globalvar. Could you
add this change to the existing initcall and rename
init_boot_watchdog_timeout() to something more suitable?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id
2019-06-17 12:21 ` Sascha Hauer
@ 2019-06-17 18:06 ` Cory Tusar
0 siblings, 0 replies; 5+ messages in thread
From: Cory Tusar @ 2019-06-17 18:06 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Chris Healy
On Mon, Jun 17, 2019 at 02:21:23PM +0200, Sascha Hauer wrote:
> On Fri, Jun 14, 2019 at 08:35:08PM +0000, Cory Tusar wrote:
> > There are references throughout the documentation (and elsewhere in the
> > boot code) regarding the use of machine-id in a bootloader spec file.
> > However, there was no global storage allocated for this variable.
> >
> > This commit adds the necessary storage and associated initialization.
> >
> > Signed-off-by: Cory Tusar <cory.tusar@zii.aero>
> > ---
> > common/boot.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/common/boot.c b/common/boot.c
> > index 974eaf5d0..fae2ff935 100644
> > --- a/common/boot.c
> > +++ b/common/boot.c
> > @@ -348,4 +348,13 @@ void bootsources_list(struct bootentries *bootentries)
> > printf("%-20s %s\n", entry->title, entry->description);
> > }
> >
> > +static int boot_init(void)
> > +{
> > + globalvar_add_simple("boot.machine_id", NULL);
> > +
> > + return 0;
> > +}
> > +late_initcall(boot_init);
>
> There already is an initcall in this file adding a globalvar. Could you
> add this change to the existing initcall and rename
> init_boot_watchdog_timeout() to something more suitable?
Will do.
-Cory
--
Cory Tusar
Senior Software Engineer
Zodiac Inflight Innovations
2929 E Imperial Hwy, Suite 170
Brea, CA 92821
(714) 203-0519
www.safran-aerosystems.com
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] common: blspec: Both environment and config file machine-id must match
2019-06-14 20:35 [PATCH 0/2] Fix machine-id operation Cory Tusar
2019-06-14 20:35 ` [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id Cory Tusar
@ 2019-06-14 20:35 ` Cory Tusar
1 sibling, 0 replies; 5+ messages in thread
From: Cory Tusar @ 2019-06-14 20:35 UTC (permalink / raw)
To: barebox; +Cc: Chris Healy
The original logic for determining whether or not to consider a blspec
entry as "matching" would return a false positive for cases in which a
machine-id was specified in a particular blspec configuration file, but
no such value was present in the environment.
This commit modifies that logic such that a machine-id is considered to
be "matching" ONLY if the values are identical in both the environment
and configuration file, OR if there is no machine-id specified in either
the environment or the configuration file.
Instances where a machine-id is specified in only one location will no
longer be considered a match, nor will instances where the UUID values
themselves differ.
Tested on a number of ZII platforms where we use a machine-id value to
differentiate between active and inactive OS partitions.
Signed-off-by: Cory Tusar <cory.tusar@zii.aero>
---
common/blspec.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/common/blspec.c b/common/blspec.c
index 41f2a4c53..59859c9b3 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -430,16 +430,14 @@ out:
static bool entry_is_match_machine_id(struct blspec_entry *entry)
{
- int ret = true;
const char *env_machineid = getenv_nonempty("global.boot.machine_id");
+ const char *machineid = blspec_entry_var_get(entry, "machine-id");
+ bool ret = !!env_machineid == !!machineid;
- if (env_machineid) {
- const char *machineid = blspec_entry_var_get(entry, "machine-id");
- if (!machineid || strcmp(machineid, env_machineid)) {
- pr_debug("ignoring entry with missmatched machine-id " \
- "\"%s\" != \"%s\"\n", env_machineid, machineid);
- ret = false;
- }
+ if (env_machineid && machineid && strcmp(env_machineid, machineid)) {
+ pr_info("ignoring entry with mismatched machine-id " \
+ "\"%s\" != \"%s\"\n", env_machineid, machineid);
+ ret = false;
}
return ret;
--
2.21.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-17 18:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 20:35 [PATCH 0/2] Fix machine-id operation Cory Tusar
2019-06-14 20:35 ` [PATCH 1/2] common: boot: Instantiate storage for global.boot.machine_id Cory Tusar
2019-06-17 12:21 ` Sascha Hauer
2019-06-17 18:06 ` Cory Tusar
2019-06-14 20:35 ` [PATCH 2/2] common: blspec: Both environment and config file machine-id must match Cory Tusar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox