summaryrefslogtreecommitdiff
path: root/src/initrd/nmi-cmdline-reader.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/initrd/nmi-cmdline-reader.c')
-rw-r--r--src/initrd/nmi-cmdline-reader.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c
index 69e5e56d07..e44841e683 100644
--- a/src/initrd/nmi-cmdline-reader.c
+++ b/src/initrd/nmi-cmdline-reader.c
@@ -237,20 +237,24 @@ get_word (char **argument, const char separator)
}
static void
-_base_setting_set (NMConnection *connection, const char *property, const char *value)
+connection_set (NMConnection *connection, const char *setting_name, const char *property, const char *value)
{
NMSetting *setting;
- const char *type_name = nm_connection_get_connection_type (connection);
- GObjectClass *object_class = g_type_class_ref (nm_setting_lookup_type (type_name));
- GParamSpec *spec = g_object_class_find_property (object_class, property);
-
- if (!spec) {
- _LOGW (LOGD_CORE, "'%s' does not support setting %s", type_name, property);
- return;
+ GType setting_type;
+ nm_auto_unref_gtypeclass GObjectClass *object_class = NULL;
+ GParamSpec *spec;
+
+ setting_type = nm_setting_lookup_type (setting_name);
+ object_class = g_type_class_ref (setting_type);
+ spec = g_object_class_find_property (object_class, property);
+ nm_assert (spec);
+
+ setting = nm_connection_get_setting_by_name (connection, setting_name);
+ if (!setting) {
+ setting = g_object_new (setting_type, NULL);
+ nm_connection_add_setting (connection, setting);
}
- setting = nm_connection_get_setting_by_name (connection, type_name);
-
if (G_IS_PARAM_SPEC_UINT (spec)) {
guint v;
@@ -259,14 +263,12 @@ _base_setting_set (NMConnection *connection, const char *property, const char *v
|| !nm_g_object_set_property_uint (G_OBJECT (setting), property, v, NULL)) {
_LOGW (LOGD_CORE,
"Could not set property '%s.%s' to '%s'",
- type_name, property, value);
+ setting_name, property, value);
}
} else if (G_IS_PARAM_SPEC_STRING (spec))
g_object_set (setting, property, value, NULL);
else
- _LOGW (LOGD_CORE, "Don't know how to set '%s' of %s", property, type_name);
-
- g_type_class_unref (object_class);
+ _LOGW (LOGD_CORE, "Don't know how to set '%s' of %s", property, setting_name);
}
static void
@@ -577,10 +579,10 @@ reader_parse_ip (Reader *reader, const char *sysfs_dir, char *argument)
}
if (mtu && *mtu)
- _base_setting_set (connection, "mtu", mtu);
+ connection_set (connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
if (macaddr && *macaddr)
- _base_setting_set (connection, "cloned-mac-address", macaddr);
+ connection_set (connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, macaddr);
}
static void
@@ -635,7 +637,7 @@ reader_parse_master (Reader *reader,
NM_SETTING_CONNECTION_MASTER, master,
NULL);
if (mtu)
- _base_setting_set (connection, "mtu", mtu);
+ connection_set (connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
} while (slaves && *slaves != '\0');
if (argument && *argument)