ohai icon indicating copy to clipboard operation
ohai copied to clipboard

Wrong detection of nested virtualization

Open ghost opened this issue 8 years ago • 3 comments

Description

I want to get the virtualization info for all KVM domains on my host.

Using the following nested virtualization setup as our dev environment:

VMWare hosts CentOS hosts multiple KVM guests

Running OHAI on CentOS detects the KVM only as role "guest", because the detection is based on presence of "hypervisor" in /proc/cpuinfo, which is also present if CentOS itself is a VMWare guest.

Also, i dont understand the difference between "system", wich contains only the LAST found virtualization provider and "systems", which lists all providers.

If there are more than one providers present, the meaning of "system", showing only the last one found, is unclear.

This is problematic, because the VirtualizationInfo plugin will only gather data for "system", not for each in "systems".

IMHO there are three problems to solve:

1.) Detect the KVM in my setup properly as role "host" 2.) Show VirtualizationInfo for each provider in "systems", which is a "host". 3.) Remove confusing "system" and list all available providers in "systems" (or ommit the "systems" subfolder")

Ohai Version

8.15.1

Platform Version

CentOS 7

Ohai Output (IS)

  • virtualization
    • systems
      • kvm: guest
      • vmware: guest
    • system: vmware
    • role: guest

Ohai Output (SHOULD BE)

  • virtualization
    • vmware
      • role: guest
    • kvm
      • role: host
      • domains: ....
      • nodeinfo: ....

ghost avatar May 20 '16 07:05 ghost

I think I am getting a similar issue, but with GCE in my case. I am building a Packer images using GCE's new nested virtualization support. Chef runs inside the image that I'm building. I am building the image using Virtualbox. However Ohai detects it as GCE. I also noticed that there is no way of setting a hint file for Virtualbox as the plugin doesn't even check for an existing hint file.

funzie19 avatar Dec 26 '17 21:12 funzie19

@funzie19 Our GCE detection is less than ideal. We just try to hit the metadata endpoint and that'll succeed for a nested VM as well. As for the virtualbox plugin that won't get you anything on the guests so we don't run it. You need to be a host for that plugin to figure.

tas50 avatar Jan 29 '18 23:01 tas50

I'm going to close this issue out at this point. We've done a lot of things to our code since 8.15 to improve how we detect various virtualization technologies. We can't change the underlying data structure there though since that would break every existing user keying off the current structure. I'm not sure the current structure limits us for what you want though. We can always produce a data structure like this if we're on a nested VM where the guest and host are both using the same technology:

virtualization systems kvm: guest kvm: guest system: kvm role: guest

System and role are a big misleading and that's because they are the legacy format when we only supported detecting a single VM system. I'm going to open a new ticket up to remove those since they're not accurate.

tas50 avatar Jan 29 '18 23:01 tas50