lxd/storage_lvm_utils.go
func (s *storageLvm) copyContainerThinpool(target container, source container, readonly bool) error {
	err := s.createSnapshotContainer(target, source, readonly)
	if err != nil {
		logger.Errorf("Error creating snapshot LV for copy: %s", err)
		return err
	}

	// Generate a new xfs's UUID
	LVFilesystem := s.getLvmFilesystem()
	poolName := s.getOnDiskPoolName()
	containerName := target.Name()
	containerLvmName := containerNameToLVName(containerName)
	containerLvDevPath := getLvmDevPath(target.Project(), poolName,
		storagePoolVolumeAPIEndpointContainers, containerLvmName)

	// If btrfstune sees two btrfs filesystems with the same UUID it
	// gets confused and wants both of them unmounted. So unmount
	// the source as well.
	if LVFilesystem == "btrfs" {
		ourUmount, err := s.ContainerUmount(source, source.Path())
		if err != nil {
			return err
		}

		if ourUmount {
			defer s.ContainerMount(source)
		}
	}

	msg, err := fsGenerateNewUUID(LVFilesystem, containerLvDevPath)
	if err != nil {
		logger.Errorf("Failed to create new \"%s\" UUID for container \"%s\" on storage pool \"%s\": %s", LVFilesystem, containerName, s.pool.Name, msg)
		return err
	}

	return nil
}
func (s *storageLvm) copyContainerThinpool(target container, source container, readonly bool) error {
	err := s.createSnapshotContainer(target, source, readonly)
	if err != nil {
		logger.Errorf("Error creating snapshot LV for copy: %s", err)
		return err
	}

	// Generate a new xfs's UUID
	LVFilesystem := s.getLvmFilesystem()
	poolName := s.getOnDiskPoolName()
	containerName := target.Name()
	containerLvmName := containerNameToLVName(containerName)
	containerLvDevPath := getLvmDevPath(target.Project(), poolName,
		storagePoolVolumeAPIEndpointContainers, containerLvmName)

	// If btrfstune sees two btrfs filesystems with the same UUID it
	// gets confused and wants both of them unmounted. So unmount
	// the source as well.
	if LVFilesystem == "btrfs" {
		ourUmount, err := s.ContainerUmount(source, source.Path())
		if err != nil {
			return err
		}

		if ourUmount {
			defer s.ContainerMount(source)
		}
	}

	msg, err := fsGenerateNewUUID(LVFilesystem, containerLvDevPath)
	if err != nil {
		logger.Errorf("Failed to create new \"%s\" UUID for container \"%s\" on storage pool \"%s\": %s", LVFilesystem, containerName, s.pool.Name, msg)
		return err
	}

	return nil
}
// Copy a container on a storage pool that does use a thinpool.