summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-09-07 17:47:21 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2016-09-20 18:28:31 +0200
commit942236b4ef483b573c5f1cc8c0ece092995b87c2 (patch)
tree4ad6130f31d075caaf7bc212c4f055c3b066ee81
parent2ce354d2608ab6a5c5fd380019062423e4267123 (diff)
downloadNetworkManager-942236b4ef483b573c5f1cc8c0ece092995b87c2.tar.gz
checkpoint: consider all devices when an empty list is passed
First, consider all devices and not only realized and managed ones when an empty list is passed. Also, move the list evaluation to the checkpoint manager, since the check for device conflicts is done there. Fixes: 3e09aed2a09fab11f66b8228e48dc8f732c65cce
-rw-r--r--introspection/nm-manager.xml2
-rw-r--r--src/nm-checkpoint-manager.c13
-rw-r--r--src/nm-checkpoint.c26
3 files changed, 11 insertions, 30 deletions
diff --git a/introspection/nm-manager.xml b/introspection/nm-manager.xml
index cf178c3951..0c4caa4713 100644
--- a/introspection/nm-manager.xml
+++ b/introspection/nm-manager.xml
@@ -209,7 +209,7 @@
<!--
CheckpointCreate:
- @devices: a list of device paths for which a checkpoint should be created. An empty list means all managed devices.
+ @devices: a list of device paths for which a checkpoint should be created. An empty list means all devices.
@rollback_timeout: the time in seconds until NetworkManager will automatically rollback to the checkpoint. Set to zero for infinite.
@flags: optional flags that influence the creation.
@checkpoint: on success, returns the path of the checkpoint.
diff --git a/src/nm-checkpoint-manager.c b/src/nm-checkpoint-manager.c
index 254dc31e3d..49e8b89595 100644
--- a/src/nm-checkpoint-manager.c
+++ b/src/nm-checkpoint-manager.c
@@ -145,19 +145,27 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
NMCheckpointCreateFlags flags,
GError **error)
{
+ NMManager *manager;
NMCheckpoint *checkpoint;
const char * const *path;
gs_unref_ptrarray GPtrArray *devices = NULL;
NMDevice *device;
const char *checkpoint_path;
+ gs_free const char **device_paths_free = NULL;
guint i;
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (!error || !*error, FALSE);
+ manager = GET_MANAGER (self);
+
+ if (!device_paths || !device_paths[0]) {
+ device_paths_free = nm_manager_get_device_paths (manager);
+ device_paths = (const char *const *) device_paths_free;
+ }
devices = g_ptr_array_new ();
for (path = device_paths; *path; path++) {
- device = nm_manager_get_device_by_path (GET_MANAGER (self), *path);
+ device = nm_manager_get_device_by_path (manager, *path);
if (!device) {
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_DEVICE,
"device %s does not exist", *path);
@@ -178,8 +186,7 @@ nm_checkpoint_manager_create (NMCheckpointManager *self,
}
}
- checkpoint = nm_checkpoint_new (GET_MANAGER (self), devices,
- rollback_timeout, error);
+ checkpoint = nm_checkpoint_new (manager, devices, rollback_timeout, error);
if (!checkpoint)
return NULL;
diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c
index 22360250bb..2d9e1f9455 100644
--- a/src/nm-checkpoint.c
+++ b/src/nm-checkpoint.c
@@ -288,29 +288,6 @@ nm_checkpoint_init (NMCheckpoint *self)
NULL, device_checkpoint_destroy);
}
-static void
-get_all_devices (NMManager *manager, GPtrArray *devices)
-{
- const GSList *list, *iter;
- NMDevice *dev;
-
- list = nm_manager_get_devices (manager);
-
- for (iter = list; iter; iter = g_slist_next (iter)) {
- dev = iter->data;
-
- if (!nm_device_is_real (dev))
- continue;
- if (nm_device_get_state (dev) <= NM_DEVICE_STATE_UNMANAGED)
- continue;
- /* We never touch assumed connections, unless told explicitly */
- if (nm_device_uses_assumed_connection (dev))
- continue;
-
- g_ptr_array_add (devices, dev);
- }
-}
-
NMCheckpoint *
nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_timeout,
GError **error)
@@ -325,9 +302,6 @@ nm_checkpoint_new (NMManager *manager, GPtrArray *devices, guint32 rollback_time
g_return_val_if_fail (devices, NULL);
g_return_val_if_fail (!error || !*error, NULL);
- if (!devices->len)
- get_all_devices (manager, devices);
-
if (!devices->len) {
g_set_error_literal (error,
NM_MANAGER_ERROR,