platform_compat_windows.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package osversion
  2. // List of stable ABI compliant ltsc releases
  3. // Note: List must be sorted in ascending order
  4. var compatLTSCReleases = []uint16{
  5. V21H2Server,
  6. }
  7. // CheckHostAndContainerCompat checks if given host and container
  8. // OS versions are compatible.
  9. // It includes support for stable ABI compliant versions as well.
  10. // Every release after WS 2022 will support the previous ltsc
  11. // container image. Stable ABI is in preview mode for windows 11 client.
  12. // Refer: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-10#windows-server-host-os-compatibility
  13. func CheckHostAndContainerCompat(host, ctr OSVersion) bool {
  14. // check major minor versions of host and guest
  15. if host.MajorVersion != ctr.MajorVersion ||
  16. host.MinorVersion != ctr.MinorVersion {
  17. return false
  18. }
  19. // If host is < WS 2022, exact version match is required
  20. if host.Build < V21H2Server {
  21. return host.Build == ctr.Build
  22. }
  23. var supportedLtscRelease uint16
  24. for i := len(compatLTSCReleases) - 1; i >= 0; i-- {
  25. if host.Build >= compatLTSCReleases[i] {
  26. supportedLtscRelease = compatLTSCReleases[i]
  27. break
  28. }
  29. }
  30. return ctr.Build >= supportedLtscRelease && ctr.Build <= host.Build
  31. }