From 8df4259c5778866735d5a93ab37c0afced4d6049 Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Thu, 30 May 2024 10:44:40 +0300 Subject: [PATCH 1/2] Generate negative key when adding pci device Signed-off-by: Stoyan Zhelyazkov --- .../internal/virtualdevice/virtual_machine_device_subresource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/vsphere/internal/virtualdevice/virtual_machine_device_subresource.go b/vsphere/internal/virtualdevice/virtual_machine_device_subresource.go index c0430eef3..5fb72dd46 100644 --- a/vsphere/internal/virtualdevice/virtual_machine_device_subresource.go +++ b/vsphere/internal/virtualdevice/virtual_machine_device_subresource.go @@ -988,6 +988,7 @@ func (c *pciApplyConfig) modifyVirtualPciDevices(devList *schema.Set, op types.V SystemId: c.SystemID, VendorId: pciDev.VendorId, }, + Key: c.VirtualDevice.NewKey(), }, } vm, err := virtualmachine.FromUUID(c.Client, c.ResourceData.Id()) From 1a38523d003be0c279b4a04ff4d44b18023e4b4b Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Fri, 5 Jul 2024 18:36:29 +0300 Subject: [PATCH 2/2] Mark pci_device_id's dependency to host_system_id Signed-off-by: Stoyan Zhelyazkov --- vsphere/resource_vsphere_virtual_machine.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vsphere/resource_vsphere_virtual_machine.go b/vsphere/resource_vsphere_virtual_machine.go index e21598e7c..2e59c5af7 100644 --- a/vsphere/resource_vsphere_virtual_machine.go +++ b/vsphere/resource_vsphere_virtual_machine.go @@ -238,10 +238,11 @@ func resourceVSphereVirtualMachine() *schema.Resource { Elem: &schema.Resource{Schema: virtualdevice.CdromSubresourceSchema()}, }, "pci_device_id": { - Type: schema.TypeSet, - Optional: true, - Description: "A list of PCI passthrough devices", - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeSet, + Optional: true, + Description: "A list of PCI passthrough devices", + Elem: &schema.Schema{Type: schema.TypeString}, + RequiredWith: []string{"host_system_id"}, }, "clone": { Type: schema.TypeList,