fix(host): don't hide kvm cpu feature on nested virt (#15579)

This commit is contained in:
wanyaoqi
2022-12-20 20:38:57 +08:00
committed by GitHub
parent fe80cc2f45
commit 9c767d97ef
3 changed files with 7 additions and 14 deletions
+1 -2
View File
@@ -33,13 +33,12 @@ type Arch interface {
}
type KVMGuestInstance interface {
HasGpu() bool
IsOldWindows() bool
GetOsName() string
GetKernelVersion() string
CpuMax() (uint, error)
IsEnabledNestedVirt() bool
IsNestedVirt() bool
IsKvmSupport() bool
}
+5 -2
View File
@@ -132,7 +132,10 @@ func (x86 *X86) GenerateCpuDesc(cpus uint, s KVMGuestInstance) (*desc.SGuestCpu,
if err != nil {
return nil, err
}
hideKVM := !s.IsEnabledNestedVirt() || s.HasGpu()
var hideKVM = true
if s.IsNestedVirt() {
hideKVM = false
}
var hostCPUPassthrough = options.HostOptions.HostCpuPassthrough
var isCPUIntel = sysutils.IsProcessorIntel()
@@ -171,7 +174,7 @@ func (x86 *X86) GenerateCpuDesc(cpus uint, s KVMGuestInstance) (*desc.SGuestCpu,
}
}
if !hideKVM {
if hideKVM {
features["kvm"] = false
}
} else {
+1 -10
View File
@@ -115,7 +115,7 @@ func (s *SKVMGuestInstance) IsKvmSupport() bool {
return s.manager.GetHost().IsKvmSupport()
}
func (s *SKVMGuestInstance) IsEnabledNestedVirt() bool {
func (s *SKVMGuestInstance) IsNestedVirt() bool {
return s.manager.GetHost().IsNestedVirtualization()
}
@@ -733,15 +733,6 @@ func (s *SKVMGuestInstance) startMemCleaner() error {
return nil
}
func (s *SKVMGuestInstance) HasGpu() bool {
for i := 0; i < len(s.Desc.IsolatedDevices); i++ {
if s.Desc.IsolatedDevices[i].DevType != api.USB_TYPE {
return true
}
}
return false
}
func (s *SKVMGuestInstance) gpusHasVga() bool {
manager := s.manager.GetHost().GetIsolatedDeviceManager()
for i := 0; i < len(s.Desc.IsolatedDevices); i++ {