[PATCH 4/4] bootm: add global.bootm.provide_hostname option

Marco Felsch m.felsch at pengutronix.de
Wed Mar 20 03:48:59 PDT 2024


Hi Ahmad,

On 24-03-14, Ahmad Fatoum wrote:
> Hello Marco,
> 
> Cc += Leonard
> 
> On 13.03.24 20:45, Marco Felsch wrote:
> > +		if (!barebox_hostname_is_valid(hostname)) {
> > +			pr_err("Provided hostname is not compatible to systemd hostname requirements\n");
> > +			ret = -EINVAL;
> > +			goto err_out;
> > +		}
> > +
> > +		hostname_bootarg = basprintf("systemd.hostname=%s", hostname);
> 
> Linux >= v6.0 supports a hostname= parameter and there's a discussion to decide what
> the semantics should be and if it should differ to systemd.hostname=:
> https://github.com/systemd/systemd/pull/25158

Thanks for the pointer, I think this discussion is still ongoing and
after skipping through the longly thread my impression is that the
semantics are the same.

> I am not fully sure, whether we should go with hostname or systemd.hostname= here.

As you have said, the hostname= param was added with v6.0 so by this
change distros using older kernels could benefit. Also I think that
hostname and systemd.hostname should be the same, to cite the GH
discussion:
8<-------------------------------------------------------------------
...

If there was already hostname= with those semantics on the kernel side
in place, I'm pretty sure we would've just reused it instead of defining
systemd.hostname=.

...
8<-------------------------------------------------------------------

Therefore I would keep the systemd.hostname as it was done by this
patch or we can supply both systemd.hostname= and hostname= but setting
it to the same value.

Regards,
  Marco

> @Leonard, what do you think?
> 
> Cheers,
> Ahmad
> 
> 
> > -static bool barebox_hostname_is_valid(const char *s)
> > +bool barebox_hostname_is_valid(const char *s)
> >  {
> >  	unsigned int n_dots = 0;
> >  	const char *p;
> > diff --git a/include/bootm.h b/include/bootm.h
> > index ee2b574521db..c69da85cdda1 100644
> > --- a/include/bootm.h
> > +++ b/include/bootm.h
> > @@ -34,6 +34,11 @@ struct bootm_data {
> >  	 * value of global.machine_id to Kernel.
> >  	 */
> >  	bool provide_machine_id;
> > +	/*
> > +	 * provide_hostname - if true, try to add systemd.hostname= with value
> > +	 * of global.hostname to Kernel.
> > +	 */
> > +	bool provide_hostname;
> >  	unsigned long initrd_address;
> >  	unsigned long os_address;
> >  	unsigned long os_entry;
> > diff --git a/include/common.h b/include/common.h
> > index b7b4d9e35094..d7b5261bc921 100644
> > --- a/include/common.h
> > +++ b/include/common.h
> > @@ -127,6 +127,7 @@ void barebox_set_model(const char *);
> >  const char *barebox_get_hostname(void);
> >  void barebox_set_hostname(const char *);
> >  void barebox_set_hostname_no_overwrite(const char *);
> > +bool barebox_hostname_is_valid(const char *s);
> >  
> >  const char *barebox_get_serial_number(void);
> >  void barebox_set_serial_number(const char *);
> 
> -- 
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> 



More information about the barebox mailing list