Hyper-V support #1244

Closed
Iristyle opened this Issue Dec 4, 2012 · 77 comments

Projects

None yet
@Iristyle

I see an issue for VMWare here.. but I don't see any mention of Hyper-V.

I see the list mentioned in the blog post here as well... but also no Hyper-V.

Hyper-V support would be great to see on the roadmap.

@awildeep

+1 on the hyper-v support.

@Elufimov

+1 on the hyper-v support.

@dakull

+1 on the hyper-v support.

@Atchuu

+1 on the hyper-v support.

@blackjid

+1 on a hyper-v provider!

@dakull

Is this even feasible ? I mean does it have any clear benefits compared to VirtualBox ? Performance wise I reckon it should be more or less the same as most of us just use it to clone production environments that don't use any graphical env. and if you have your VHD on a SSD the IO bottleneck goes away; CPU wise even a 20-30% delta can go under the radar when you use an i5 or i7 cpu.

@Iristyle

Well, let's put it this way... A few members of my team were working off of a Hyper-V VM, but I decided to move us all over to a custom VeeWee-built VritualBox basebox, plus a Vagrant package with Puppet customizations for things we care to version bump across the team (Riak, ElasticSearch and Redis). This made it more manageable for me to make sure everyone is using the same version of everything, etc.

We've had nothing but issues with VirtualBox -- frankly, I think it's a gigantic POS compared to Hyper-V or VMWare. One of my biggest gripes is that it's not setup to run as a system service, so if you happen to reboot and forget to vagrant halt or vagrant suspend, then you risk corrupting your VM. They recently added service like support to some operating systems, but not Windows.

We're also seeing a lot of weirdness with the VirtualBox gui tools -- with 4.2.10 and Vagrant 1.0.6, once Vagrant has touched the VM, the VirtualBox GUI tools crash on startup. Unless you're familiar with VBoxManage, it can be hard to know what is / isn't running. I've also had issues where Vagrant reports that the VM isn't running, but I can see the VM running in the GUI tools -- not sure if that's an issue with Vagrant or with VirtualBox. I end up having to manually shut the VM down, then reboot... for Vagrant to start seeing it again.

As far as the performance goes, I think it's pretty well established that VirtualBox lags the others by quite a bit. If you Google around, you should be able to find benchmarks.

Windows 8 now ships with Hyper-V in the box, and it's integrated quite nicely. No need to install buggy VirtualBox, or purchase a VMware license. To me, that reason alone is compelling.

My 2c.

@awildeep

The other reason this is compelling would be for server provisioning. Vagrant isn't just for setting up a development environment.

@dakull

@Iristyle I don't really use the VirtualBox GUI and had no issues whatsoever yet I do agree that the integration in Windows 8 of Hyper-V sweetens the need for this feature with the added bonus of Hyper-V running in ring 0.

@awildeep server provisioning ? what about puppet/chef ?

@Iristyle

