diff --git a/pkg/hostman/guestman/arch/arch.go b/pkg/hostman/guestman/arch/arch.go index d2d8cfc325..8916f0bb35 100644 --- a/pkg/hostman/guestman/arch/arch.go +++ b/pkg/hostman/guestman/arch/arch.go @@ -41,6 +41,7 @@ type KVMGuestInstance interface { IsNestedVirt() bool IsKvmSupport() bool HideKVM() bool + HideHypervisor() bool } func NewArch(arch string) Arch { diff --git a/pkg/hostman/guestman/arch/x86.go b/pkg/hostman/guestman/arch/x86.go index af6e1905ac..92c477f082 100644 --- a/pkg/hostman/guestman/arch/x86.go +++ b/pkg/hostman/guestman/arch/x86.go @@ -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" diff --git a/pkg/hostman/guestman/qemu-kvmhelper.go b/pkg/hostman/guestman/qemu-kvmhelper.go index 1aae43b6c2..8b8eae192c 100644 --- a/pkg/hostman/guestman/qemu-kvmhelper.go +++ b/pkg/hostman/guestman/qemu-kvmhelper.go @@ -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 }