fix(host): set max cpus for virt machine type (#15339)

This commit is contained in:
wanyaoqi
2022-11-11 08:29:20 +08:00
committed by GitHub
parent a15f1736de
commit 6173bffe87
3 changed files with 12 additions and 4 deletions
+2
View File
@@ -141,6 +141,8 @@ func (m *SGuestManager) InitQemuMaxCpus(machineCaps []monitor.MachineInfo, kvmMa
// You can add an IOMMU using: -device intel-iommu,intremap=on,eim=on
// Set x86 machine max cpu 240 for now.
m.qemuMachineCpuMax[machine] = minFunc(cpuMax, m.qemuMachineCpuMax[machine])
} else {
m.qemuMachineCpuMax[machine] = cpuMax
}
log.Infof("Machine type %s max cpus: %d", machine, m.qemuMachineCpuMax[machine])
}
+3 -1
View File
@@ -2163,7 +2163,9 @@ func (s *SKVMGuestInstance) OnResumeSyncMetadataInfo() {
} else {
meta.Set("__cpu_mode", jsonutils.NewString(api.CPU_MODE_HOST))
}
meta.Set("__pcie_extend_bus", jsonutils.JSONTrue)
if s.hasPcieExtendBus() {
meta.Set("__pcie_extend_bus", jsonutils.JSONTrue)
}
cmdline, err := s.getQemuCmdline()
if err != nil {
log.Errorf("Get qemu process cmdline error: %v", err)
+7 -3
View File
@@ -744,11 +744,12 @@ func (s *SKVMGuestInstance) gpusHasVga() bool {
}
func (s *SKVMGuestInstance) initCpuDesc() error {
cpudesc, err := s.archMan.GenerateCpuDesc(uint(s.Desc.Cpu), s)
s.fixGuestMachineType()
cpuDesc, err := s.archMan.GenerateCpuDesc(uint(s.Desc.Cpu), s)
if err != nil {
return err
}
s.Desc.CpuDesc = cpudesc
s.Desc.CpuDesc = cpuDesc
return nil
}
@@ -809,7 +810,7 @@ func (s *SKVMGuestInstance) initMemDescFromMemoryInfo(memoryDevicesInfoList []mo
return nil
}
func (s *SKVMGuestInstance) initMachineDesc() {
func (s *SKVMGuestInstance) fixGuestMachineType() {
if s.GetOsName() == OS_NAME_MACOS {
s.Desc.Machine = api.VM_MACHINE_TYPE_Q35
s.Desc.Bios = qemu.BIOS_UEFI
@@ -822,6 +823,9 @@ func (s *SKVMGuestInstance) initMachineDesc() {
}
s.Desc.Bios = qemu.BIOS_UEFI
}
}
func (s *SKVMGuestInstance) initMachineDesc() {
s.Desc.MachineDesc = s.archMan.GenerateMachineDesc(s.Desc.CpuDesc.Accel)
}