Skip to content
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

Merged
merged 2 commits into from
Dec 15, 2016

Conversation

rdean716
Copy link
Contributor

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

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."
Copy link
Contributor

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.

Copy link
Contributor Author

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.'?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can!

Copy link
Contributor Author

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 -" ...

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reference.

@tas50
Copy link
Contributor

tas50 commented Dec 14, 2016

@rdean716 Also make sure to rebase that last commit with the DCO sign-off

@tas50
Copy link
Contributor

tas50 commented Dec 14, 2016

@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>
@rdean716
Copy link
Contributor Author

@tas50 - everything looks good now.

@tas50 tas50 merged commit 09813a9 into chef:master Dec 15, 2016
@tas50
Copy link
Contributor

tas50 commented Dec 15, 2016

Nice stuff. Thanks

@tas50 tas50 changed the title Windows guest support on Hyper-v and Xen. Detect Windows guests running on Hyper-v and Xen Jan 23, 2017
@tas50 tas50 added the Type: Enhancement Adds new functionality. label Apr 11, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants