mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(host): hide kvm only gpu guests (#16974)
Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ type KVMGuestInstance interface {
|
||||
CpuMax() (uint, error)
|
||||
IsNestedVirt() bool
|
||||
IsKvmSupport() bool
|
||||
HideKVM() bool
|
||||
}
|
||||
|
||||
func NewArch(arch string) Arch {
|
||||
|
||||
@@ -128,11 +128,7 @@ func (*X86) enableHypervFeatures(features map[string]bool) {
|
||||
}
|
||||
|
||||
func (x86 *X86) GenerateCpuDesc(cpus uint, cpuMax uint, s KVMGuestInstance) (*desc.SGuestCpu, error) {
|
||||
var hideKVM = true
|
||||
if s.IsNestedVirt() {
|
||||
hideKVM = false
|
||||
}
|
||||
|
||||
var hideKVM = s.HideKVM()
|
||||
var hostCPUPassthrough = options.HostOptions.HostCpuPassthrough
|
||||
var isCPUIntel = sysutils.IsProcessorIntel()
|
||||
var isCPUAMD = sysutils.IsProcessorAmd()
|
||||
|
||||
@@ -130,6 +130,13 @@ func (s *SKVMGuestInstance) GetKernelVersion() string {
|
||||
return s.manager.host.GetKernelVersion()
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) HideKVM() bool {
|
||||
if s.hasGPU() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) CpuMax() (uint, error) {
|
||||
cpuMax, ok := s.manager.qemuMachineCpuMax[s.Desc.Machine]
|
||||
if !ok {
|
||||
@@ -786,6 +793,17 @@ func (s *SKVMGuestInstance) gpusHasVga() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) hasGPU() bool {
|
||||
manager := s.manager.GetHost().GetIsolatedDeviceManager()
|
||||
for i := 0; i < len(s.Desc.IsolatedDevices); i++ {
|
||||
dev := manager.GetDeviceByAddr(s.Desc.IsolatedDevices[i].Addr)
|
||||
if dev.GetDeviceType() == api.GPU_VGA_TYPE || dev.GetDeviceType() == api.GPU_HPC_TYPE {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) initCpuDesc(cpuMax uint) error {
|
||||
var err error
|
||||
s.fixGuestMachineType()
|
||||
|
||||
Reference in New Issue
Block a user