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: 3e09aed2a0
This commit is contained in:
@@ -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.
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user