VMware {code} Community
VMwareUserBA
Contributor
Contributor

Modifying UUID of an existing disk (VMDK) while adding it to a VM using ReconfigVM_Task API

Hi,

I am trying to add an existing VMDK to a virtual machine. The ReconfigVM_Task() API completes without issues and the virtual machine is added with the existing virtual disk as specified.

However, the UUID of the virtual disk clashes with the pre-existing virtual disk of the VM (The virtual disk being added to the VM is same as that of the currently available virtual disk). Even though the UUID value is specified for the new virtual disk, the API ReconfigVM_Task() appears to be reading it from the .vmdk file and using it instead of the new specified VirtualDiskFlatVer2BackingInfo.uuid.

I would like to specify new UUID for the virtual disk that is getting added and not to use the one that exists inside the .vmdk file.

Please advise me on this. I am using 4.1 SDK. The implementation works fine without issues as long as the pre-existing virtual disk UUID and the UUID of new virtual disk to be added to virtual machine are different;  otherwise there is a Question
asked on the virtual machine to complete the addition of virtual disk with duplicate UUID.


The modification of UUID of existing virtual disk works provided that the respective virtual machine is powered off. Thus the UUIDs are different and there was no issue observed while adding same disk to the vm.

Thanks,

0 Kudos
3 Replies
VMwareUserBA
Contributor
Contributor

Adding an existing disk to a virtual machine with no value / empty string / blank space specified for the ‘uuid’ (virtualmachine.config.hardware.device[2001].backing.uuid) causes a question (virtualmachine.runtime.question) raised on the respective virtual machine:

"msg.disk.duplicateUUID:Virtual disks "/vmfs/volumes/ds-1/vm-1/ vm-1.vmdk" and "/vmfs/volumes/ds-1/cloned-disk/vm-1.vmdk" have the same UUID. Virtual disks with same UUID should not be assigned to a virtual machine because duplications can lead to problems when the guest boots. Make sure virtual disks have unique UUIDs. Do you want to continue?" Yes/No

If the question is answered with 'Yes' then the disk gets added with duplicate UUID to the virtual machine and ReconfigureVM_Task completes successfully.

It seems that the API AnswerVM() can be used to answere the question.... need to check.

If anyone has better solution; please advise.

0 Kudos
VMwareUserBA
Contributor
Contributor

It appears that the UUID of a virtual disk (virtualmachine.config.hardware.device[2001].backing.uuid) can be changed as long as the respective VM is powered off. If the VM is powered ON then the ReconfigVM_Task API gives error: The <unspecified file> is locked.....

The API AnswerVM() works fine and the existing disk with duplicate UUID is added to the VM successfully.   However each time VM is powered on the same question is promted to the User and thus its not a good solution.

Is anyone aware if the virtual disk UUID  (virtualmachine.config.hardware.device[2001].backing.uuid) can be modified while VM is in powered ON state ?

0 Kudos
hickeng
VMware Employee
VMware Employee

I can't say for certain that the UUID cannot be changed while the VM is powered on but I think it unlikely as the vmdk UUID is presented to the OS as the hardware serial number if disk.EnableUUID is true.

However it is possible to supply the answer to the duplicate UUID question ahead of time in the vmx file by setting:

answer.msg.disk.duplicateUUID = "Yes"


The article below contains additional information about how to determine the value to set for any given question:

VMware KB: Powering on a virtual machine pauses at 95% while waiting for a question to be answered

0 Kudos