IVMVirtualMachine::AddHardDiskConnection method

The AddHardDiskConnection method adds a new hard disk connection to the virtual machine.

Syntax

HRESULT AddHardDiskConnection(
  [in]  BSTR                  hardDiskPath,
  [in]  VMDriveBusType        busType,
  [in]  long                  busNumber,
  [in]  long                  deviceNumber,
  [out] IVMHardDiskConnection **hardDiskConnection
);

Parameters

hardDiskPath [in]

Full path specifying the virtual hard disk file to connect

busType [in]

Bus to attach the hard disk drive to.

busNumber [in]

Bus number to attach the hard disk to. For IDE, this number can be 0-1. For SCSI, this number is an index from 0 to the number returned by IVMSCSIControllerCollection::Count.

deviceNumber [in]

Device number to attach the hard disk to. For IDE, this number can be 0-1. For SCSI, this number can be 0-6.

hardDiskConnection [out]

A new IVMHardDiskConnection object.

Return value

This method supports standard return values, as well as the following. For information on Virtual Server specific return values not listed below, see HRESULT Codes Specific to the Virtual Server.

Return code Description
S_OK
The operation was successful.
E_POINTER
The hardDiskPath parameter is NULL, empty, or not valid; the busType, busNumber, or deviceNumber parameter is not valid.
E_POINTER
The hardDiskConnection parameter is NULL.
E_FILE_NOT_FOUND
The system cannot find the file specified by the hardDiskPath parameter.
E_PATH_NOT_FOUND
The system cannot find the path specified by the hardDiskPath parameter.
E_INVALID_NAME
The hardDiskPath parameter contains an invalid character (one of "*?<>/|":").
E_BAD_PATHNAME
The hardDiskPath parameter specifies an empty or relative path. An absolute path is required.
E_BUFFER_OVERFLOW
The path specified by the hardDiskPath parameter is too long. The path must be less than 260 characters.
VM_E_VM_UNKNOWN
The configuration is unknown.
VM_E_VM_RUNNING
Virtual machine is running or saved.
VM_E_DRIVE_BUS_LOC_IN_USE
The specified bus location is in use.
E_SHARING_VIOLATION
The specified hard disk file is already connected to another bus location for this virtual machine.
DISP_E_EXCEPTION
An unexpected error has occurred.

Remarks

You can only add a new hard disk connection to a stopped virtual machine.

Requirements

Product
Microsoft Virtual Server 2005 onWindows Server 2003
Download
Microsoft Virtual Server 2005 R2 SP1 Update onWindows Server 2008orWindows Server 2003
Header
VsComInterfaces.h

See also

IVMVirtualMachine

VMDriveBusType