mirror of
https://github.com/ipxe/ipxe
synced 2025-12-24 15:23:42 +03:00
[linux] Allow arbitrary settings to be applied to Linux devices
Allow arbitrary settings to be specified on the Linux command line.
For example:
./bin-x86_64-linux/slirp.linux \
--net slirp,testserver=qa-test.ipxe.org
This can be useful when using the Linux userspace build to test
embedded scripts, since it allows arbitrary parameters to be passed
directly on the command line.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -130,24 +130,48 @@ struct linux_setting *linux_find_setting(char *name, struct list_head *settings)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block)
|
/**
|
||||||
{
|
* Apply Linux command-line settings
|
||||||
struct linux_setting *setting;
|
*
|
||||||
|
* @v list List of command-line settings
|
||||||
|
* @v settings Settings block
|
||||||
|
*/
|
||||||
|
void linux_apply_settings ( struct list_head *list,
|
||||||
|
struct settings *settings ) {
|
||||||
|
struct linux_setting *lsetting;
|
||||||
|
struct settings *ignore;
|
||||||
|
struct setting setting;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
list_for_each_entry(setting, new_settings, list) {
|
list_for_each_entry ( lsetting, list, list ) {
|
||||||
|
|
||||||
/* Skip already applied settings */
|
/* Skip already applied settings */
|
||||||
if (setting->applied)
|
if ( lsetting->applied )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
struct setting *s = find_setting(setting->name);
|
/* Parse setting name */
|
||||||
if (s) {
|
if ( ( rc = parse_setting_name ( lsetting->name,
|
||||||
rc = storef_setting(settings_block, find_setting(setting->name), setting->value);
|
find_child_settings, &ignore,
|
||||||
if (rc != 0)
|
&setting ) ) != 0 ) {
|
||||||
DBG("linux storing setting '%s' = '%s' failed\n", setting->name, setting->value);
|
DBGC ( settings, "Linux cannot parse %s: %s\n",
|
||||||
setting->applied = 1;
|
lsetting->name, strerror ( rc ) );
|
||||||
} else {
|
continue;
|
||||||
DBG("linux unknown setting '%s'\n", setting->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apply default type if not specified */
|
||||||
|
if ( ! setting.type )
|
||||||
|
setting.type = &setting_type_string;
|
||||||
|
|
||||||
|
/* Store setting */
|
||||||
|
if ( ( rc = storef_setting ( settings, &setting,
|
||||||
|
lsetting->value ) ) != 0 ) {
|
||||||
|
DBGC ( settings, "Linux cannot set %s=\"%s\": %s\n",
|
||||||
|
lsetting->name, lsetting->value,
|
||||||
|
strerror ( rc ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mark setting as applied */
|
||||||
|
lsetting->applied = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user