-
Notifications
You must be signed in to change notification settings - Fork 16
(FACT-1717) Add VMware detector #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4066641 to
a5bf228
Compare
| /** | ||
| * Retrieve the BIOS address | ||
| * @return The BIOS address | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always available in the data from dmidecode, but just not always needed/useful for what we're trying to do? Or only under VMWare?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BIOS address is always available from dmidecode (as long as the dmidecode output isn't totally empty), but as far as I've seen, VMware is the only place it's actually useful.
The DMI source object is getting pretty crowded as more single-case values like this are collected - I feel like there's probably a better way to organize this.
lib/src/detectors/vmware_detector.cc
Outdated
|
|
||
| string vmware_bios_address_to_version(int address) | ||
| { | ||
| static const std::unordered_map<int, std::string> version_map { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems brittle, but we have plenty of other examples of similar maps that require manual attention. Probably not much else we can do here.
| * @param address The value of the BIOS address from DMI | ||
| * @return The VMware version | ||
| */ | ||
| std::string vmware_bios_address_to_version(int address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this doesn't need to be called outside of the vmware detector, it can just be a static method in that file - there's no need to put it in the header or even in the namespace.
|
This doesn't seem to include the change to the entry function to actually check for vmware? |
c96d403 to
8672ce5
Compare
|
Oops, that is a pretty important thing to forget! Updated now. |
|
Coverage loss seems to be the one new line in the main query function, which is hard to unit-test properly. I'm cool with that loss 👍 |
Adds a new field - the BIOS address - to the dataset collected by the DMI source. This field is only available via `dmidecode` (not `/sys/class/dmi/`), which requires root. When available, it can be used to determine hypervisor version for VMware.
Adds a detector function for VMware hypervisors. Uses the CPUID or DMI data sources for basic detection. When run as root, it can collect the BIOS address via `dmidecode` and use it to include the VMware version in the result.
8672ce5 to
549ebdd
Compare
Adds a new detector for VMware hypervisors.
The first commit adds a new item (BIOS address) to the set of data collected by the DMI detector. Determining the VMware version from inside a guest is tricky - there doesn't seem to be an official approach, but a few blog posts and repositories (example, and another) describe how the BIOS Address can be translated into a version - I included what translations I could find in
vmware_detector.cc, but there are doubtless many others that could be added. This version information is also only available to root, since getting the BIOS address requiresdmidecode.The second commit adds the vmware detector; This is really similar to the existing VirtualBox detector.