VMware {code} Community
amrut7764
Contributor
Contributor
Jump to solution

Adding a virtual disk on SCSI controller with physical/virtual sharing fails

I am adding a virtual disk to a SCSI controller with either physical or virtual bus sharing, which is getting failed for the below code. Same code gets successful if bus sharing is "noSharing".

    $vmView = Vim::find_entity_view(view_type=>'VirtualMachine',filter=>{name=>$vms[0]});
    $controllerKey = find_scsi_cntlrkey(vm=>$vmView,controller=>$cntlr);
    my %hash = (
                vm=>$vmView,
                diskMode=>"persistent",
                fileName=>$filename,
                controllerKey=>$controllerKey,
                unitNumber=>$target,
                size=>"5242880",
                backingtype=>"regular",
                uuid =>undef,
                deviceName=>undef,
                );
    my $filespec = get_vdiskSpec(%hash);
    print Dumper $filespec;
    my $vdisk = add_virtualdisk(vm=>$vmView,devspec=>$filespec);

Command execution:

amrut@2:~/scripts/vmware/apps$ perl RDM_add.pl  --vmname vm1  --server vcenter_server --username administrator@vsphere.local --password Pass@123 --operation add --controller 2:2 --filename vm_232
Adding new LsiLogicSAS vSCSI Controller 2 to "vm1"
Successfully added
$VAR1 = bless( {
                 'fileOperation' => bless( {
                                             'val' => 'create'
                                           }, 'VirtualDeviceConfigSpecFileOperation' ),
                 'operation' => bless( {
                                         'val' => 'add'
                                       }, 'VirtualDeviceConfigSpecOperation' ),
                 'device' => bless( {
                                      'capacityInKB' => '5242880',
                                      'backing' => bless( {
                                                            'fileName' => '[datastore1 (4)]/vm1/vm_232.vmdk',
                                                            'diskMode' => 'persistent'
                                                          }, 'VirtualDiskFlatVer2BackingInfo' ),
                                      'unitNumber' => 2,
                                      'controllerKey' => '1002',
                                      'key' => -1
                                    }, 'VirtualDisk' )
               }, 'VirtualDeviceConfigSpec' );
Unable to configure virtual device.

amrut@2:~/scripts/vmware/apps$

In vcenter GUi I am getting below error:

Failed to power on scsi2:2.
Failed to add disk scsi2:2.

But Getting successful if bus sharing is none!

amrut@uptohell2:~/scripts/vmware/apps$ perl RDM_add.pl  --vmname vm1 --server vcenter_server --username administrator@vsphere.local --password Pass@123 --operation add --controller 1:2 --filename vm_232
$VAR1 = bless( {
                 'fileOperation' => bless( {
                                             'val' => 'create'
                                           }, 'VirtualDeviceConfigSpecFileOperation' ),
                 'operation' => bless( {
                                         'val' => 'add'
                                       }, 'VirtualDeviceConfigSpecOperation' ),
                 'device' => bless( {
                                      'capacityInKB' => '5242880',
                                      'backing' => bless( {
                                                            'fileName' => '[datastore1 (4)]/vm1/vm1_232.vmdk',
                                                            'diskMode' => 'persistent'
                                                          }, 'VirtualDiskFlatVer2BackingInfo' ),
                                      'unitNumber' => 2,
                                      'controllerKey' => '1001',
                                      'key' => -1
                                    }, 'VirtualDisk' )
               }, 'VirtualDeviceConfigSpec' );
Virtual Disk created.
amrut@2:~/scripts/vmware/apps$

Can some one please let me know, do we need to pass any other parameter for adding disk to SCSIController with bus sharing physical/virtual ?

Thanks

AMrut

Reply
0 Kudos
1 Solution

Accepted Solutions
stumpr
Virtuoso
Virtuoso
Jump to solution

Yes, the backing can be set to any of the types at deployment time.  You'll need to modify your add disk operation with the correct backing.

Reuben Stump | http://www.virtuin.com | @ReubenStump

View solution in original post

Reply
0 Kudos
3 Replies
amrut7764
Contributor
Contributor
Jump to solution

This behaviour is seen when VMDK is created using perl script and SCSI controller bus sharing is either physical or virtual.  And this is happening because, using perl script if we create a virutal disk it is getting created as "Thick Provisioned Lazy zeroed" which is not being able to share with other VMs. But if we create disk "Thick Provisioned Eager zeroed" disk manually then it is getting shared properly.

Is there any API or method with which we can convert disk provision from 'Lazy zeroed' to 'Eager zeroed' ? We can able to convert it manually once we created it, using 'vmkfstools', but I am creating disks and sharing it with multiple VMs at the same time.

Please let me know how to convert disk from thick to thin or from 'lazy zeroed' to 'eager zeroed'.

Thanks

AMrut

stumpr
Virtuoso
Virtuoso
Jump to solution

Yes, the backing can be set to any of the types at deployment time.  You'll need to modify your add disk operation with the correct backing.

Reuben Stump | http://www.virtuin.com | @ReubenStump
Reply
0 Kudos
amrut7764
Contributor
Contributor
Jump to solution

Thanks Stumpr!!! after modifying backing with proper value for 'eagerlyScrub', I am able to create thick provisioned Eager zeroed disks to share among virtual machines.

Thanks

Amrut

Reply
0 Kudos