Windows: Default to Hyper-V Containers on client

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-04-14 17:12:02 -07:00
parent 8f9c5000e6
commit f25ade22d4

View file

@ -3,10 +3,13 @@ package system
import ( import (
"syscall" "syscall"
"unsafe" "unsafe"
"github.com/Sirupsen/logrus"
) )
var ( var (
ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0")
procGetVersionExW = modkernel32.NewProc("GetVersionExW")
) )
// OSVersion is a wrapper for Windows version information // OSVersion is a wrapper for Windows version information
@ -18,6 +21,21 @@ type OSVersion struct {
Build uint16 Build uint16
} }
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
type osVersionInfoEx struct {
OSVersionInfoSize uint32
MajorVersion uint32
MinorVersion uint32
BuildNumber uint32
PlatformID uint32
CSDVersion [128]uint16
ServicePackMajor uint16
ServicePackMinor uint16
SuiteMask uint16
ProductType byte
Reserve byte
}
// GetOSVersion gets the operating system version on Windows. Note that // GetOSVersion gets the operating system version on Windows. Note that
// docker.exe must be manifested to get the correct version information. // docker.exe must be manifested to get the correct version information.
func GetOSVersion() OSVersion { func GetOSVersion() OSVersion {
@ -34,6 +52,18 @@ func GetOSVersion() OSVersion {
return osv return osv
} }
// IsWindowsClient returns true if the SKU is client
func IsWindowsClient() bool {
osviex := &osVersionInfoEx{OSVersionInfoSize: 284}
r1, _, err := procGetVersionExW.Call(uintptr(unsafe.Pointer(osviex)))
if r1 == 0 {
logrus.Warnf("GetVersionExW failed - assuming server SKU: %v", err)
return false
}
const verNTWorkstation = 0x00000001
return osviex.ProductType == verNTWorkstation
}
// Unmount is a platform-specific helper function to call // Unmount is a platform-specific helper function to call
// the unmount syscall. Not supported on Windows // the unmount syscall. Not supported on Windows
func Unmount(dest string) error { func Unmount(dest string) error {