From cc7366c7a90868fcb38e60551b4c9e0b5c7a211f Mon Sep 17 00:00:00 2001 From: Vasil Atanasov <141020316+vasilsatanasov@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:53:51 +0200 Subject: [PATCH] fix: scsi ids changing on machines built with v2.6.x (#2115) Ref: #2089 Signed-off-by: Vasil Atanasov --- ...l_machine_network_interface_subresource.go | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go index ce8567ee9..c50408132 100644 --- a/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go +++ b/vsphere/internal/virtualdevice/virtual_machine_network_interface_subresource.go @@ -1118,7 +1118,7 @@ func (r *NetworkInterfaceSubresource) Update(l object.VirtualDeviceList) ([]type // in-place modification. // A result of this is that if you have any SRIOV network interfaces, you // cannot Update the count of non-SRIOV network interfaces. - if r.HasChange("adapter_type") || r.HasChange("physical_function") { + if r.HasChange("adapter_type") || physicalFunctionChanged(r) { // Ensure network interfaces aren't changing adapter_type to or from sriov if err := r.blockAdapterTypeChangeSriov(); err != nil { return nil, err @@ -1513,3 +1513,21 @@ func (r *NetworkInterfaceSubresource) assignEthernetCard(l object.VirtualDeviceL } return nil } + +func physicalFunctionChanged(r *NetworkInterfaceSubresource) bool { + old, n := r.GetChange("physical_function") + var oldVal, newVal string + if old == nil { + oldVal = "" + } else { + oldVal = old.(string) + } + + if n == nil { + newVal = "" + } else { + newVal = n.(string) + } + + return newVal != oldVal +}