VMware {code} Community
karthimin
Contributor
Contributor

Can any one clarify what went wrong while creating RDM?

Hi all,

For creating RDM we need to do the following:

1.Create the VirtualDeviceConfigSpec and set its properties.

2.Create VirtualMachineConfigSpec object and set the VirtualDeviceConfigSpec to the device change property of VirtualMachineConfigSpec object.

3. Call the ReconfigVM_Task.

If I follow the process 1 specified below getting the error "Incompatible device backing specified for device 0 " as it is unable to create the vmdk file with the path specified in

backingInfo->fileName. If I specify backingInfo->fileName="[datastorename]" then it is creating Virtual Disk with unknown size which is not RDM.

But if I follow the process 2 , first create vmdk file and then specify this file in backingInfo->fileName, its working fine.

But the problem is it works only in case of ESXServer not Virtual Center because for creating VirtualDisk_Task, it takes VirtualDiskManager as

Parameter which is not set in case of Virtual Center.

So we are unable to understand why it is failing to create the RDM in process 1.

I am also enclosing the link where the guy is able to create RDM using Process 1.

Link : http://communities.vmware.com/thread/38923;jsessionid=14172672B2B1D99EBB70617BD6066CE5?tstart=15

We came to know how to set the values for the following properties also

backingInfo->lunUuid

vdCfgSpec->device->unitNumber

vdCfgSpec->device->controllerKey

I also tried setting the below property in process 1 but no use

vdCfgSpec ->fileOperation = VirtualDeviceConfigSpecFileOperation::create;

vdCfgSpec ->fileOperationSpecified = true;

I am still working on this, but if you find any solution on process 1, please let me know.

Thanks & Regards

Neela

1.Process to create a RDM (Error : Incompatible device backing specified for device 0)

==================

/// Create VirtualDeviceConfigSpec object and set its properties

VimApi::VirtualDeviceConfigSpec^ vdCfgSpec = gcnew VimApi::VirtualDeviceConfigSpec();

vdCfgSpec->operation = VirtualDeviceConfigSpecOperation::add;

vdCfgSpec->operationSpecified = true;

vdCfgSpec->device = gcnew VirtualDisk();

VirtualDiskRawDiskMappingVer1BackingInfo^ backingInfo = gcnew VirtualDiskRawDiskMappingVer1BackingInfo();

backingInfo->compatibilityMode = "physicalMode";

/// Need to be changed to the canonical name

backingInfo->deviceName = "vmhba1:1:17:0"; //p_VDisk->;

backingInfo->diskMode = "independent_persistent";

backingInfo->lunUuid = 01002d00003030303032374443303030374d61676e6974; // uuid we can get from the Host

backingInfo->fileName = "[Primary] vm.vmdk";

// Note: set any *Specified values to true

vdCfgSpec->device->backing = backingInfo;

vdCfgSpec->device->connectable = gcnew VirtualDeviceConnectInfo();

vdCfgSpec->device->connectable->allowGuestControl = true;

vdCfgSpec->device->connectable->connected = true;

vdCfgSpec->device->connectable->startConnected = true;

vdCfgSpec->device->controllerKey = 1000;//vdary[iSCSIControllerIndex].key; // you may have one already, or have to create one in this same spec.

vdCfgSpec->device->controllerKeySpecified = true;

vdCfgSpec->device->key = -1; // all devices can be -1, but. all SCSI controllers must have unique -ve values

vdCfgSpec->device->unitNumber = 3; // next device # in SCSI chain... vdCfgSpec[0].device.unitNumberSpecified = true;

vdCfgSpec->device->unitNumberSpecified = true;

VimApi::Description^ deviceInfo = gcnew VimApi::Description();

deviceInfo->label = "HardDisk123";

deviceInfo->summary = "";

vdCfgSpec->device->deviceInfo = deviceInfo;

/// Create the Virtual Machine managed object

VimApi::ManagedObjectReference ^vm = gcnew VimApi::ManagedObjectReference();

vm->type = "VirtualMachine";

Morpheus::Model::VMW_ModelObjectId^ VMobj = safe_cast (this->ObjectId);

vm->Value = VMobj->MOB->Value;

// Create the VirtualMachineConfigSpec object

VimApi::VirtualMachineConfigSpec^ virtualMacConfigSpec = gcnew VimApi::VirtualMachineConfigSpec();

virtualMacConfigSpec->deviceChange = gcnew array ;

m_pVimSvc->ReconfigVM_Task(vm,virtualMacConfigSpec);

2. Process to create a RDM by creating the vmdk file first and then creating RDM (But works only with ESXServer not Virtual Center)

================================================================================================

// Create the VirtualDiskManager MO

VimApi::ManagedObjectReference ^virtualDiskManager = gcnew VimApi::ManagedObjectReference();

virtualDiskManager->type = "VirtualDiskManager";

virtualDiskManager->Value = "ha-vdiskmanager";

/// create a DeviceBackedVirtualDiskSpec ob

VimApi::DeviceBackedVirtualDiskSpec^ virtualDiskSpec = gcnew VimApi::DeviceBackedVirtualDiskSpec();

virtualDiskSpec->diskType = "rdm";

virtualDiskSpec->adapterType = "lsiLogic";

virtualDiskSpec->device = p_VDisk->VMWDevicepath;

pVim->CreateVirtualDisk_Task(virtualDiskManager,"[Primary] vm.vmdk",nullptr,virtualDiskSpec);

/// Create VirtualDeviceConfigSpec object and set its properties

VimApi::VirtualDeviceConfigSpec^ vdCfgSpec = gcnew VimApi::VirtualDeviceConfigSpec();

vdCfgSpec->operation = VirtualDeviceConfigSpecOperation::add;

vdCfgSpec->operationSpecified = true;

vdCfgSpec->device = gcnew VirtualDisk();

VirtualDiskRawDiskMappingVer1BackingInfo^ backingInfo = gcnew VirtualDiskRawDiskMappingVer1BackingInfo();

backingInfo->compatibilityMode = "physicalMode";

/// Need to be changed to the canonical name

backingInfo->deviceName = "vmhba1:1:17:0"; //p_VDisk->;

backingInfo->diskMode = "independent_persistent";

backingInfo->lunUuid = 01002d00003030303032374443303030374d61676e6974; // uuid we can get from the Host

backingInfo->fileName = "[Primary] vm.vmdk";

// Note: set any *Specified values to true

vdCfgSpec->device->backing = backingInfo;

vdCfgSpec->device->connectable = gcnew VirtualDeviceConnectInfo();

vdCfgSpec->device->connectable->allowGuestControl = true;

vdCfgSpec->device->connectable->connected = true;

vdCfgSpec->device->connectable->startConnected = true;

vdCfgSpec->device->controllerKey = 1000;//vdary[iSCSIControllerIndex].key; // you may have one already, or have to create one in this same spec.

vdCfgSpec->device->controllerKeySpecified = true;

vdCfgSpec->device->key = -1; // all devices can be -1, but. all SCSI controllers must have unique -ve values

vdCfgSpec->device->unitNumber = 3; // next device # in SCSI chain... vdCfgSpec[0].device.unitNumberSpecified = true;

vdCfgSpec->device->unitNumberSpecified = true;

VimApi::Description^ deviceInfo = gcnew VimApi::Description();

deviceInfo->label = "HardDisk123";

deviceInfo->summary = "";

vdCfgSpec->device->deviceInfo = deviceInfo;

/// Create the Virtual Machine managed object

VimApi::ManagedObjectReference ^vm = gcnew VimApi::ManagedObjectReference();

vm->type = "VirtualMachine";

Morpheus::Model::VMW_ModelObjectId^ VMobj = safe_cast (this->ObjectId);

vm->Value = VMobj->MOB->Value;

// Create the VirtualMachineConfigSpec object

VimApi::VirtualMachineConfigSpec^ virtualMacConfigSpec = gcnew VimApi::VirtualMachineConfigSpec();

virtualMacConfigSpec->deviceChange = gcnew array ;

m_pVimSvc->ReconfigVM_Task(vm,virtualMacConfigSpec);

Reply
0 Kudos
2 Replies
Niket
Enthusiast
Enthusiast

Hi,

It looks like you problem is in defining vdCfgSpec of type VirtualDeviceConfigSpec.

DeviceChange property of virtualMacConfigSpec needs an array object of type VirtualDeviceConfigSpec and setting for each device, which needs to set using the index of array something like this. vdCfgSpec[0]->operationSpecified = true;

Finally you should call populate the property device change like this.

virtualMacConfigSpec->deviceChange = vdCfgSpec //vdCfgSpec should already defined as an array in the starting of program.

While you code snippet

virtualMacConfigSpec->deviceChange = gcnew array ;

is not getting an array of VirtualDeviceConfigSpec and moreover no property didn't set for an element of VirtualDeviceConfigSpec object.

I hope it helps to make the changes in the code and would work.

Please let us know, if you still facing the issue.

Thanks

Niket

Reply
0 Kudos
hishivahere
Contributor
Contributor

Hi Niket,

Thanks for the reply.

I tried the steps you suggeted.still get the same error.

I am also enclosing the code changes.Let me know if something needs to be hanged

Regards

Neela

array<VirtualDeviceConfigSpec> vdCfgSpec = gcnew array<VirtualDeviceConfigSpec^>(1);

vdCfgSpec[0] = gcnew VirtualDeviceConfigSpec();

vdCfgSpec[0]->operation = VirtualDeviceConfigSpecOperation::add;

vdCfgSpec[0]->operationSpecified = true;

vdCfgSpec[0]->device = gcnew VirtualDisk();

VirtualDiskRawDiskMappingVer1BackingInfo^ backingInfo = gcnew VirtualDiskRawDiskMappingVer1BackingInfo();

backingInfo->compatibilityMode = "physicalMode";

/// Need to be changed to the canonical name

backingInfo->deviceName = "vmhba1:0:1:0"; //p_VDisk->;

backingInfo->diskMode = "persistent";

backingInfo->lunUuid = "01000100003030303032374535303031464d61676e6974"; // uuid we can get from the Host

//backingInfo->datastore = nullptr;

backingInfo->fileName = "[storage1] TestVM/TestVM_1.vmdk";

// Note: set any *Specified values to true

vdCfgSpec[0]->device->backing = backingInfo;

vdCfgSpec[0]->device->connectable = gcnew VirtualDeviceConnectInfo();

vdCfgSpec[0]->device->connectable->allowGuestControl = true;

vdCfgSpec[0]->device->connectable->connected = true;

vdCfgSpec[0]->device->connectable->startConnected = true;

vdCfgSpec[0]->device->controllerKey = 1000;//vdary[iSCSIControllerIndex].key; // you may have one already, or have to create one in this same spec.

vdCfgSpec[0]->device->controllerKeySpecified = true;

vdCfgSpec[0]->device->key = -1; // all devices can be -1, but. all SCSI controllers must have unique -ve values

vdCfgSpec[0]->device->unitNumber = 6; // next device # in SCSI chain... vdCfgSpec[0].device.unitNumberSpecified = true;

vdCfgSpec[0]->device->unitNumberSpecified = true;

VimApi::Description^ deviceInfo = gcnew VimApi::Description();

deviceInfo->label = "ShivaDisk";

deviceInfo->summary = "";

vdCfgSpec[0]->device->deviceInfo = deviceInfo;

/// Create the Virtual Machine managed object

VimApi::ManagedObjectReference ^vm = gcnew VimApi::ManagedObjectReference();

vm->type = "VirtualMachine";

vm->Value = "16";

// Create the VirtualMachineConfigSpec object

VimApi::VirtualMachineConfigSpec^ virtualMacConfigSpec = gcnew VimApi::VirtualMachineConfigSpec();

virtualMacConfigSpec->deviceChange = vdCfgSpec;

m_pVimSvc->ReconfigVM_Task(vm,virtualMacConfigSpec);

Reply
0 Kudos