3.4.5.2.17.3 IVdsVdProvider::AddVDisk (Opnum 5)

The AddVDisk method creates a virtual disk object representing the specified virtual disk and adds it to the list of virtual disks managed by the provider. This method returns an IVdsVDisk (section 3.1.15.1) interface pointer to the specified virtual disk object.

 HRESULT AddVDisk(
   [in] PVIRTUAL_STORAGE_TYPE VirtualDeviceType,
   [in, string] LPWSTR pPath,
   [out] IVdsVDisk** ppVDisk
 );

VirtualDeviceType: A pointer to a VIRTUAL_STORAGE_TYPE (section 2.2.1.3.23) structure that specifies the type of virtual hard disk to open.

pPath: A NULL-terminated wide-character string containing the fully qualified pathname for the virtual disk's backing file.

ppVDisk: A pointer to a variable that, if the operation is successfully completed, receives an IVdsVDisk interface pointer to the newly created virtual disk object. Callers MUST release the interface pointer when it is no longer needed by calling the IUnknown::Release method.

Return Values: The method MUST return zero or a nonerror HRESULT (as specified in [MS-ERREF]) 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 2.2.3.

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

  • Verify that VirtualDeviceType is not NULL.

  • Verify that pPath is not NULL.

  • Verify that ppVDisk is not NULL.

The server MUST then perform the following in sequence:

  • Search its cached virtual disk objects for an object whose file name matches the input pPath. If such an object does not exist, create a new virtual disk cache object that implements the IVdsVDisk interface and assign it a unique VDS_OBJECT_ID (section 2.2.1.1.3).

  • Point ppVDisk to an IVdsVDisk interface of the virtual disk object found or created and return an HRESULT indicating success.