<div class="content"><p> </p><p>The CreateVolume method creates a <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_9a876829-33a1-4f0b-8b81-8552b7e5561c" data-linktype="relative-path">volume</a></span> in a <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_a6543827-8d70-4e5a-a982-2fdc2e7f8bca" data-linktype="relative-path">disk pack</a></span>.</p><dl>
<dd>
<div><pre> HRESULT CreateVolume(
   [in] VDS_VOLUME_TYPE type,
   [in, size_is(lNumberOfDisks)] VDS_INPUT_DISK* pInputDiskArray,
   [in] long lNumberOfDisks,
   [in] unsigned long ulStripeSize,
   [out] IVdsAsync** ppAsync
 );
</pre></div>
</dd></dl><p><b>type: </b>A value from the <span><a href="7d8726fc-4c14-45b5-b085-9644097811ae" data-linktype="relative-path">VDS_VOLUME_TYPE</a></span>
enumeration that indicates the type of volume to create.</p><p><b>pInputDiskArray: </b>An array of <span><a href="2ec3b542-a7d7-4927-bdd6-b0dc8a8881ae" data-linktype="relative-path">VDS_INPUT_DISK</a></span>
structures that indicate the <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_c4133b2a-a990-4042-ba44-7fda3090f118" data-linktype="relative-path">disks</a></span> on which to
create the volume.<a id="Appendix_A_Target_80"></a><a aria-label="Product behavior note 80" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_80" data-linktype="relative-path">&lt;80&gt;</a></p><p><b>lNumberOfDisks: </b>The number of elements in <b>pInputDiskArray</b>.</p><p><b>ulStripeSize: </b>The stripe size of the new
volume.<a id="Appendix_A_Target_81"></a><a aria-label="Product behavior note 81" href="6b2552ee-ba27-409f-99a8-18841573327a#Appendix_A_81" data-linktype="relative-path">&lt;81&gt;</a></p><p><b>ppAsync: </b>A pointer to an <span><a href="97ea9c0f-5c8a-43e9-a9ee-deda29e2a09e" data-linktype="relative-path">IVdsAsync</a></span>
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. If the IVdsAsync::Wait (Opnum 4)
method is called on the interface, the interfaces returned in the <span><a href="d21dadd7-b2ed-4c02-8fd2-83264272d277" data-linktype="relative-path">VDS_ASYNC_OUTPUT</a></span>
structure MUST be released as well. For information on handling asynchronous
tasks, see section <span><a href="28fc0a76-54bc-4d7d-81c3-37cf36586b23" data-linktype="relative-path">3.4.5.1.9</a></span>.</p><p><b>Return Values: </b>The method MUST return zero or
a non-error <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_799103ab-b3cb-4eab-8c55-322821b2b235" data-linktype="relative-path">HRESULT</a></span> (as
specified in <span><a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a></span>)
to indicate success, or return an implementation-specific nonzero error code to
indicate failure. For the HRESULT values predefined by the Virtual Disk Service
Remote Protocol, see section <span><a href="5102cc53-3143-4268-ba4c-6ea39e999ab4" data-linktype="relative-path">2.2.3</a></span>.</p><p>When the server receives this message, it MUST validate the
following parameters:</p><ul><li><p><span><span> 
</span></span>Verify that <b>pInputDiskArray</b> is not NULL.</p>
</li><li><p><span><span> 
</span></span>Verify that the specified disk(s) belong to the given pack.</p>
</li><li><p><span><span> 
</span></span>Verify that <b>ppAsync</b> is not NULL.</p>
</li></ul><p>The server MUST perform the following:</p><ul><li><p><span><span> 
</span></span>Verify that the volume size that is specified using the array of
VDS_INPUT_DISK structures is greater than zero. The requested size of the
volume is equal to the sum of the <b>ullSize</b> members of each element in the
array of VDS_INPUT_DISK structures.  If the volume size is not greater than
zero, then the server MUST return VDS_E_EXTENT_SIZE_LESS_THAN_MIN.</p>
</li><li><p><span><span> 
</span></span>For each VDS_INPUT_DISK structure in the <i>pInputDiskArray</i>
parameter, verify that the value of the <b>ullSize</b> field does not exceed
the amount of free space on the given disk. If the volume is being created
within a dynamic disk pack and if this requirement is not met, then the server
MUST return VDS_E_EXTENT_EXCEEDS_DISK_FREE_SPACE. If the volume is being
created in a basic disk pack and if this requirement is not being met, then the
server MUST return VDS_E_NOT_ENOUGH_SPACE.</p>
</li><li><p><span><span> 
</span></span>Create a new async object implementing the IVdsAsync interface
with an output type of VDS_ASYNCOUT_CREATEVOLUME and set the pointer that <b>ppAsync</b>
references to the interface.</p>
</li><li><p><span><span> 
</span></span>Return an HRESULT indicating failure or success. Any errors
encountered up until this point in processing the CreateVolume operation are
returned in this HRESULT. </p>
</li></ul><p>The server MUST then perform the following in sequence.
Errors generated in this sequence of steps are returned in the <b>pHrResult</b>
parameter to the <span><a href="ccba511e-b299-4153-bb2f-c25ba97840f4" data-linktype="relative-path">IVdsAsync::Wait</a></span> or
IVdsAsyncQueryStatus methods. </p><ul><li><p><span><span> 
</span></span>Create a new volume that uses the parameters that are specified
for this method.</p>
<ul><li><p><span><span>  </span></span>If
the volume creation resulted in the renumbering of existing <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_2f24f458-7d39-47a2-93f7-de433ea85c75" data-linktype="relative-path">partitions</a></span>
on a boot disk, the server MUST update the <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_f1bdb0a4-803c-4cb5-ab76-82f6886a5031" data-linktype="relative-path">boot configuration file</a></span>
with the new partition numbering.</p>
</li></ul></li><li><p><span><span> 
</span></span>Create a new volume object that corresponds to the new volume, implement
the <span><a href="555601e2-1103-4423-b62b-0b1f3d3370e6" data-linktype="relative-path">IVdsVolume</a></span>
interface, and assign it a unique <span><a href="9186f1ce-04de-4df2-a8cf-3925a02fcd47" data-linktype="relative-path">VDS_OBJECT_ID</a></span>.</p>
</li><li><p><span><span> 
</span></span>Set the volume object&#39;s <span><a href="8eef5d42-22d7-4302-aed9-12face91505a#gt_890bb28d-df68-420f-a8bc-83899d34ad5c" data-linktype="relative-path">pack</a></span> pointer to this
pack object.</p>
</li><li><p><span><span> 
</span></span>Create new volume plex objects that correspond to the new volume
plexes, implement the IVdsVolumePlex interface, and assign it a unique
VDS_OBJECT_ID.</p>
</li><li><p><span><span> 
</span></span>Set the volume plex object&#39;s volume pointer to this volume
object.</p>
</li><li><p><span><span> 
</span></span>Add the volume plex object to the list of storage management
objects. </p>
</li><li><p><span><span> 
</span></span>Add the volume object to the list of storage management objects.</p>
</li><li><p><span><span> 
</span></span>Set the task-specific return values in the async object to return
the values that are associated with VDS_ASYNCOUT_CREATEVOLUME. See section
3.4.5.1.9.</p>
</li><li><p><span><span> 
</span></span>Set the return code in the async object to an HRESULT indicating
failure or success.</p>
<ul><li><p><span><span>  </span></span>If
the server tried to update the boot configuration file but failed, the return
code MUST be set to VDS_S_UPDATE_BOOTFILE_FAILED (HRESULT of 0x80042434).</p>
</li></ul></li><li><p><span><span> 
</span></span>If the task completed successfully, set the percentage completed
value in the async object to 100.</p>
</li><li><p><span><span> 
</span></span>Set the signal state in the async object to TRUE.</p>
</li><li><p><span><span> 
</span></span>For each callback object registered in the list of callback
objects, call the callback object&#39;s IVdsAdviseSink::OnNotify (Opnum 3) method
with a <span><a href="4f29057f-ab32-4a3d-9fcb-00ba3457cb42" data-linktype="relative-path">VDS_NOTIFICATION</a></span>
structure with the following attributes:</p>
<ul><li><p><span><span>  </span></span><b>objectType</b>
member is VDS_NTT_VOLUME.</p>
</li><li><p><span><span>  </span></span><b>Volume</b>
member is a <span><a href="410540de-982d-4db1-991e-a73efed4e6f0" data-linktype="relative-path">VDS_VOLUME_NOTIFICATION</a></span>
with the following attributes:</p>
<ul><li><p><span><span> 
</span></span><b>ulEvent</b> is VDS_NF_VOLUME_ARRIVE.</p>
</li><li><p><span><span> 
</span></span><b>volumeId</b> is the VDS_OBJECT_ID of the volume object that
was added.</p>
</li><li><p><span><span> 
</span></span><b>plexId</b> SHOULD be GUID_NULL, but it is not relevant when <b>ulEvent</b>
is VDS_NF_VOLUME_ARRIVE.</p>
</li><li><p><span><span> 
</span></span><b>ulPercentCompleted</b> ranges from 0-100; however, it is not
relevant when <b>ulEvent</b> is VDS_NF_VOLUME_ARRIVE.</p>
</li></ul></li></ul></li></ul><p>The server MUST update the percentage completed value
periodically during the preceding sequence. How often the percentage completed
is updated, and at what point in the sequence, is implementation-specific.</p></div>