@dakull I generally don't use the GUI either. However, some of the devs on the team don't know where to look for the Vagrantfile, etc -- so to shut down things, its easier to hop into the GUI and shut it down (as mentioned, this can also become necessary if Vagrant can't connect to the running VM, which has happened to me many many times).

I just want to give them a VM with services / ports that just works. One thing that would help a bit here is a global registry of Vagrantfile / .vagrant to running VM. Something like box list, but for running VMs -- so you don't have to be in the proper directory at the console to control running VMs.

@dakull

This might help : http://www.virtualbox.org/manual/ch08.html#vboxmanage-list you can then have a script that checks for rogue VMs.

Regarding the sanity of the VMs I think that depends on ones workflow : I like to keep things idempotent so when something breaks I can easily recreate the vagrant env. and just do a git clone of my app source.

@Iristyle

@dakull sure, you can use VBoxManage. But the point is that I think that should be part of Vagrants responsibility... especially so if you're using Vagrant to normalize the underlying VM tools in VirtualBox / VMWare.

@am11

+1 and here is the list of posh ver 3.0 cmdlets for Hyper-V http://technet.microsoft.com/en-us/library/hh848559.aspx.

@mitchellh
Owner

Custom providers can now be made! http://docs.vagrantup.com/v2/plugins/providers.html

I have no short term plans to officially support Hyper-V, but I'd love to in the future.

@mitchellh mitchellh closed this Apr 7, 2013
@Iristyle

So in other words...

Basic class definition -> https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/provider.rb
VirtualBox 4.2, for instance -> https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/driver/version_4_2.rb

Doesn't look too difficult, but I don't have the cycles at the moment -- any takers? ;0

@Iristyle

I'm swamped and haven't had time yet...

@julezman

We will also take a look at contributing or doing this if there is time too. Powershell route suggested by am11 seems a possibility

@Nicholas-Perry

I would love to work on this, but I don't know where to start. Can someone with more experience break down what needs to get done? I want to get discourse running on my hyper-v cluster using their vagrant configuration: http://blog.discourse.org/2013/04/discourse-as-your-first-rails-app/

@am11

I guess the first step would be to detect if client's hardware supports Second Level Address Translation (SLAT); a pre-requisite of Hyper-V to run VM and an advanced virtualization technology refers to Intel's EPT (Extended Page Tables) or AMD's RVI (Rapid Virtualization Indexing). Here is a good read on it and a way to detect its support in OS using coreinfo.exe.

After that, our corresponding base class may look something similar to:

def initialize
    if Vagrant::Util::Platform.windows? && slat_supported?
       #SLAT is supported, continue checking Hyper-V availability
    end
end

def slat_supported?
   #Assuming coreinfo.exe is available in ruby's bin dir
   slat_dump = `coreinfo -v`
   slat_marker = slat_dump.slice(-45, 1) 

    # slat_marker = '*' means slat is available, slat_marker = '-' means unavailable
   return slat_marker == '*'
end

Unless there is an explicit way to detect SLAT support via syscall, this approach will confirm that the installed Hyper-V feature is eligible to create VM.

@am11

I've found another way of checking SLAT support, using PowerShell. The method suggested in the aforementioned blog is querying Selected.System.Management.ManagementObject and returning the desired value using pipeline approach, which also provides access to members using dot (. as in .NET way!).

Our slat_supported? method may look like:

def slat_supported?
  return `powershell "(gwmi win32_processor).SecondLevelAddressTranslationExtensions"`.include? "True"
end

So the dependency on coreinfo.exe is gone resulting in cleaner code.

@factormystic

@am11 No need to shell out to run a WMI query...

https://gist.github.com/factormystic/5452265

require 'win32ole'

wmi = WIN32OLE.connect('winmgmts://')
result = wmi.ExecQuery('select SecondLevelAddressTranslationExtensions from Win32_Processor').to_enum.first

if result && result.SecondLevelAddressTranslationExtensions
  puts 'SLAT Available'
else
  puts 'SLAT Not Available'
end
@am11

@factormystic, thanks for the simplicity. Next step in initializer function would be to identify if Hyper-V is installed. I couldn't find a better/native way of detecting that. So, I started with this PowerShell script to test of Start-VM cmdlet exists:

Function CmdletExists ($cmdName) 
{ 
    if (Get-Command $cmdName -errorAction SilentlyContinue -CommandType Cmdlet)
    { 
        return 1; 
    } 
    return 0;
}

# call CmdletExists on Start-VM
CmdletExists "Start-VM";

from irb >

`powershell Function CmdletExists ($cmdName) { if (Get-Command $cmdName -errorAction SilentlyContinue -CommandType Cmdlet) { return 1; } return 0;}; CmdletExists('Start-VM');`.to_i

I tested on two machines running Windows 8 Pro. One with SLAT and Virtualization capability and one without (only Hyper-V management and remote control is visible to connect to remote VMs or VM-servers). I was hoping that that the aforementioned script would return 1 only when Hyper-V management has the ability to host VM locally. But unfortunately, it returns 1 on the both machines.

So I moved on to Service test. In the machine where I had the ability to host VMs locally, there was a service Hyper-V Virtual Machine Management, which wasn't present in the other system. Here is the PS script to identify if service is installed:

Function TestServiceExists ($ServiceName) 
{
    if (Get-Service $ServiceName -ErrorAction SilentlyContinue)
    {
        return 1;
    }
    return 0;
}

TestServiceExists("Hyper-V Virtual Machine Management");

from irb >

`powershell Function TestServiceExists ($ServiceName)  { if (Get-Service $ServiceName -ErrorAction SilentlyContinue) { return 1;} return 0; }; TestServiceExists('Hyper-V Virtual Machine Management');`.to_i

Do you know any better way to check if service exists from Win32OLE OR to detect the Hyper-V exists and it has the ability to host VMs locally?

@supernovae

Anyone got any movement on this?

@alexsandro-xpt

+1 on the hyper-v support.
Please...

@rhbecker

I found this: https://github.com/anurse/vagrant-hyperv/

Any other works in progress out there?

@rahmit

The project at https://github.com/anurse/vagrant-hyperv/ is just a skeleton - the project is created but nothing is implemented.

+1 and still looking for Hyper-V support.

@tehgeekmeister

I've started work on this over here, and will keep working on it as I can find time.

If you want to support work on it, I've got a project up on BountySource to get an alpha version of this ready for an $1,100 goal. Seems we might be able to hit such a goal.

@kernel-io

I've also started work on this, along with the other thousand GitHub residents. I have basics so far, i.e: listing all vm's known by hyper-v, creating a new VM + Managing its power states (havent decided on a box format yet, will have to read the docs). For now i'm aiming at something simple that shares a few folders and forwards some ports as that is all I will need to get dev happening on windows.

Still getting my head around how to best structure a Vagrant plugin.

@am11

Guys I have found another set of cmdlets (Start, Stop, Restart, Configure, Create, List, Suspend, Resume, Connect) for Hyper-V. http://technet.microsoft.com/en-us/library/hh831705.aspx

These work on Windows 8, 8.1, 2012 and 2012 R2 (although the documentation doesn't mention that).

Hopefully, it will help the folks still working on it. :)

@tehgeekmeister

I lost interest in this a while back, too busy with other projects and my personal life. Hope someone else does it, though.

@kernel-io, I found the included plugins very helpful in figuring that out. Check out the virtual box provider.

@ionelmc

Would be nice to have support for hyperv (mainly because of fantastic IO performance)

However, hyperv not being a user-level hypervisor, it doesn't have any NAT support (don't even think about doing anything with internet connection sharing, it blows) and no shared folders for linux. Anyone know if those can/will be fixed?

