arm.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package arch
  15. import (
  16. "yunion.io/x/onecloud/pkg/hostman/guestman/desc"
  17. "yunion.io/x/onecloud/pkg/hostman/options"
  18. )
  19. const (
  20. ARM_MAX_CPUS = 64
  21. ARM_SOCKETS = 2
  22. ARM_CORES = 32
  23. ARM_THREADS = 1
  24. ARM_MEM_DEFAULT_SLOTS = 4
  25. )
  26. var ARM_MAX_MEM_MB uint = 262144
  27. type ARM struct {
  28. archBase
  29. otherArchBase
  30. }
  31. func (*ARM) GenerateMachineDesc(accel string) *desc.SGuestMachine {
  32. gicVersion := "max"
  33. return &desc.SGuestMachine{
  34. Accel: accel,
  35. GicVersion: &gicVersion,
  36. }
  37. }
  38. func (*ARM) GenerateMemDesc() *desc.SGuestMem {
  39. return &desc.SGuestMem{
  40. Slots: ARM_MEM_DEFAULT_SLOTS,
  41. MaxMem: ARM_MAX_MEM_MB,
  42. }
  43. }
  44. func (*ARM) GenerateCpuDesc(cpus uint, cpuMax uint, s KVMGuestInstance) (*desc.SGuestCpu, error) {
  45. var hostCPUPassthrough = options.HostOptions.HostCpuPassthrough
  46. var accel, cpuType string
  47. if s.IsKvmSupport() {
  48. accel = "kvm"
  49. if hostCPUPassthrough {
  50. cpuType = "host"
  51. } else {
  52. // * under KVM, -cpu max is the same as -cpu host
  53. // * under TCG, -cpu max means "emulate with as many features as possible"
  54. cpuType = "max"
  55. }
  56. } else {
  57. accel = "tcg"
  58. cpuType = "max"
  59. }
  60. return &desc.SGuestCpu{
  61. Cpus: cpus,
  62. Sockets: ARM_SOCKETS,
  63. Cores: cpuMax / ARM_SOCKETS / ARM_THREADS,
  64. Threads: ARM_THREADS,
  65. MaxCpus: cpuMax,
  66. Model: cpuType,
  67. Accel: accel,
  68. }, nil
  69. }