-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update controller's device list in AssignController #3588
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dilyar85 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this failing test first: https://github.com/vmware/govmomi/actions/runs/11264744416/job/31326263686?pr=3588
I can take a closer look in a bit
vcsim may change the Device.Key, in which case we need to change the Controller.Device reference too: diff --git a/simulator/virtual_machine.go b/simulator/virtual_machine.go
index a596798d..1bda935c 100644
--- a/simulator/virtual_machine.go
+++ b/simulator/virtual_machine.go
@@ -1279,6 +1279,7 @@ func (vm *VirtualMachine) configureDevice(
d := device.GetVirtualDevice()
var controller types.BaseVirtualController
+ key := d.Key
if d.Key <= 0 {
// Keys can't be negative; Key 0 is reserved
d.Key = devices.NewKey()
@@ -1293,6 +1294,19 @@ func (vm *VirtualMachine) configureDevice(
d.Key++
}
+ // Update device controller's key reference
+ if key != d.Key {
+ if p := devices.FindByKey(d.ControllerKey); p != nil {
+ c := p.(types.BaseVirtualController).GetVirtualController()
+ for i := range c.Device {
+ if c.Device[i] == key {
+ c.Device[i] = d.Key
+ break
+ }
+ }
+ }
+ }
+
label := devices.Name(device)
summary := label
dc := ctx.Map.getEntityDatacenter(ctx.Map.Get(*vm.Parent).(mo.Entity)) |
12d21bb
to
c44199a
Compare
Thanks @dougm! Updated with your suggestion above and got all the tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dilyar85 !
Description
This PR updates the
AssignController
function to add the assigned device to the controller's device list. This ensures that PickController() function returns the appropriate controller with available slots, as it's based on the current number of devices attached to the controller.Closes: N/A
How Has This Been Tested?
TestAssignController
to validate the controller's device list.AssignController
during a single VM reconfiguration task. Verified that the devices were properly assigned to the controller without exceeding the maximum allowed slots:Guidelines
Please read and follow the
CONTRIBUTION
guidelines of this project.