settings: log connection diffs in replace_settings only where appropriate

Only log connection diffs when we update a connection that we actually
care about.

Note that most plugin specific connections use
nm_settings_connection_replace_settings() in their constructor
to initialize themselves. These occurrences are not interesting
and spam the logfile.
This commit is contained in:
Thomas Haller
2014-12-09 11:45:32 +01:00
parent 750f01dfcb
commit e14ea6818a
10 changed files with 16 additions and 4 deletions

View File

@@ -450,6 +450,7 @@ gboolean
nm_settings_connection_replace_settings (NMSettingsConnection *self, nm_settings_connection_replace_settings (NMSettingsConnection *self,
NMConnection *new_connection, NMConnection *new_connection,
gboolean update_unsaved, gboolean update_unsaved,
const char *log_diff_name,
GError **error) GError **error)
{ {
NMSettingsConnectionPrivate *priv; NMSettingsConnectionPrivate *priv;
@@ -475,7 +476,8 @@ nm_settings_connection_replace_settings (NMSettingsConnection *self,
*/ */
g_signal_handlers_block_by_func (self, G_CALLBACK (changed_cb), GUINT_TO_POINTER (TRUE)); g_signal_handlers_block_by_func (self, G_CALLBACK (changed_cb), GUINT_TO_POINTER (TRUE));
nm_utils_log_connection_diff (new_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, "update connection", "++ "); if (log_diff_name)
nm_utils_log_connection_diff (new_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ ");
nm_connection_replace_settings_from_connection (NM_CONNECTION (self), new_connection); nm_connection_replace_settings_from_connection (NM_CONNECTION (self), new_connection);
nm_settings_connection_set_flags (self, nm_settings_connection_set_flags (self,
@@ -535,9 +537,9 @@ replace_and_commit (NMSettingsConnection *self,
{ {
GError *error = NULL; GError *error = NULL;
if (nm_settings_connection_replace_settings (self, new_connection, TRUE, &error)) { if (nm_settings_connection_replace_settings (self, new_connection, TRUE, "replace-and-commit-disk", &error))
nm_settings_connection_commit_changes (self, callback, user_data); nm_settings_connection_commit_changes (self, callback, user_data);
} else { else {
g_assert (error); g_assert (error);
if (callback) if (callback)
callback (self, error, user_data); callback (self, error, user_data);
@@ -1367,7 +1369,7 @@ update_auth_cb (NMSettingsConnection *self,
con_update_cb, con_update_cb,
info); info);
} else { } else {
if (!nm_settings_connection_replace_settings (self, info->new_settings, TRUE, &local)) if (!nm_settings_connection_replace_settings (self, info->new_settings, TRUE, "replace-and-commit-memory", &local))
g_assert (local); g_assert (local);
con_update_cb (self, local, info); con_update_cb (self, local, info);
g_clear_error (&local); g_clear_error (&local);

View File

@@ -123,6 +123,7 @@ void nm_settings_connection_commit_changes (NMSettingsConnection *connection,
gboolean nm_settings_connection_replace_settings (NMSettingsConnection *self, gboolean nm_settings_connection_replace_settings (NMSettingsConnection *self,
NMConnection *new_connection, NMConnection *new_connection,
gboolean update_unsaved, gboolean update_unsaved,
const char *log_diff_name,
GError **error); GError **error);
void nm_settings_connection_replace_and_commit (NMSettingsConnection *self, void nm_settings_connection_replace_and_commit (NMSettingsConnection *self,

View File

@@ -82,6 +82,7 @@ nm_example_connection_new (const char *full_path,
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
tmp, tmp,
TRUE, TRUE,
NULL,
error)) { error)) {
g_object_unref (object); g_object_unref (object);
object = NULL; object = NULL;

View File

@@ -46,6 +46,7 @@ nm_ibft_connection_new (const GPtrArray *block, GError **error)
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
source, source,
FALSE, FALSE,
NULL,
error)) error))
g_clear_object (&object); g_clear_object (&object);

View File

@@ -235,6 +235,7 @@ nm_ifcfg_connection_new (NMConnection *source,
if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
tmp, tmp,
update_unsaved, update_unsaved,
NULL,
error)) error))
nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object)); nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object));
else else

View File

@@ -340,6 +340,7 @@ connection_new_or_changed (SCPluginIfcfg *self,
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (existing), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (existing),
NM_CONNECTION (new), NM_CONNECTION (new),
FALSE, /* don't set Unsaved */ FALSE, /* don't set Unsaved */
"ifcfg-rh-update",
&error)) { &error)) {
/* Shouldn't ever get here as 'new' was verified by the reader already */ /* Shouldn't ever get here as 'new' was verified by the reader already */
g_assert_not_reached (); g_assert_not_reached ();

View File

@@ -82,6 +82,7 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
tmp, tmp,
update_unsaved, update_unsaved,
NULL,
NULL); NULL);
g_object_unref (tmp); g_object_unref (tmp);

View File

@@ -313,6 +313,7 @@ reload_connections (NMSystemConfigInterface *config)
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (old),
NM_CONNECTION (new), NM_CONNECTION (new),
FALSE, /* don't set Unsaved */ FALSE, /* don't set Unsaved */
"ifnet-update",
&error)) { &error)) {
/* Shouldn't ever get here as 'new' was verified by the reader already */ /* Shouldn't ever get here as 'new' was verified by the reader already */
g_assert_not_reached (); g_assert_not_reached ();

View File

@@ -76,6 +76,7 @@ nm_keyfile_connection_new (NMConnection *source,
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
tmp, tmp,
update_unsaved, update_unsaved,
NULL,
error)) { error)) {
g_object_unref (object); g_object_unref (object);
object = NULL; object = NULL;

View File

@@ -126,6 +126,7 @@ update_connection (SCPluginKeyfile *self,
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection), if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection),
NM_CONNECTION (tmp), NM_CONNECTION (tmp),
FALSE, /* don't set Unsaved */ FALSE, /* don't set Unsaved */
"keyfile-update",
&error)) { &error)) {
/* Shouldn't ever get here as 'new' was verified by the reader already */ /* Shouldn't ever get here as 'new' was verified by the reader already */
g_assert_not_reached (); g_assert_not_reached ();
@@ -182,6 +183,7 @@ new_connection (SCPluginKeyfile *self,
if (!nm_settings_connection_replace_settings (connection, if (!nm_settings_connection_replace_settings (connection,
NM_CONNECTION (tmp), NM_CONNECTION (tmp),
FALSE, /* don't set Unsaved */ FALSE, /* don't set Unsaved */
"keyfile-update-new",
&error)) { &error)) {
/* Shouldn't ever get here as 'tmp' was verified by the reader already */ /* Shouldn't ever get here as 'tmp' was verified by the reader already */
g_assert_not_reached (); g_assert_not_reached ();