Exemplo n.º 1
0
        private void ResolveFileChain()
        {
            VirtualDiskLayer file = _files[_files.Count - 1].First;

            while (file.NeedsParent)
            {
                bool        foundParent = false;
                FileLocator locator     = file.RelativeFileLocator;

                foreach (string posParent in file.GetParentLocations())
                {
                    if (locator.Exists(posParent))
                    {
                        file = VirtualDisk.OpenDiskLayer(file.RelativeFileLocator, posParent, FileAccess.Read);
                        _files.Add(new ThinkAway.Tuple <VirtualDiskLayer, Ownership>(file, Ownership.Dispose));
                        foundParent = true;
                        break;
                    }
                }

                if (!foundParent)
                {
                    throw new IOException("Parent disk not found");
                }
            }
        }
Exemplo n.º 2
0
        private static DiskCreateType DiffDiskCreateType(VirtualDiskLayer layer)
        {
            DiskImageFile vmdkLayer = layer as DiskImageFile;

            if (vmdkLayer != null)
            {
                switch (vmdkLayer.CreateType)
                {
                case DiskCreateType.FullDevice:
                case DiskCreateType.MonolithicFlat:
                case DiskCreateType.MonolithicSparse:
                case DiskCreateType.PartitionedDevice:
                case DiskCreateType.StreamOptimized:
                case DiskCreateType.TwoGbMaxExtentFlat:
                case DiskCreateType.TwoGbMaxExtentSparse:
                    return(DiskCreateType.MonolithicSparse);

                default:
                    return(DiskCreateType.VmfsSparse);
                }
            }
            else
            {
                return(DiskCreateType.MonolithicSparse);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a new differencing disk.
        /// </summary>
        /// <param name="path">The path (or URI) for the disk to create.</param>
        /// <returns>The newly created disk.</returns>
        public override VirtualDisk CreateDifferencingDisk(string path)
        {
            VirtualDiskLayer firstLayer = _files[0].Item1;

            return(InitializeDifferencing(path, DiffDiskCreateType(firstLayer),
                                          firstLayer.RelativeFileLocator.GetFullPath(_path)));
        }
Exemplo n.º 4
0
 private static DiskCreateType DiffDiskCreateType(VirtualDiskLayer layer)
 {
     DiskImageFile vmdkLayer = layer as DiskImageFile;
     if (vmdkLayer != null)
     {
         switch (vmdkLayer.CreateType)
         {
             case DiskCreateType.FullDevice:
             case DiskCreateType.MonolithicFlat:
             case DiskCreateType.MonolithicSparse:
             case DiskCreateType.PartitionedDevice:
             case DiskCreateType.StreamOptimized:
             case DiskCreateType.TwoGbMaxExtentFlat:
             case DiskCreateType.TwoGbMaxExtentSparse:
                 return DiskCreateType.MonolithicSparse;
             default:
                 return DiskCreateType.VmfsSparse;
         }
     }
     else
     {
         return DiskCreateType.MonolithicSparse;
     }
 }