Skip to content

Commit

Permalink
vcsim: set VirtualMachine ChangeTrackingSupported property (#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanpaha committed May 28, 2021
1 parent c07e44a commit df9dfde
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions simulator/virtual_machine.go
Expand Up @@ -160,6 +160,8 @@ func NewVirtualMachine(ctx *Context, parent types.ManagedObjectReference, spec *
vm.Runtime.ConnectionState = types.VirtualMachineConnectionStateConnected
vm.Summary.Runtime = vm.Runtime

vm.Capability.ChangeTrackingSupported = types.NewBool(changeTrackingSupported(spec))

vm.Summary.QuickStats.GuestHeartbeatStatus = types.ManagedEntityStatusGray
vm.Summary.OverallStatus = types.ManagedEntityStatusGreen
vm.ConfigStatus = types.ManagedEntityStatusGreen
Expand Down Expand Up @@ -2236,3 +2238,23 @@ func allSnapshotsInTree(tree []types.VirtualMachineSnapshotTree) []types.Managed

return result
}

func changeTrackingSupported(spec *types.VirtualMachineConfigSpec) bool {
for _, device := range spec.DeviceChange {
if dev, ok := device.GetVirtualDeviceConfigSpec().Device.(*types.VirtualDisk); ok {
switch dev.Backing.(type) {
case *types.VirtualDiskFlatVer2BackingInfo:
return true
case *types.VirtualDiskSparseVer2BackingInfo:
return true
case *types.VirtualDiskRawDiskMappingVer1BackingInfo:
return true
case *types.VirtualDiskRawDiskVer2BackingInfo:
return true
default:
return false
}
}
}
return false
}

0 comments on commit df9dfde

Please sign in to comment.