Creating r/virtual_machine with multiple PCI passthrough devices is not supported #2237
Open
4 tasks done
Labels
Milestone
Community Guidelines
Terraform
1.5.7
Terraform Provider
2.8.2
VMware vSphere
8.0.2
Description
I identified this problem while working on #1688
A PCI passthrough device can be added to a virtual machine only during reconfiguration. Attempting to create a virtual machine with such devices fails.
This happens because same codepath is followed both when creating and reconfiguring a virtual machine, at least as far as PCI devices are concerned.
The root cause of the problem is in the following method
https://github.com/hashicorp/terraform-provider-vsphere/blob/main/vsphere/internal/virtualdevice/virtual_machine_device_subresource.go#L974
This function attempts to retrieve the virtual machine by its identifier which is impossible before the machine has been created. The VM reference is necessary so that this method can later on loop over its devices and prepare the reconfiguration changes.
We need to define a dedicated procedure for adding PCI devices to a VM creation specification.
This will require changes to
virtual_machine_device_subresource.go
as well as refactoring inresource_vsphere_virtual_machine.go
Affected Resources or Data Sources
resource/vsphere_virtual_machine
Terraform Configuration
Debug Output
N/A
Panic Output
No response
Expected Behavior
A virtual machine should be created
Actual Behavior
The execution fails before the creation task is triggered
Steps to Reproduce
Attempt to create a virtual machine with at least one value for
pci_device_id
Environment Details
No response
Screenshots
No response
References
No response
The text was updated successfully, but these errors were encountered: