
Xhyve – Lightweight Virtualization on OS X Based on Bhyve - ingve
http://www.pagetable.com/?p=831
======
bruienne
This runs boot2docker pretty well out of the box. I made the required edits to
xhyverun.sh as found in this gist:
[https://gist.github.com/bruienne/d1053df883b47822c6e](https://gist.github.com/bruienne/d1053df883b47822c6e)

It requires that you copy the vmlinuz64 and initrd.img files from the B2D ISO
to a local filesystem location. As of right now enabling networking requires
root privileges. Not sure if the Hypervisor framework has user-level
accommodations for that.

~~~
bruienne
Blegh,
[https://gist.github.com/bruienne/d1053df883b47822c6e0](https://gist.github.com/bruienne/d1053df883b47822c6e0)

~~~
alfonsodev
thanks! what about volume mounting and port forwarding, are supported already?

------
Osmium
Really glad to see someone using Hypervisor.framework, looks like it has a lot
of potential. Fusion/Parallels always seem far too heavyweight to me.

~~~
tachion
Not to mention they're paid solutions, closed source and are horrible for
battery life. Their only advantage is nice set of GUI tools and tight OS X
integration.

~~~
lvillani
VMWare Fusion is, in my experience, everything but horrible for battery life.
I frequently spin up VMs with Vagrant, do something with them and then switch
to other tasks. More often than not, I forget to shut them off, mostly because
their impact on the battery life is so minimal that I don't notice them until
I run `vagrant global-status`.

~~~
devonkim
This probably depends greatly upon whether your machine has discrete graphics
or not. On Macbook Pros with nVidia graphics like my 2014 higher-tier Macbook
Pro, there is a dramatic loss in battery when the discrete graphics kicks in.
However, most Macs sold now don't have discrete graphics because the Intel
integrated graphics is honestly pretty decent nowadays for most tasks. The
difference is 3 hours of battery and 8+ for me.

Google Chrome, similarly, tends to drain my battery a lot, and that alone has
encouraged me to go to Safari on Macs.

~~~
mrpippy
Or just use gfxCardStatus to lock your machine to the integrated GPU all the
time

~~~
Osmium
Can anyone tell me why this isn't an inbuilt feature of OS X? Preferably in
the 'Energy Saver' pane of System Preferences, e.g. while on battery power,
only use integrated graphics.

~~~
nvartolomei
There was a discussion that sometimes it is better to run a task quick on GPU
than to run it for longer time on CPU. Would be cool if someone could try to
prove this or inverse. :)

~~~
Osmium
Maybe it'll be different in Metal-backed El Capitan, but my experience so far
has been that the discrete GPU universally degrades my battery life. I'm glad
I have it though; sometimes I need it, but it'd be nice if I could just
disable it completely most of the time.

------
alisnic
This is great, is it possible to make it work with Docker?

Edit: Yes, it is.

Edit2: It is possible, but whether is it worth it or not is still a question.
xhyve is a supervisor after all, you still need to boot a vm to use Docker. So
if you like me, thought for a second that this can make containers in OSX a
reality, don't get excited too early.

~~~
mendocino
Not sure how useful OS X containers would be. Are you deploying on OS X?

~~~
alisnic
The benefit for me would be quick, isolated development environments. I want
to boot a contained swarm of services connected to each other in a single
command, and shut them down in a single command as well

~~~
mateuszf
And installing docker / docker-compose / machine, etc. using one brew command
would be a great addition in order to ease introduction of the tool to the
whole team.

~~~
mikewhy

        brew install docker docker-compose docker-machine
        open https://kitematic.com/download/
    

Kitematic might even come with docker, docker-machine. It will then set up a
docker machine for you and you're ready to go.

~~~
mchiang
Yes, Kitematic does install docker-machine automatically which also sets up
docker.

For CLI, in Kitematic menu there is a button where you can install the
binaries.

------
saidajigumi
Definitely time to add Hypervisor.framework to the list of interesting things
on OS X to check out. Related: I'd love to see a Vagrant provider for Xhyve,
may have to hack on that a bit later.

------
sudioStudio64
OK. That's freaking awesome. I like seeing FreeBSD technology being brought
into the mainstream in OS X. (I don't even use OS X, but this is cool.)

------
ionforce
I guess this is pronounced "X-hive" and "B-hive"?

Initially I thought it was "zive" and "bive", like "bive" was a foreign word
from somewhere. Bhyve, the muse of unit tests!

~~~
floatboth
Ten-hive :D

~~~
ttflee
But nobody I know pronounces Xcode as ten-code.

~~~
bsg75
Never thought to. I am starting today.

------
falcolas
Fair warning, this may cause a Kernel panic. I've contributed to the bug with
my trace, but it's definitely something to keep in mind when checking it out.

I really want this to work, though. It would be a great replacement for
VirtualBox.

~~~
techdragon
I honestly wouldn't notice. 10.10 kernel panics on me about once a day. It's
the WORST EVER release of OSX by an amazing margin.

------
philips
I wrote a quick set of scripts to get CoreOS booting under xhyve as a
container host. The defaults will expose SSH and a docker client port and drop
you directly into a shell. Some quick getting started info here:

[https://github.com/coreos/coreos-xhyve#coreos--
xhyve](https://github.com/coreos/coreos-xhyve#coreos--xhyve)

Lots of GitHub issues filed for next steps in exploring this technology.
Really exciting to see a simple CLI driven virtualization option on OSX.
Patches accepted. :)

------
tw04
This project is awesome. No more vmware fusion for me. Props to netapp for
funding and driving the bhyve project. FreeBSD was desperately in need of
native virtualization capabilities.

~~~
4ad
Note that apart from bhyve (available today), FreeBSD 11 will also come with
Xen Dom0 support.

~~~
walterbell
Great news. That will allow ZFS in a FreeBSD driver VM, providing storage for
other guests, even with a Linux dom0. Is FreeBSD 11 expected this year?

~~~
stock_toaster
Next year in july:
[https://www.freebsd.org/releases/11.0R/schedule.html](https://www.freebsd.org/releases/11.0R/schedule.html)

------
jkyle
Ran the script. Hit Ctrl-D instead of sudo halt and it hung, had to kill the
proc from another shell.

But, compiled clean, test vm started fast. Will look at again.

~~~
mendocino
Looks more like an issue with the VM rather than xhyve. Serial console does
not seem to get respawned.

------
mateuszf
It would be great if Docker integrated / embedded that instead of forcing
users to download / configure VirtualBox + boot2docker.

~~~
jkyle
I'm not sure docker would want to do this or if that's even an appropriate
feature to integrate.

I'd rather see it supported by vagrant, which would seem an appropriate tool
to manage them with.

~~~
acdha
Docker has a huge interest in making it easy for the legions of Mac-toting
developers to use it easily without first telling you to get complex, fragile
external tooling like vagrant or virtualbox working.

I doubt it'd go in the mainline product but I'd be shocked if in a year or two
there isn't a Docker.app one-stop option which makes it trivial to run popular
Linux apps.

~~~
jkyle
> use it easily without first telling you to get complex, fragile external
> tooling like vagrant or virtualbox working.

I won't get into virtualbox. But I haven't found vagrant very fragile at all
since Mitchell moved to omnibus (quite a while back). Most of the issues I had
with vagrant were directly related to virtualbox, not vagrant itself.

> Docker has a huge interest in making it easy for the legions of Mac-toting
> developers

Well, sort of. They have a product that is inherently linux based. Getting a
nice setup working on OS X is pretty trivial, takes a developer maybe a couple
of hours one time to have something working.If they use someone else's
solution, it takes minutes.

Here's an ansible task I use to configure an ubuntu machine[1]. It's all of 24
lines. If you're running it against a VM, you just forward the 2375 port to
your host. Then the workflow looks like:

    
    
        vagrant up
        docker build -t jkyle/awesomeness .
    

Course you can get fancier. Ansible can pull down docker projects using git,
build, and run them for you as well.

[1]
[https://gist.github.com/jameskyle/b8e573d63da4dbaaf31a](https://gist.github.com/jameskyle/b8e573d63da4dbaaf31a)

~~~
acdha
Yeah, I know many people who use and like vagrant but I've heard a too many
people mention it as a major impediment when they were just getting starting.
Sure, someone with a bit of sysadmin experience can usually get it working
fairly quickly but I've seen entire meetups where 90% of the people used a
Linux instance on EC2 rather than try to debug it.

Anything which makes that process easier for newcomers is welcome,
particularly for non-specialists like front-end specialists, scientists, data-
analysts and other technical professionals for whom figuring out a toolchain
is a road-block to their job rather than the job itself.

------
walterbell
Hopefully Apple will add Hypervisor.framework support for Intel's hardware-
virtualized graphics, [https://01.org/zh/blogs/skjain/2014/intel®-graphics-
virtuali...](https://01.org/zh/blogs/skjain/2014/intel®-graphics-
virtualization-update?langredirect=1)?

------
osxrand
I'm curious why there is a restriction of 2010 or newer mac. Is it something
in the CPU that's needed? I've 10.10.3 installed on a non supported mac and
wanted to use this, but getting errors when I try the test Linux

~~~
tw04
You need a CPU that supports Intel's virtualization instruction set.
Specifically VT-x. You can check if your CPU supports it with: sysctl
machdep.cpu.features

You're looking for VMX. Here's an example from mine (highlighted the flag
you're looking for):

machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA
CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ
DTES64 MON DSCPL * VMX * SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2
x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C

~~~
mrsteveman1
Most Macs have had VT-x enabled since.... 2007?

The critical hardware feature they _didn 't_ all have is EPT[1], which may be
required here in addition to VT-x.

[1]
[https://en.wikipedia.org/wiki/Second_Level_Address_Translati...](https://en.wikipedia.org/wiki/Second_Level_Address_Translation#EPT)

~~~
ruda
This (missing) EPT must be the reason my MacBook Pro from 2009 is crashing
when running it. Thanks for pointing that

------
72deluxe
That's really great! I had to rebuy VMware at work and Parallels at home when
Yosemite came out because of the new hypervisor framework modifications that
these two needed under Yosemite (I presume).

I don't really use the OSX integration of both systems, other than file
mapping/sharing (I run Linux and Windows VMs).

Glad to see this, many thanks!

~~~
acdha
I don't know about Parallels but VMWare Fusion 6 runs just fine on Yosemite –
there's almost no reason to upgrade unless you want new icons.

That said, I'm completely with you on the value of Hypervisor.framework for
people who are e.g. running Linux test instances and not really seeing much
benefit from the UI integration but who still want to avoid the performance /
stability problems caused by using virtualbox.

~~~
72deluxe
I had been making do with VMWare Fusion 5, so it truly refused to work on
Yosemite. (I also had Parallels 8 at home, which refused to work).

Hopefully the upgrades will be only necessary every two years.

Stability problems with VirtualBox are very real. I haven't touched that for
years.

~~~
driverdan
> Stability problems with VirtualBox are very real. I haven't touched that for
> years.

What issues do you have? I've been running VirtualBox on OS X for 6+ years and
have never had stability issues. I usually have a few VMs running at a time
via vagrant.

~~~
72deluxe
Under Snow Leopard (yes it was that long ago) it would frequently kernel panic
so I stopped using it. I have never had VMware kernel panic on me; Parallels
has crashed once or twice but never kernel panicked.

I did use VirtualBox for running Windows 95 the other month though. I am not
complaining about VirtualBox or advising against its use, just I had some
issues on OSX.

Under Windows and Linux it ran fine, just OSX was dodgy for me.

------
tachion
The title is a bit misleading, it could say 'Xhyve – Lightweight
Virtualization for OS X based on FreeBSD's Bhyve'

~~~
pyvpx
Bhyve is FreeBSDs...? I don't follow how it is misleading.

~~~
tachion
It is in fact - it is called The BSD Hypervisor [1] and so far it exists only
on FreeBSD, and this is where it was born. There are some forks to port it to
other platforms (like Joyent's SmartOS) but they're closed and not out yet.

I consider technology awareness, competition and diversity a very good thing,
therefore I think its important to mention FreeBSD in this case (and other
BSD's too in other cases).

By the way, have you donated to FreeBSD [2] and OpenSSH [3] yet? ;)

[1] [http://bhyve.org/](http://bhyve.org/)

[2]
[https://www.freebsdfoundation.org/donate/](https://www.freebsdfoundation.org/donate/)

[3]
[http://www.openbsd.org/donations.html](http://www.openbsd.org/donations.html)

~~~
pyvpx
I've been buying OpenBSD CD's since 3.4 and a long time friend has commit bits
with the FreeBSD project. I am a big BSD supporter :)

