lxd/storage_lvm_utils.go
func (s *storageLvm) copyContainer(target container, source container, refresh bool) error {
	targetPool, err := target.StoragePool()
	if err != nil {
		return err
	}

	targetContainerMntPoint := getContainerMountPoint(target.Project(), targetPool, target.Name())
	err = createContainerMountpoint(targetContainerMntPoint, target.Path(), target.IsPrivileged())
	if err != nil {
		return err
	}

	sourcePool, err := source.StoragePool()
	if err != nil {
		return err
	}

	if s.useThinpool && targetPool == sourcePool && !refresh {
		// If the storage pool uses a thinpool we can have snapshots of
		// snapshots.
		err = s.copyContainerThinpool(target, source, false)
	} else {
		// If the storage pools does not use a thinpool we need to
		// perform full copies.
		err = s.copyContainerLv(target, source, false, refresh)
	}
	if err != nil {
		return err
	}

	err = target.TemplateApply("copy")
	if err != nil {
		return err
	}

	return nil
}
func (s *storageLvm) copyContainer(target container, source container, refresh bool) error {
	targetPool, err := target.StoragePool()
	if err != nil {
		return err
	}

	targetContainerMntPoint := getContainerMountPoint(target.Project(), targetPool, target.Name())
	err = createContainerMountpoint(targetContainerMntPoint, target.Path(), target.IsPrivileged())
	if err != nil {
		return err
	}

	sourcePool, err := source.StoragePool()
	if err != nil {
		return err
	}

	if s.useThinpool && targetPool == sourcePool && !refresh {
		// If the storage pool uses a thinpool we can have snapshots of
		// snapshots.
		err = s.copyContainerThinpool(target, source, false)
	} else {
		// If the storage pools does not use a thinpool we need to
		// perform full copies.
		err = s.copyContainerLv(target, source, false, refresh)
	}
	if err != nil {
		return err
	}

	err = target.TemplateApply("copy")
	if err != nil {
		return err
	}

	return nil
}
// Copy an lvm container.