VMware {code} Community
sivadevel
Enthusiast
Enthusiast

CreateVM_Task fails if harddisks are connected to Scsi Ctrls

Hi,

During VM Creation if the VMConfigSpec is having the harddisk connected to a IDE controller the VM is created properly. But if the VmConfigSpec is given a Scsi Controller vm creation is failing with the error " The device '7' is referring to a nonexisting controller '-44'."

The actual controller key value 100 and I have given this value too, but the creation fails. Google did yield some results, but they were not helpful in solving. Any help is appreciated.

Thanks,

./Siva.

0 Kudos
10 Replies
togtog
Hot Shot
Hot Shot

Hi Siva,

Just a quick guess. Try to adjust your code according to the following:

// Formulate the SCSI controller 
deviceConfigSpec[1].setOperation(VirtualDeviceConfigSpecOperation.add);
VirtualLsiLogicController scsiCtrl = new VirtualLsiLogicController();
scsiCtrl.setBusNumber(0); 
deviceConfigSpec[1].setDevice(scsiCtrl);
scsiCtrl.setKey(-44);
scsiCtrl.setSharedBus(VirtualSCSISharing.noSharing);

// Formulate SCSI disk one
deviceConfigSpec[2].setFileOperation(VirtualDeviceConfigSpecFileOperation.create);
deviceConfigSpec[2].setOperation(VirtualDeviceConfigSpecOperation.add);
VirtualDisk disk = new VirtualDisk();
VirtualDiskFlatVer2BackingInfo diskfileBacking = new VirtualDiskFlatVer2BackingInfo();
diskfileBacking.setDatastore(datastoreRef);
diskfileBacking.setFileName(volumeName);
diskfileBacking.setDiskMode("persistent");
diskfileBacking.setSplit(new Boolean(false));
diskfileBacking.setWriteThrough(new Boolean(false));
disk.setKey(-1000000);
disk.setControllerKey(new Integer(-44));
disk.setUnitNumber(new Integer(0));
disk.setBacking(diskfileBacking);
disk.setCapacityInKB(524288);
deviceConfigSpec[2].setDevice(disk);

That is the controllerKey of the SCSI disk must be the same as the key of the controller and use negative numbers.

Please let me know if this makes it work ...

Thomas G.
0 Kudos
sivadevel
Enthusiast
Enthusiast

That is the problem, my code is written exactly like the link you have provided and it does not work. Since I take the information from the ConfigInfo file I stored during backup, I read and load values from the file. I fill the controller key like this

            vmConfigSpec.deviceChange[currIndex]->device = vd[devIndex];

            int cKey = -(*scsiCtrl->controllerKey);

            vmConfigSpec.deviceChange[currIndex]->device->controllerKey = &(cKey);
            vmConfigSpec.deviceChange[currIndex]->device->key = -(scsiCtrl->key);

Where the scsiCtrl is the pointer to the scsicontroller that I filled up the deviceChange with. As an experiment I removed the disk from the configuration and the VM gets created without any problem.

Thanks,

./Siva.

0 Kudos
togtog
Hot Shot
Hot Shot

Hi Siva,

OK the fact that the machine creates without the SCSI setup indicates that the SCSI setup is the problem and the error message you provided indicates that the error originates from the controller<->device associations specified. So let's investigate that further:

vd[devIndex] // is the SCSI disk, for the moment I assume this is an array of pointers to disks
scsiCtrl // the SCSI controller to which we want to attach the SCSI disk

Now both devices have the following properties:

vd[devIndex]->controllerKey // the key of the SCSI controller to which to attach, 
                            // has to be negative and set by you vd[devIndex]->key // the key of the SCSI disk itself,
                  // has to be negative and set by you scsiCtrl->controllerKey // the key of the VirtualPCIController controller
                        //to which to attach, do not set this scsiCtrl->key // the key of the SCSI controller itself,
              // has to be negative and set by you

Considering the above could you try to rewrite as follows:


// Set disk
vmConfigSpec.deviceChange[currIndex]->device = vd[devIndex];

// Get SCSI controller key

int cKey = -(*scsiCtrl->key); 
// Associate disk with controller


vmConfigSpec.deviceChange[currIndex]->device->controllerKey = &(cKey); 
// Get disk key
int dKey = -(*vd[devIndex]->key);


// Force negative disk key
vmConfigSpec.deviceChange[currIndex]->device->key = &(dKey);

I am not a C/C++ expert so please be patient and resolve any pointer mess I created above 😉

Thomas G.
0 Kudos
sivadevel
Enthusiast
Enthusiast

Totally weird. Following is the XML snippet from the config file

<vw1:device xsi:type="vw1:VirtualBusLogicController">
            <vw1:key>1000</vw1:key>
            <vw1:deviceInfo xsi:type="vw1:Description">
                <vw1:label>SCSI controller 0</vw1:label>
                <vw1:summary>BusLogic Parallel</vw1:summary>
            </vw1:deviceInfo>
            <vw1:controllerKey>100</vw1:controllerKey>
            <vw1:unitNumber>3</vw1:unitNumber>
            <vw1:busNumber>0</vw1:busNumber>
            <vw1:device>2000</vw1:device>
            <vw1:hotAddRemove>true</vw1:hotAddRemove>
            <vw1:sharedBus>noSharing</vw1:sharedBus>
            <vw1:scsiCtlrUnitNumber>7</vw1:scsiCtlrUnitNumber>

        </vw1:device>

