Add option to print MAC address and exit #79
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As the name suggests, this adds the -M command line flag that will tell Xhyve to print the MAC address and exit if using vmnet.
This only really has practical use if the -U flag is also supplied with a UUID, so that you can determine which MAC address the UUID will map to. This will allow you to determine the IP address of the guest by inspecting the DHCP leases on the host. The idea being you run xhyve first with the -M flag to figure out ahead of time the MAC and IP address it will get, and then run it for real without the -M flag.
A similar pattern is used by docker-machine-xhyve, and the nearly identical xhyve-ruby native extension that each take the approach of spinning up a network interface just to find out what it's MAC address will be.
The side effect of doing this outside of Xhyve is that the binary performing the lookup has the same 'sudo' problem as outlined in #60. So, if Xhyve were signed or xhyve had SetUID, it can more securely perform the lookup.
I tried to follow the existing style and idioms, and I'm open to any command line flag (-M seemed somewhat sensible). If there is another simpler or better way to achieve this, I'm open to it.
@mist64 for review