summaryrefslogtreecommitdiff
path: root/src/nm-checkpoint.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-28 07:06:10 +0200
committerThomas Haller <thaller@redhat.com>2018-04-04 14:02:13 +0200
commit5c283356a1df42e5b94cf0efb5a0d352c8343216 (patch)
tree8254600796957bfa9cbde5f4492f70caa47ba477 /src/nm-checkpoint.c
parente5fc9a307d036fe814145a5100bb6bdf28216cc6 (diff)
downloadNetworkManager-5c283356a1df42e5b94cf0efb5a0d352c8343216.tar.gz
checkpoint: allow overlapping checkpoints
Introduce a new flag NM_CHECKPOINT_CREATE_FLAG_ALLOW_OVERLAPPING that allows the creation of overlapping checkpoints. Before, and by default, checkpoints that reference a same device conflict, and creating such a checkpoint failed. Now, allow this. But during rollback automatically destroy all overlapping checkpoints that were created after the checkpoint that is about to rollback. With this, you can create a series of checkpoints, and rollback them individually. With the restriction, that if you once rolled back to an older checkpoint, you no longer can roll"forward" to a younger one. What this implies and what is new here, is that the checkpoint might be automatically destroyed by NetworkManager before the timeout expires. When the user later would try to manually destroy/rollback such a checkpoint, it would fail because the checkpoint no longer exists.
Diffstat (limited to 'src/nm-checkpoint.c')
-rw-r--r--src/nm-checkpoint.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c
index 55968843e1..29e748bb39 100644
--- a/src/nm-checkpoint.c
+++ b/src/nm-checkpoint.c
@@ -101,6 +101,12 @@ G_DEFINE_TYPE (NMCheckpoint, nm_checkpoint, NM_TYPE_DBUS_OBJECT)
/*****************************************************************************/
void
+nm_checkpoint_log_destroy (NMCheckpoint *self)
+{
+ _LOGI ("destroy %s", nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
+}
+
+void
nm_checkpoint_set_timeout_callback (NMCheckpoint *self,
NMCheckpointTimeoutCallback callback,
gpointer user_data)
@@ -114,12 +120,33 @@ nm_checkpoint_set_timeout_callback (NMCheckpoint *self,
priv->timeout_data = user_data;
}
-gboolean
-nm_checkpoint_includes_device (NMCheckpoint *self, NMDevice *device)
+NMDevice *
+nm_checkpoint_includes_devices (NMCheckpoint *self, NMDevice *const*devices, guint n_devices)
+{
+ NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
+ guint i;
+
+ for (i = 0; i < n_devices; i++) {
+ if (g_hash_table_contains (priv->devices, devices[i]))
+ return devices[i];
+ }
+ return NULL;
+}
+
+NMDevice *
+nm_checkpoint_includes_devices_of (NMCheckpoint *self, NMCheckpoint *cp_for_devices)
{
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
+ NMCheckpointPrivate *priv2 = NM_CHECKPOINT_GET_PRIVATE (cp_for_devices);
+ GHashTableIter iter;
+ NMDevice *device;
- return g_hash_table_contains (priv->devices, device);
+ g_hash_table_iter_init (&iter, priv2->devices);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &device, NULL)) {
+ if (g_hash_table_contains (priv->devices, device))
+ return device;
+ }
+ return NULL;
}
static NMSettingsConnection *