Skip to content

Commit

Permalink
vcsim: fix race in CloneVM_Task
Browse files Browse the repository at this point in the history
Commit 4b59b65 made simulator tasks async, but in this 1 case task.Info was being read before the call to task.Wait()
  • Loading branch information
dougm committed May 26, 2021
1 parent 9c7ad1f commit 0c0ed98
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions simulator/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1777,12 +1777,11 @@ func (vm *VirtualMachine) CloneVMTask(ctx *Context, req *types.CloneVM_Task) soa
})

ctask := Map.Get(res.(*methods.CreateVM_TaskBody).Res.Returnval).(*Task)
ctask.Wait()
if ctask.Info.Error != nil {
return nil, ctask.Info.Error.Fault
}

ctask.Wait()

ref := ctask.Info.Result.(types.ManagedObjectReference)
clone := Map.Get(ref).(*VirtualMachine)
clone.configureDevices(ctx, &types.VirtualMachineConfigSpec{DeviceChange: req.Spec.Location.DeviceChange})
Expand Down

0 comments on commit 0c0ed98

Please sign in to comment.