mirror of https://github.com/ipxe/ipxe.git
[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>pull/310/head
parent
8055d5c48b
commit
7b963310aa
|
@ -130,24 +130,48 @@ struct linux_setting *linux_find_setting(char *name, struct list_head *settings)
|
|||
return result;
|
||||
}
|
||||
|
||||
void linux_apply_settings(struct list_head *new_settings, struct settings *settings_block)
|
||||
{
|
||||
struct linux_setting *setting;
|
||||
/**
|
||||
* Apply Linux command-line settings
|
||||
*
|
||||
* @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;
|
||||
|
||||
list_for_each_entry(setting, new_settings, list) {
|
||||
list_for_each_entry ( lsetting, list, list ) {
|
||||
|
||||
/* Skip already applied settings */
|
||||
if (setting->applied)
|
||||
if ( lsetting->applied )
|
||||
continue;
|
||||
|
||||
struct setting *s = find_setting(setting->name);
|
||||
if (s) {
|
||||
rc = storef_setting(settings_block, find_setting(setting->name), setting->value);
|
||||
if (rc != 0)
|
||||
DBG("linux storing setting '%s' = '%s' failed\n", setting->name, setting->value);
|
||||
setting->applied = 1;
|
||||
} else {
|
||||
DBG("linux unknown setting '%s'\n", setting->name);
|
||||
/* Parse setting name */
|
||||
if ( ( rc = parse_setting_name ( lsetting->name,
|
||||
find_child_settings, &ignore,
|
||||
&setting ) ) != 0 ) {
|
||||
DBGC ( settings, "Linux cannot parse %s: %s\n",
|
||||
lsetting->name, strerror ( rc ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue