mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: windows GPU vm should set hypervisor=off (#18690)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -41,6 +41,7 @@ type KVMGuestInstance interface {
|
||||
IsNestedVirt() bool
|
||||
IsKvmSupport() bool
|
||||
HideKVM() bool
|
||||
HideHypervisor() bool
|
||||
}
|
||||
|
||||
func NewArch(arch string) Arch {
|
||||
|
||||
@@ -129,6 +129,7 @@ func (*X86) enableHypervFeatures(features map[string]bool) {
|
||||
|
||||
func (x86 *X86) GenerateCpuDesc(cpus uint, cpuMax uint, s KVMGuestInstance) (*desc.SGuestCpu, error) {
|
||||
var hideKVM = s.HideKVM()
|
||||
var hideHypervisor = s.HideHypervisor()
|
||||
var hostCPUPassthrough = options.HostOptions.HostCpuPassthrough
|
||||
var isCPUIntel = sysutils.IsProcessorIntel()
|
||||
var isCPUAMD = sysutils.IsProcessorAmd()
|
||||
@@ -174,6 +175,9 @@ func (x86 *X86) GenerateCpuDesc(cpus uint, cpuMax uint, s KVMGuestInstance) (*de
|
||||
if hideKVM {
|
||||
features["kvm"] = false
|
||||
}
|
||||
if hideHypervisor {
|
||||
features["hypervisor"] = false
|
||||
}
|
||||
} else {
|
||||
accel = "tcg"
|
||||
cpuType = "qemu64"
|
||||
|
||||
@@ -131,17 +131,29 @@ func (s *SKVMGuestInstance) GetKernelVersion() string {
|
||||
return s.manager.host.GetKernelVersion()
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) HideKVM() bool {
|
||||
if s.hasGPU() {
|
||||
func (s *SKVMGuestInstance) HideHypervisor() bool {
|
||||
if s.IsRunning() && s.IsMonitorAlive() {
|
||||
cmdline, _ := fileutils2.FileGetContents(path.Join("/proc", strconv.Itoa(s.GetPid()), "cmdline"))
|
||||
if strings.Contains(cmdline, "hypervisor=off") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if s.hasGPU() && s.GetOsName() == OS_NAME_WINDOWS {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *SKVMGuestInstance) HideKVM() bool {
|
||||
if s.IsRunning() && s.IsMonitorAlive() {
|
||||
cmdline, _ := fileutils2.FileGetContents(path.Join("/proc", strconv.Itoa(s.GetPid()), "cmdline"))
|
||||
if strings.Contains(cmdline, "kvm=off") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if s.hasGPU() && s.GetOsName() != OS_NAME_WINDOWS {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user