@am11

@ionelmc,

If it ain't broke, don't fix it.

You can certainly enable NAT'ed internet with Hyper-V on Windows 2008, 2008-R2, 8, 8.1, 2012 and 2012-R2.

http://technet.microsoft.com/en-us/video/nat-hyper-v.aspx
http://blog.areflyen.no/2012/10/10/setting-up-internet-access-for-hyper-v-with-nat-in-windows-8/

You can also share folder with internal connection like a regular sharing on network with UNC path (I wonder why do you think it would blow?). If you want Internet access with internal connection (an obvious use case), you may have multiple connections in Virtual Switch Manager assigned to a VM, say first one is internal (local only) and the second is external with the Internet access.

For the windows folder's permissions, you can grant to Everyone and then mount its UNC path to /vagrant in Linux. Or if you want to retain/respect the file system's permissions, you can simply mount the UNC path (lets say //windows-pc/doodlebug for C:\Users\user1\Documents\GitHub\doodlebug\) to /vagrant using:

mount -t cifs -o username=window-pc\user1 //windows-pc/doodlebug /vagrant

If you want elaborated method, you may preemptively install Samba package in your box, configure a domain user and then grant the suitable permissions in Windows to this user. For instance, headless-ubuntu is the vm name on network and sudev is your user you configured with Samba, you can grant full permission to headless-ubuntu/sudev on the folder to share in Windows or the entire volume. Finally, mount UNC path to /vagrant using Samba (for NTML authentication). But I guess Samba won't be necessary for merely mounting folder between host and guest OSes.

@ionelmc

Well I don't want to leave you wondering 😃

Here are my woes with ICS:

  • You cannot configure the addresses it will use. It will always use the same IPs (192.168.100.XXX). This generally not an issue but turns out I have a router that uses the same ips, and you cannot change that. Now I'm looking at this ridiculous router-daisy-chain workaround that sits on my desk.
  • It is unreliable.

    • If you use windows 8 it will mess up your messaging software. After few months of having a hanging skype or pidgin process that you cannot kill (because the process is in wait:executive state) and the only workaround is rebooting windows I think it is fair to say that ICS blows. Turns out ICS was causing this - I've change the ICS startup to manual, no more lockups. Now you just need to be careful to not start ICS before skype ... Mind you, this is not something that you would blame on the windows kernel - linux has this too - the nefarious D state. ICS is a joke that runs in the kernel, a really bad joke. I haven't tried ICS on windows 8.1 tho ...
    • The service will eventually get stuck and unusable if you fiddle and reconfigure it too much. Workaround: reboot. This is not serious software.

Now, why use NAT in the first place, when you can bridge your vm ? It's not that hard to put a firewall in the vm ...

Well, basically: god damn VPNs. You cannot share a vpn connection to a bridged vm. This blows, and some people don't have a choice :(

@ionelmc

And shared folders ? cifs and samba are a joke. Try running git status on that and then run in despair.

I mean virtualbox's shared folders is SLOW: takes 10 second to run git status on some project of mine. Do you seriously expect people to use something couple orders of magnitude slower ?!

@am11

@ionelmc, well some people follow different workflow:

  • Operate git from host.
  • Development on host.
  • Deployment on guest VM.

Some even put everything running on vagrant box while keeping the host OS clean (don't use /vagrant at all). The whole idea is to isolate the dev environment(s) from the host.

Once we have vagrant working with Hyper-V, we can then worry about the performance comparisons.

All I am saying, its possible to automate the process of hooking host's folder with guest using HV. In addition to VMware and VirtualBox, if we have a HV adapter in vagrant (even at the expense of allegedly slow performance), it would be considered as a value added feature for many devs running new version of Windows host.

@jamesmanning

Not sure if it helps or not, but looking at the forks of anurse/vagrant-hyperv, it looks like @Sauraus did a bunch of work in July in the ROBLOX/vagrant-hyperv fork

https://github.com/ROBLOX/vagrant-hyperv/commits/master

@Sauraus - is this something that's already up and working, and/or something others could help you with?

Thanks!!

@Sauraus

I am at the point where I can build new base boxes using veewee, the next step it to figure out how to do Vagrant. HyperV has some significant differences to all other hypervisors which make it a real PITA to do any kind of rapid development work on it.

The biggest problem to resolve is the fact that VMs running on HyperV have no access to the local storage system, eg. shared folders between the Host & Guest are impossible.

@shawnholt

+1 for Hyper-V!!

@ghost

+1520 for Hyper-V support! But unless Microsoft doesn't support file explicit sharing option, its not possible.

Nonetheless, Gavin Gear from Extreme Windows Blog stated: "While what you describe is not currently supported, you can achieve basically the same thing with enhanced session mode and drive redirection, albeit only with VM images that support enhanced session mode (see list in this article)." - (comment @ http://blogs.windows.com/windows/b/extremewindows/archive/2013/12/05/overview-client-hyper-v-enhanced-session-mode-in-windows-8-1.aspx)

@RobBiddle

Please don't think of this as merely an alternative to locally hosted VirtualBox VMs. (This is directed towards the complains about local storage sharing and local NAT)

Yes, you certainly could use Hyper-V in lieu of VirtualBox for local dev work, but that's not really the main use case for the alternative providers in Vagrant.

The awesome thing about Vagrant providers is the ability to:
1. Deploy to production environments (NO ONE would choose to run VirtualBox in a non-trivial production environment).
2. Testing in an environment identical to your production environment. e.g. Develop locally in VirtualBox (or Hyper-V I suppose), deploy to a dev/test Hyper-V/Xen/Vmware/AWS cluster for final testing, then finally deploy to production Hyper-V/Xen/Vmware/AWS.

I've been an advocate of XenServer for several years, but Hyper-V in 2012 R2 is looking like it may be the better option right now for small/medium sized private-cloud type setups. Vagrant support would make it much better.

@vasekboch

+1 available for every windows developer

@mickdelaney

+1 for Hyper-V!!

@Sauraus

A quick update from my side, I am currently able to build and export 'veewee' built VMs on HyperV, that's the good news, now for the bad.

Unfortunately due to HyperV's security architecture shared folders between host and guest are only supported using Kerberos authentication which is more than just small problem when dealing with dynamic VMs being created on a HyperV host that is part of a domain.

If anyone knows of an easier way to share folders between a HyperV guest & host (or workstation) then please reply to this thread.

@jcii

@Sauraus Regarding Kerberos authentication:

Is the problem with Kerberos that you don't have the libraries available on linux? or from the ruby script environment?

@Sauraus

My understanding of how Kerberos authentication works in a Windows Domain is that it requires both source & target host to be registered in the domain tree, which is not an impossible problem but I have to yet meet the first AD admin who is happy with me adding and deleting hosts on a continuous basis to there AD tree. ;)

@ionelmc
@Sauraus

There are several threads on MS' TechNet about shared folders between Guest & Host using HyperV and how Kerberos fits into that.

@ionelmc
@rgardler

Here at MS Open Tech we have been following this issue with interest. We'd love to hear more about the work done so far and the blocks being hit. If the problems being faced can be expanded upon I'll see if I can get a good answer for you. Alternatively, is this work available in a public repo anywhere?

@Sauraus

@rgardler this thread has some of the details although the title is misleading I have to admit: http://social.technet.microsoft.com/Forums/windowsserver/en-US/3f2528f3-3948-42e3-8d8a-bf9e95dce30e/hyperv-virtual-machine-management-service-not-start-with-domain-user-account?forum=winserverhyperv#a249845f-4aed-439a-aec0-2d9b88273b33

But the easiest way for you to repo the issue is to install VirtualBox and Vagrant on your desktop and take it for a spin and then to observe how files are presented to the guest OS from the host when provisioning the guest OS using something like Chef.

VirtualBox is able to access a folder on the host machines from the guest OS through their integration services. AFAIK using HyperV this is only possible using 'constrained delegation' which depends on Kerberos.

@ghost

@rgardler, does it mean no more PUTTY and we will finally get SSH support natively in Windows too (as vagrant requires ssh)? Vagrant requires SSH and it is proven to be a most common protocol in server-client/host-guest environments. Denying this fact over a decade is not helping anyone.

@supernovae

@jasonwilliams200OK

Can't we just make a Cygwin requirement? Windows + Cygwin pretty much answers the tool chain requirement.. There are wrappers such as CopSSH to make it easier to manage.

@rgardler

@Saurus Thanks for the info. I've asked one of the team exploring the Vagrant options to look into the problem you are facing. Hopefully I'll be able to provide a constructive response soon.

@ferventcoder

w00t! There are some folks I know that would like to see some Hyper-V love. Appreciate you taking point @rgardler :)

@ghost

@supernovae, now why would we do that? Unless we are killing birds with canons.

Cygwin is like an instance of headless linux, with tons of utilities which windows already provides (especially in powershell). Vagrant just require ONE missing util; SSH.

Remember, here the target platform is Windows 8+ (client), which support Hyper-V management and those systems usually come with edge version of PowerShell and WMI installed.

@supernovae

@jasonwilliams200OK
It's all about the tools. I'm not sure why anyone would want to exclude Cygwin. If Cygwin keeps this with more parity along the lines of the unix counterparts, to me, that is a positive thing. I agree, embrace powershell and cool stuff like that but don't be afraid of Cygwin, its awesome.

@ghost

@supernovae,

I agree that Cygwin is awesome, so is minGW.

The whole point of vagrant is to install less dev related applications on host system and more on portable vagrant instances. You won't be deprived of Unix counterpart anyway when you are running Ubuntu via vagrant.

SSH (a small utility vs huge Cygwin/MinGW packs) is the only thing missing in fresh windows 8x PC (of course with VirtualBox/VMware installed), which is preventing users native CLIs (cmd and powershell). Not to mention other benefits of SSH, SCP etc.

Putty is the light-weight solution, but still not integrable with native shell prompt. Having native ssh support in Windows would be a great welcoming addition.

@ferventcoder
@jachin84

I've got some time to spend on this and have significant experience on the Windows and Hyper-V side. Where are we targeting our efforts?

@ionelmc

Looks like there a new feature in later hyperv: "guest services" that allows out of band file sharing - http://blogs.technet.com/b/keithmayer/archive/2013/11/22/why-r2-guest-services-in-windows-server-2012-r2-hyper-v.aspx

Not sure about support in linux - anyone have any idea here ?

@am11

@ionelmc, thanks for the headsup.

Here is the information on Linux support http://technet.microsoft.com/en-us/library/dn282278.aspx#bkmk_linux.

Separately; will it make copy of each file on VMBus we want to share between host and guest? Or just add its reference in an xml file, so we don't have multiple copies? If its latter, then its sane.

@ionelmc

@am11 Unfortunately they don't appear to have anything on the linux feature grid about the "out of band files sharing" thing.

Looks like it would require developing some integration service/filesystem kernel module for Linux - I wonder if @rgardler has any input on this ...

@rgardler

MS Open Tech just released initial code for a Hyper-V provider for Vagrant. See blog at http://msopentech.com/blog/2014/02/25/vagrant-and-hyper-v-provides-managed-devops-work-environments/ or code at https://github.com/MSOpenTech/vagrant/

We would love to have feedback (and code where appropriate) from folks interested in Hyper-V support.

@Iristyle

@rgardler great news!

@rgardler

Thanks @ntwb, I just updated my original comment as I had a cut and paste error on the code link

@alexsandro-xpt

Really nice news :D

@jachin84

Sweet, testing now!

@rgardler

Awesome - our Hyper-V support is now in the 1.5 release - you don't need to checkout our provider separately.

@ghost

This is awesome news.

But how does it solve the sharing problem? With VirtualBox, we get a bi-directional folder share without even connecting to network. Can we do the same with Hyper-V's SMB? Is SMB share as swift as VirtualBox share?

In other words, what is NOT supported with Hyper-V SMB share when compared to VirtualBox's sharing? As there are number of complains on shortcomings of Hyper-V, previously posted in this thread! Anyone?

@rgardler

There does need to be a connection between the host and the guest, but that need not be connected to the outside world.

I've not done exhaustive performance testing myself but the docs say "SMB is built-in to Windows machines and provides a higher performance alternative to some other mechanisms such as VirtualBox shared folders." http://docs.vagrantup.com/v2/synced-folders/smb.html

@ghost

@rgardler , thanks! BTW, Windows 8 also comes with Hyper-V per-installed. What is missing in 8's Hyper-V which renders 8.1, the minimum OS requirement? Some systems are not updated to 8.1 at our workplace (yet). The list of missing features would help convincing our IT folks to schedule update soon.

@rgardler

@jasonwilliams200OK for Windows guests we needed Windows 8.1 for remote PowerShell execution. Linux guests should work fine on Windows 8, but we are not testing that (would good to hear from anyone trying it out)

@brizzbane

Does this for sure not work on windows server 2008 R2? Have been using Hyper-V with windows servers for quite a while, and really wanted to start using Hyper-V.

Windows 8.1 is only version of windows that works, or will later windows server versions work?

It's hanging at checking for hyper-v for me (Windows 2008 R2 Standard)

(Trying to spin up instances using vagrant on a windows server--don't want to spin up windows server machines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment