VMware {code} Community
Dreamer732
Contributor
Contributor

Attaching a RDM to VM. Can you please tell what am i missing here?

Hi,

I am using the below configuration spec to attach a RDM (raw disk - pass-throuh)

However attaching is failing:(

It says Invalid configuration for device '0'.

Any help is greatly appreciated as i am struck:(?

VirtualDisk virtualDisk = new VirtualDisk();

//disk info

virtualDisk.controllerKey = controllerKey;

virtualDisk.controllerKeySpecified = true;

virtualDisk.unitNumber = location;

virtualDisk.unitNumberSpecified = true;

//backing file info 

VirtualDiskRawDiskMappingVer1BackingInfo backing = new VirtualDiskRawDiskMappingVer1BackingInfo();

backing.lunUuid = uuid;

backing.compatibilityMode = "physicalMode";

backing.diskMode ="persistent";

backing.deviceName = "vml.0200030000600601607f412e003c84c498fc52e111565241494420"; //TODO

backing.datastore = datastoremor

backing.fileName = "[DS_193]";  //do i have to specify the file? is it the mapping vmdk file?

   //isnt the framework automaitcally create mapping file?

virtualDisk.backing = backing;

//config spec

VirtualDeviceConfigSpec vdConfigSpecEdit = new VirtualDeviceConfigSpec();

vdConfigSpecEdit.device = virtualDisk;

vdConfigSpecEdit.operation =VirtualDeviceConfigSpecOperation.add;

vdConfigSpecEdit.operationSpecified = true;

vdConfigSpecEdit.fileOperation =VirtualDeviceConfigSpecFileOperation.create;

vdConfigSpecEdit.fileOperationSpecified =false;

VirtualMachineConfigSpec vmConfigSpecEdit = new VirtualMachineConfigSpec();

vmConfigSpecEdit.deviceChange = new VirtualDeviceConfigSpec[1];

vmConfigSpecEdit.deviceChange[0] = vdConfigSpecEdit;

Regards,

Dreamer

0 Kudos
8 Replies
Dreamer732
Contributor
Contributor

I tried this. Basically i didnt specify the filename and datastore.

VirtualDiskRawDiskMappingVer1BackingInfo backing = new VirtualDiskRawDiskMappingVer1BackingInfo();

backing.lunUuid = taskSpec.ScsiLun.Uuid;

backing.compatibilityMode =

"physicalMode"; //TODO

backing.diskMode =

"persistent"; //TODO

backing.deviceName =

"vml.0200030000600601607f412e003c84c498fc52e111565241494420"; //TODO

Debug.Assert(this.m_vmIdDatastoreMap.ContainsKey(taskSpec.VmGuid)

&&

this.m_vmIdDatastoreMap[taskSpec.VmGuid].Length > 0);

//backing.datastore = this.m_vmIdDatastoreMap[taskSpec.VmGuid][0];

//backing.fileName = "[DS_193]";

virtualDisk.backing = backing;

And its giving the following error:(

Looks like i should give a file. BUT SHOULD I CREATE A FILE OR JUST GIVE A FILENAME TO BE CREATED?

ANY DOCUMENTATION?

TaskStatus: Faulted

Required property fileName is missing from data object of type VirtualDiskRawDiskMappingVer1BackingInfo

while parsing serialized DataObject of type vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo
at line 1, column 380

while parsing property "backing" of static type VirtualDeviceBackingInfo

while parsing serialized DataObject of type vim.vm.device.VirtualDisk
at line 1, column 337

while parsing property "device" of static type VirtualDevice

while parsing serialized DataObject of type vim.vm.device.VirtualDeviceSpec
at line 1, column 297

while parsing property "deviceChange" of static type ArrayOfVirtualDeviceConfigSpec

while parsing serialized DataObject of type vim.vm.ConfigSpec
at line 1, column 291

while parsing call information for method ReconfigVM_Task
at line 1, column 218

while parsing SOAP body
at line 1, column 207

while parsing SOAP envelope
at line 1, column 38

while parsing HTTP request for method reconfigure
on object of type vim.VirtualMachine
at line 1, column 0
PS C:\>

Regards,

Naresh

0 Kudos
Dreamer732
Contributor
Contributor

Now, i tried this by giving the datastore but leaving the filename empty as assuming the framework will generate one for me.

VirtualDiskRawDiskMappingVer1BackingInfo backing = new VirtualDiskRawDiskMappingVer1BackingInfo();

backing.lunUuid = taskSpec.ScsiLun.Uuid;

backing.compatibilityMode ="physicalMode"; //TODO

backing.diskMode ="persistent"; //TODO

backing.deviceName ="vml.0200030000600601607f412e003c84c498fc52e111565241494420"; //TODO

backing.datastore = mor;

backing.fileName ="";

virtualDisk.backing = backing;

Now, i am getting the following error:

Invalid datastore format ''.

Regards,

Naresh

0 Kudos
Dreamer732
Contributor
Contributor

Now, i gave the connectable info, but still getting the same error.

VirtualDiskRawDiskMappingVer1BackingInfo backing = new VirtualDiskRawDiskMappingVer1BackingInfo();

backing.lunUuid = taskSpec.ScsiLun.Uuid;

backing.compatibilityMode ="physicalMode"; //TODO

backing.diskMode ="persistent"; //TODO

backing.deviceName ="vml.0200030000600601607f412e003c84c498fc52e111565241494420"; //TODO

backing.datastore = mor;

backing.fileName ="";

VirtualDeviceConnectInfo connectable = new VirtualDeviceConnectInfo();

connectable.startConnected =true;

connectable.allowGuestControl =false;

connectable.connected =true;

virtualDisk.connectable = connectable;

virtualDisk.backing = backing;

Invalid datastore format ''.

Regards,

Dreamer

0 Kudos
lamw
Community Manager
Community Manager

Take a look at this script which allows you to add/remote and RDM to a VM (it's written using vSphere SDK for Perl) but you can disect it to convert it to .NET - http://communities.vmware.com/docs/DOC-10974

Dreamer732
Contributor
Contributor

Hi,

Finally i was able to add rdm after lots of trail and errors...

1. I am giving wrong device name. I was giving "vml" + lunuuid as the managed object browser showed that. Now assigning the device name from the ScsiLun.

2. I need to set the fileOperationSpecified to true even though i specified the file operation to create.

3. Filename can be set to "" to let the framework give a name for the mapping file.

the config spec i used:

VirtualDisk rdmDisk = new VirtualDisk();

//disk info

rdmDisk.controllerKey = key;

rdmDisk.controllerKeySpecified = true;

rdmDisk.unitNumber = location;

rdmDisk.unitNumberSpecified = true;

//backing rawdevice info

VirtualDiskRawDiskMappingVer1BackingInfo backing = new VirtualDiskRawDiskMappingVer1BackingInfo();

backing.lunUuid = taskSpec.ScsiLun.Uuid;

backing.compatibilityMode = "physicalMode"; //TODO

backing.diskMode = "independent_persistent"; //TODO

backing.deviceName = taskSpec.ScsiLun.DeviceName;

backing.datastore = mor;

//Framework will automatically assigns filename

backing.fileName = "";

rdmDisk.backing = backing;

//config spec

VirtualDeviceConfigSpec vdConfigSpecEdit = new VirtualDeviceConfigSpec();

vdConfigSpecEdit.device = rdmDisk;

vdConfigSpecEdit.operation = VirtualDeviceConfigSpecOperation.add;

vdConfigSpecEdit.operationSpecified = true;

vdConfigSpecEdit.fileOperation = VirtualDeviceConfigSpecFileOperation.create;

vdConfigSpecEdit.fileOperationSpecified = true;

VirtualMachineConfigSpec vmConfigSpecEdit = new VirtualMachineConfigSpec();

vmConfigSpecEdit.deviceChange = new VirtualDeviceConfigSpec[1];

vmConfigSpecEdit.deviceChange[0] = vdConfigSpecEdit;

Regards,

Dreamer

0 Kudos
Dreamer732
Contributor
Contributor

I am using 5.0 sdk and the code is working for adding rdm disks to VMs of ESX hosts (5.0).

But the same code is failing for vms on ESX 4.1

I am getting the same error again: Invalid configuration for device '0'

Any help is greatly appreciated as i have no clue how to fix it...

Regards,

Naresh

0 Kudos
Dreamer732
Contributor
Contributor

Now I tried using 4.1 sdk and still getting the same error.

Not sure whats happening. Same code works for vms on 5.0 esx host with 5.0 sdk (vim25 definitions) and not for vms on 4.1 esx host (both 5.0 and 4.1 sdks)

And the error doesnt give any info.

It simply says invalid configuration for device '0'.

i have no clue what does that mean.

its frustrating...

-Naresh

0 Kudos
sivakaminathan
Contributor
Contributor

HI All

I am getting same error while add rdm to vm.

Same eror : Invalid Operation for device '0'

I didn't set the controller key,unitnumber and key in virtualdevice object.

Where i find those info in mob.

VirtualDiskRawDiskMappingVer1BackingInfo rdm = new VirtualDiskRawDiskMappingVer1BackingInfo();
rdm.setLunUuid(scsiDisk.get(0).getUuid());
rdm.setFileName("[RDM]");
rdm.setDiskMode("independent_persistent");
rdm.setDeviceName(scsiDisk.get(0).getDeviceName());
rdm.setDatastore(ds);
rdm.setCompatibilityMode(VirtualDiskCompatibilityMode._physicalMode);
VirtualDeviceConnectInfo vdcinfo = new VirtualDeviceConnectInfo();
vdcinfo.setAllowGuestControl(false);
vdcinfo.setStartConnected(true);
vdcinfo.setConnected(true);
VirtualDevice vd = new VirtualDevice();
vd.setBacking(rdm);
vd.setConnectable(vdcinfo);
VirtualDeviceConfigSpec vdConfSpec = new VirtualDeviceConfigSpec();
vdConfSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
vdConfSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.create);
vdConfSpec.setDevice(vd);
VirtualMachineConfigSpec vmConf = new VirtualMachineConfigSpec();
vmConf.setDeviceChange(new VirtualDeviceConfigSpec[]{vdConfSpec});
VExecutor.getInstance().getServiceInstance().reconfigVM_Task(vm, vmConf);
0 Kudos