Skip to content

Commit

Permalink
lxd/storage/drivers/volume: Deep copy the volume's config when instan…
Browse files Browse the repository at this point in the history
…tiating a snapshot

Signed-off-by: Julian Pelizäus <[email protected]>
  • Loading branch information
roosterfish committed Feb 19, 2024
1 parent 496fc10 commit f1d4d56
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lxd/storage/drivers/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,23 @@ func (v Volume) NewSnapshot(snapshotName string) (Volume, error) {
return Volume{}, fmt.Errorf("Cannot create a snapshot volume from a snapshot")
}

// Deep copy the volume's config.
// A snapshot can have different config keys like its UUID.
// When instantiating a new snapshot from its parent volume,
// this ensures that modifications on the snapshots config
// aren't propagated to the parent volume.
snapConfig := make(map[string]string, len(v.config))
for k, v := range v.config {
if k == "volatile.uuid" {
// Don't copy the parent volume's UUID.
continue
}

snapConfig[k] = v
}

fullSnapName := GetSnapshotVolumeName(v.name, snapshotName)
vol := NewVolume(v.driver, v.pool, v.volType, v.contentType, fullSnapName, v.config, v.poolConfig)
vol := NewVolume(v.driver, v.pool, v.volType, v.contentType, fullSnapName, snapConfig, v.poolConfig)

// Propagate filesystem probe mode of parent volume.
vol.SetMountFilesystemProbe(v.mountFilesystemProbe)
Expand Down

0 comments on commit f1d4d56

Please sign in to comment.