Skip to content

Commit

Permalink
vcsim: avoid edit device panic when DeviceInfo is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
dougm committed May 7, 2021
1 parent dfe03eb commit bd3467d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion simulator/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,9 @@ func (vm *VirtualMachine) configureDevices(ctx *Context, spec *types.VirtualMach
return invalid
}
devices = vm.removeDevice(ctx, devices, &rspec)
device.DeviceInfo.GetDescription().Summary = "" // regenerate summary
if device.DeviceInfo != nil {
device.DeviceInfo.GetDescription().Summary = "" // regenerate summary
}

err := vm.configureDevice(ctx, devices, dspec)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions simulator/virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ func TestReconfigVmDevice(t *testing.T) {
t.Error(err)
}

d.GetVirtualDevice().DeviceInfo = nil
if err = vm.EditDevice(ctx, d); err != nil {
t.Error(err)
}

// RemoveDevice and delete the file backing
if err = vm.RemoveDevice(ctx, false, d); err != nil {
t.Error(err)
Expand Down

0 comments on commit bd3467d

Please sign in to comment.