diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2023-08-08 11:51:10 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2023-08-09 16:10:22 +0200 |
commit | 0fcfd6e24f471170cf44d8ace0202e1e2fc9ffbb (patch) | |
tree | 2555ffa85f1a1b9ca790677f628c38622d28dfff | |
parent | f930c76a0ab046f52a784fea0f39bf0d5af18e7d (diff) |
checkpoint: preserve devices that were removed and readded
With flag DISCONNECT_NEW_DEVICES, on rollback we delete devices that
are present in the system and are not in the checkpoint.
The problem is that we remove the device from
`NMCheckpointPriv->devices` when it is deleted and so we lose the
information that the device was in the checkpoint. We need to also
look in the `removed_devices` list.
Fixes: 0e2f7ac7b5ea ('nm-checkpoint: drop reference to NM_DEVICE objects on removal signal')
-rw-r--r-- | src/core/nm-checkpoint.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/nm-checkpoint.c b/src/core/nm-checkpoint.c index 0beeb4ba26..52d8a649b3 100644 --- a/src/core/nm-checkpoint.c +++ b/src/core/nm-checkpoint.c @@ -458,8 +458,25 @@ next_dev: NMDeviceState state; nm_manager_for_each_device (priv->manager, device, tmp_lst) { + gboolean found = FALSE; + if (g_hash_table_contains(priv->devices, device)) continue; + + /* Also ignore devices that were in the checkpoint initially and + * were moved to 'removed_devices' because they got removed from + * the system. */ + for (i = 0; i < priv->removed_devices->len; i++) { + dev_checkpoint = priv->removed_devices->pdata[i]; + if (dev_checkpoint->dev_type == nm_device_get_device_type(device) + && nm_streq0(dev_checkpoint->original_dev_name, nm_device_get_iface(device))) { + found = TRUE; + break; + } + } + if (found) + continue; + state = nm_device_get_state(device); if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { _LOGD("rollback: disconnecting new device %s", nm_device_get_iface(device)); |