3.4.5.2.41.5 IVdsOpenVDisk::Merge (Opnum 7)

This method is applicable only to differencing type virtual disks. The Merge method moves all data blocks from a differencing virtual disk into its parent virtual disk. Merging a virtual disk requires that the virtual disk be detached during the operation. Both the virtual disk and its parent are opened READ|WRITE using the IVdsVDisk::Open method called against the virtual disk with an appropriate value for the ReadWriteDepth, as described later in this section.<145>

For example, to merge a differencing disk that is a child of a single parent disk into that parent disk, call the IVdsVDisk::Open method on the child disk with the ReadWriteDepth parameter set to the value 2. This value opens both disks with the READ and WRITE flags set, which is necessary for disks to be merged with subsequent call to the IVdsOpenVDisk::Merge method.

 HRESULT Merge(
   [in] MERGE_VIRTUAL_DISK_FLAG Flags,
   [in] ULONG MergeDepth,
   [out] IVdsAsync** ppAsync
 );

Flags: A MERGE_VIRTUAL_DISK_FLAG (section 2.2.2.20.1.4) enumeration value that specifies how the virtual disk is to be merged.

MergeDepth: Number of parent backing store files in the differencing chain to be updated. For example, if MergeDepth has a value of 1, the data blocks from the given differencing disk are moved into its parent. If the given differencing disk's parent is also a differencing disk, (in other words the given disk is diskA, its parent is diskB, and diskB's parent is diskC), and the MergeDepth parameter value is 2, the data blocks from the given differencing disk (diskA) are moved into its parent (diskB), and then its parent's (diskB's) data blocks are moved into its parent (diskC).<146>

ppAsync: A pointer to an IVdsAsync (section 3.1.3.1) interface that, if the operation is successfully completed, receives the IVdsAsync interface to monitor and control this operation. Callers MUST release the interface when they are done with it.

Return Values: The method MUST return zero to indicate success, or return an implementation-specific nonzero error code to indicate failure.

When the server receives this message, it MUST validate the following parameters:

  • Verify that Flags is a bitwise OR of values from the MERGE_VIRTUAL_DISK_FLAG enumeration.

  • Verify that ppAsync is not NULL.

The server MUST perform the following:

  • Create a new async object implementing the IVdsAsync interface with an output type of VDS_ASYNCOUT_MERGE_VDISK and set the pointer ppAsync to the interface.

  • Return an HRESULT indicating failure or success. Any errors encountered up through this point in processing the operation are returned in this HRESULT.

The server MUST then perform the following in sequence. Errors generated in this sequence of steps are returned in the pHrResult parameter to the IVdsAsync::Wait or IVdsAsyncQueryStatus methods.

  • Pass the input parameters to the operating system to merge the disk with its parents.

  • Set the return code in the async object to an HRESULT indicating failure or success of the operating system.

  • If the task completed successfully, set the percentage completed value in the async object to 100.

  • Set the signal state in the async object to TRUE.

At any point in the preceding sequence before the percentage completed value in the async object is 100, the server MUST update the percentage completed value if forward progress is made during the merge operation.