func (s *storageBtrfs) ContainerSnapshotCreateEmpty(snapshotContainer container) error {
	logger.Debugf("Creating empty BTRFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)

	// Mount the storage pool.
	_, err := s.StoragePoolMount()
	if err != nil {
		return err
	}

	// Create the snapshot subvole path on the storage pool.
	sourceName, _, _ := containerGetParentAndSnapshotName(snapshotContainer.Name())
	snapshotSubvolumePath := getSnapshotSubvolumePath(snapshotContainer.Project(), s.pool.Name, sourceName)
	snapshotSubvolumeName := getSnapshotMountPoint(snapshotContainer.Project(), s.pool.Name, snapshotContainer.Name())
	if !shared.PathExists(snapshotSubvolumePath) {
		err := os.MkdirAll(snapshotSubvolumePath, containersDirMode)
		if err != nil {
			return err
		}
	}

	err = btrfsSubVolumeCreate(snapshotSubvolumeName)
	if err != nil {
		return err
	}

	snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", projectPrefix(snapshotContainer.Project(), sourceName))
	snapshotMntPointSymlink := shared.VarPath("snapshots", projectPrefix(snapshotContainer.Project(), sourceName))
	if !shared.PathExists(snapshotMntPointSymlink) {
		err := createContainerMountpoint(snapshotMntPointSymlinkTarget, snapshotMntPointSymlink, snapshotContainer.IsPrivileged())
		if err != nil {
			return err
		}
	}

	logger.Debugf("Created empty BTRFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
	return nil
}
func (s *storageBtrfs) ContainerSnapshotCreateEmpty(snapshotContainer container) error {
	logger.Debugf("Creating empty BTRFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)

	
	_, err := s.StoragePoolMount()
	if err != nil {
		return err
	}

	
	sourceName, _, _ := containerGetParentAndSnapshotName(snapshotContainer.Name())
	snapshotSubvolumePath := getSnapshotSubvolumePath(snapshotContainer.Project(), s.pool.Name, sourceName)
	snapshotSubvolumeName := getSnapshotMountPoint(snapshotContainer.Project(), s.pool.Name, snapshotContainer.Name())
	if !shared.PathExists(snapshotSubvolumePath) {
		err := os.MkdirAll(snapshotSubvolumePath, containersDirMode)
		if err != nil {
			return err
		}
	}

	err = btrfsSubVolumeCreate(snapshotSubvolumeName)
	if err != nil {
		return err
	}

	snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", projectPrefix(snapshotContainer.Project(), sourceName))
	snapshotMntPointSymlink := shared.VarPath("snapshots", projectPrefix(snapshotContainer.Project(), sourceName))
	if !shared.PathExists(snapshotMntPointSymlink) {
		err := createContainerMountpoint(snapshotMntPointSymlinkTarget, snapshotMntPointSymlink, snapshotContainer.IsPrivileged())
		if err != nil {
			return err
		}
	}

	logger.Debugf("Created empty BTRFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
	return nil
}
func ( s * storageBtrfs ) ContainerSnapshotCreateEmpty ( snapshotContainer container ) error { logger . Debugf ( " \" \" \" \" " , s . volume . Name , s . pool . Name ) // Mount the storage pool. _ , err := s . StoragePoolMount ( ) if err != nil { return err } // Create the snapshot subvole path on the storage pool. sourceName , _ , _ := containerGetParentAndSnapshotName ( snapshotContainer . Name ( ) ) snapshotSubvolumePath := getSnapshotSubvolumePath ( snapshotContainer . Project ( ) , s . pool . Name , sourceName ) snapshotSubvolumeName := getSnapshotMountPoint ( snapshotContainer . Project ( ) , s . pool . Name , snapshotContainer . Name ( ) ) if ! shared . PathExists ( snapshotSubvolumePath ) { err := os . MkdirAll ( snapshotSubvolumePath , containersDirMode ) if err != nil { return err } } err = btrfsSubVolumeCreate ( snapshotSubvolumeName ) if err != nil { return err } snapshotMntPointSymlinkTarget := shared . VarPath ( " " , s . pool . Name , " " , projectPrefix ( snapshotContainer . Project ( ) , sourceName ) ) snapshotMntPointSymlink := shared . VarPath ( " " , projectPrefix ( snapshotContainer . Project ( ) , sourceName ) ) if ! shared . PathExists ( snapshotMntPointSymlink ) { err := createContainerMountpoint ( snapshotMntPointSymlinkTarget , snapshotMntPointSymlink , snapshotContainer . IsPrivileged ( ) ) if err != nil { return err } } logger . Debugf ( " \" \" \" \" " , s . volume . Name , s . pool . Name ) return nil }
// Needed for live migration where an empty snapshot needs to be created before
// rsyncing into it.
Needed for live migration where an empty snapshot needs to be created before rsyncing into it .