-
Notifications
You must be signed in to change notification settings - Fork 453
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
Detect Windows guests running on Hyper-v and Xen #922
Conversation
Signed-off-by: Bob Dean <radean@hotmail.com>
@@ -44,6 +44,14 @@ | |||
virtualization[:system] = "kvm" | |||
virtualization[:role] = "guest" | |||
virtualization[:systems][:kvm] = "guest" | |||
when "American Megatrends Inc." |
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.
This is probably going to catch some systems that are also using American Megatrends BIOS and identify them as VMs when they're actually hardware. We need to key off this and something else that is unique to a hyper-v system.
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.
In reviewing a few different guests running on different version of hyper-v, the smbiosbiosversion property appears to be '090006' consistently. Reasonable to evaluate that when the manufacturer is 'American Megatrends Inc.'?
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.
We could probably use that.
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 next property that seems to be semi consistent is version. On one version of hyper-v its value is 'VRTUAL - 5001223' and on another it is 'VRTUAL - 4001628'. I have no idea what factors cause this to change. But, it seems messy to try to match on a partial string.
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.
Matching on that 'VRTUAL - ' string is probably what we want here. That would avoid mis-identifying a hardware system entirely. Can you switch to that from smbiosbiosversion?
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.
I can!
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.
I am fairly new to ruby, are you ok with this - if bios[0]["version"].include? "VRTUAL -" ...
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.
I think what you want here is a match with a regex. There's two ways to do that with ruby, but the easiest here is:
if bios[0]["version"] =~ /VRTUAL -/
Here's a nice doc with all your options:
https://ruby-doc.org/core-2.2.0/Regexp.html
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.
Thanks for the reference.
@rdean716 Also make sure to rebase that last commit with the DCO sign-off |
92f225c
to
d334cdf
Compare
@rdean716 You have a Chefstyle warning showing up in travis. Run chefstyle -a and that should get autocorrected. |
Signed-off-by: Bob Dean <radean@hotmail.com>
d334cdf
to
d2c6297
Compare
@tas50 - everything looks good now. |
Nice stuff. Thanks |
Description
This change allows Windows guest systems to detect the virtualization platform when running on both Hyper-v and Xen.
Issues Resolved
#664
Check List
Signed-off-by: Bob Dean radean@hotmail.com