summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2019-03-15 18:56:23 +0100
committerFrancesco Giudici <fgiudici@redhat.com>2019-03-22 16:14:12 +0100
commitd74e09a7783fa3d57fd8460f65d5b0cc97f12538 (patch)
treea8b866ec4f941ae17396cfa0146ea1756f0d48e5
parentb159a0da82b756e6eb4da18317c3e522a8e9c99a (diff)
downloadNetworkManager-fg/checkpoint-devices-rh1578335-pt1.tar.gz
nm-checkpoint: save device ifname and track if it is softwarefg/checkpoint-devices-rh1578335-pt1
This will be soon useful as we are going to drop the reference to the Device objs: so, when a checkpoint is created and a device disappear (hw removed or sw device deleted) we will be able to correctly perform the rollback.
-rw-r--r--src/nm-checkpoint.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nm-checkpoint.c b/src/nm-checkpoint.c
index 91a4bb0b0d..41d5f4b84e 100644
--- a/src/nm-checkpoint.c
+++ b/src/nm-checkpoint.c
@@ -38,11 +38,13 @@
typedef struct {
char *original_dev_path;
+ char *original_dev_name;
NMDevice *device;
NMConnection *applied_connection;
NMConnection *settings_connection;
guint64 ac_version_id;
NMDeviceState state;
+ bool is_software:1;
bool realized:1;
bool activation_lifetime_bound_to_profile_visiblity:1;
NMUnmanFlagOp unmanaged_explicit;
@@ -225,7 +227,7 @@ nm_checkpoint_rollback (NMCheckpoint *self)
guint32 result = NM_ROLLBACK_RESULT_OK;
_LOGD ("rollback: restoring device %s (state %d, realized %d, explicitly unmanaged %d)",
- nm_device_get_iface (device),
+ dev_checkpoint->original_dev_name,
(int) dev_checkpoint->state,
dev_checkpoint->realized,
dev_checkpoint->unmanaged_explicit);
@@ -241,7 +243,7 @@ nm_checkpoint_rollback (NMCheckpoint *self)
}
} else {
if (dev_checkpoint->realized) {
- if (nm_device_is_software (device)) {
+ if (dev_checkpoint->is_software) {
/* try to recreate software device */
_LOGD ("rollback: software device not realized, will re-activate");
goto activate;
@@ -430,7 +432,9 @@ device_checkpoint_create (NMCheckpoint *checkpoint, NMDevice *device)
dev_checkpoint = g_slice_new0 (DeviceCheckpoint);
dev_checkpoint->device = g_object_ref (device);
dev_checkpoint->original_dev_path = g_strdup (path);
+ dev_checkpoint->original_dev_name = g_strdup (nm_device_get_iface (device));
dev_checkpoint->state = nm_device_get_state (device);
+ dev_checkpoint->is_software = nm_device_is_software (device);
dev_checkpoint->realized = nm_device_is_real (device);
dev_checkpoint->dev_exported_change_id = g_signal_connect (device,
NM_DBUS_OBJECT_EXPORTED_CHANGED,
@@ -469,6 +473,7 @@ device_checkpoint_destroy (gpointer data)
g_clear_object (&dev_checkpoint->settings_connection);
g_clear_object (&dev_checkpoint->device);
g_free (dev_checkpoint->original_dev_path);
+ g_free (dev_checkpoint->original_dev_name);
g_slice_free (DeviceCheckpoint, dev_checkpoint);
}