When I programmatically refer ContollerKey of the above set, the value returned is 3 instead of 100 - which is being currently set as the key for the controller. Once I hardcoded the value it worked properly. So that is actually the issue, the value being misread by the soap API. Have to look in to that.

Once that value is hardcoded - it worked without any other changes. Will update the post when I figure out why the hell is DS being filled up wrongly.

./Siva.

0 Kudos
togtog
Hot Shot
Hot Shot

Hi Siva,

OK, but besides the SOAP framework I feel that there is still something wrong as, as far as I understand your code, you use

            <vw1:controllerKey>100</vw1:controllerKey>

and not

            <vw1:key>1000</vw1:key>

to associate the disk with the controller. But 100 is the key of the VirtualPCIController and not of the SCSI controller - this is weird to me. 

Thomas G.
0 Kudos
sivadevel
Enthusiast
Enthusiast

It makes sense.

<vw1:device xsi:type="vw1:VirtualPCIController">
            <vw1:key>100</vw1:key>
            <vw1:deviceInfo xsi:type="vw1:Description">
                <vw1:label>PCI controller 0</vw1:label>
                <vw1:summary>PCI controller 0</vw1:summary>
            </vw1:deviceInfo>
            <vw1:busNumber>0</vw1:busNumber>
            <vw1:device>1000</vw1:device>
            <vw1:device>4000</vw1:device>
            <vw1:device>500</vw1:device>
            <vw1:device>12000</vw1:device>
        </vw1:device>

One of the device connects to it is the BusLogicController ==> 1000.

<vw1:device xsi:type="vw1:VirtualBusLogicController">
            <vw1:key>1000</vw1:key>
            <vw1:deviceInfo xsi:type="vw1:Description">
                <vw1:label>SCSI controller 0</vw1:label>
                <vw1:summary>BusLogic Parallel</vw1:summary>
            </vw1:deviceInfo>
            <vw1:controllerKey>100</vw1:controllerKey>
            <vw1:unitNumber>3</vw1:unitNumber>
            <vw1:busNumber>0</vw1:busNumber>
            <vw1:device>2000</vw1:device>
            <vw1:hotAddRemove>true</vw1:hotAddRemove>
            <vw1:sharedBus>noSharing</vw1:sharedBus>
            <vw1:scsiCtlrUnitNumber>7</vw1:scsiCtlrUnitNumber>
        </vw1:device>

I just have to figure out why I am getting it wrong when I read from the file.

./Siva.

0 Kudos
togtog
Hot Shot
Hot Shot

Hi Siva,

OK so far I am absolutely with you that makes sens. Now please post the SCSI disk device XML snippet from the config file ...

Thomas G.
0 Kudos
sivadevel
Enthusiast
Enthusiast

The whole file attached.

0 Kudos
togtog
Hot Shot
Hot Shot

Hi Siva,

The whole file attached.

Great, thanks. OK now to illustrate what I mean here a shortened snippet from the file:

<vw1:device xsi:type="vw1:VirtualPCIController">
    <vw1:key>100</vw1:key>
</vw1:device>
 
<vw1:device xsi:type="vw1:VirtualBusLogicController">
    <vw1:key>1000</vw1:key>
    ...
    <vw1:controllerKey>100</vw1:controllerKey>
    ...
</vw1:device>
   
<vw1:device xsi:type="vw1:VirtualDisk">
    <vw1:key>2000</vw1:key>
    ...
    <vw1:controllerKey>1000</vw1:controllerKey>
    ...
</vw1:device>

The VirtualBusLogicController is associated with the VirtualPCIController via its controllerKey property=100, thus pointing to the PCIController

The VirtualDisk is associated with the BusLogicController via its controllerKey property=1000, thus pointing to the BusLogicController

Now if I read your original code right:

    vmConfigSpec.deviceChange[currIndex]->device = vd[devIndex];

    int cKey = -(*scsiCtrl->controllerKey);

    vmConfigSpec.deviceChange[currIndex]->device->controllerKey = &(cKey);
    vmConfigSpec.deviceChange[currIndex]->device->key = -(scsiCtrl->key);

then the value of cKey should be -100 and the fact that you set -100 as the value of the controllerKey property of your disk makes the disk point to the PCIController not the BusLogicController which would be achieved with cKey == -1000.

In other words to resemble the original setup the controllerKey and the key property of the virtual disk should be set as follows:

    vmConfigSpec.deviceChange[currIndex]->device->controllerKey = -1000;
    vmConfigSpec.deviceChange[currIndex]->device->key = -2000;

See what I mean. This is why I am buffled that the machine creates with the hard coded 100, but maybe this is because of the messed up SOAP input ...

Thomas G.
0 Kudos
sivadevel
Enthusiast
Enthusiast

Hi,

I guess I misunderstood when I mentioned that controllerkey for Harddisk is the 100. That is wrong.

ControllerKey for harddisk is 1000 and Key is 2000. Controller key for Scsi controller is 100 which we don't have to be bothered.

Thanks,

./Siva.

0 Kudos