// SelectAndPrepareHypervisor Select the preferred hypervisor for the platform, and prepare it if necessary
SelectAndPrepareHypervisor Select the preferred hypervisor for the platform, and prepare it if necessary
// SelectAndPrepareHypervisor Select the preferred hypervisor for the platform and prepare it if necessary
func SelectAndPrepareHypervisor(preferred string) string {
	var m *metadata.Metadata
	var err error
	var vbox string
	if preferred == "auto" {
		m, err = metadata.GetMetadata()
		if err == nil && m != nil {
			preferred = m.Driver
		}
	}
	if preferred == "auto" || len(preferred) < 1 {
		preferred = platformPreferred()
	}
	if preferred == "virtualbox" {
		vboxManageCmd, found := DetectVBoxManageCmd()
		if !found {
			err := downloadVirtualBoxIfNecessary()
			if err != nil {
				fmt.Println("Error downloading VirtualBox: " + err.Error())
				fmt.Println("Continuing but further failures might occur")
			} else {
				fmt.Println("Installing Virtualbox (this may take some time)")
				err = relaunchForInstall("virtualbox")
				vboxManageCmd, found := DetectVBoxManageCmd()
				if found {
					vbox = vboxManageCmd
				}
				if err != nil {
					fmt.Println("Error installing VirtualBox: " + err.Error())
					fmt.Println("Continuing but further failures might occur")
				} else {
					fmt.Println("VirtualBox installed!")
				}
			}
		} else {
			vbox = vboxManageCmd
		}
	} else if preferred == "xhyve" {
		if !isxhyveInstalled() {
			fmt.Println("Installing xyhve driver")
			relaunchForInstall("xhyve")
		}
	}
	if m != nil &&
		(m.Driver != preferred ||
			(preferred == "virtualbox" && m.VirtualBox != vbox)) {
		m.Driver = preferred
		m.VirtualBox = vbox
		metadata.SaveMetadata(m)
	}
	return preferred
}
func SelectAndPrepareHypervisor ( preferred string ) string { var m * metadata . Metadata var err error var vbox string if preferred == " " { m , err = metadata . GetMetadata ( ) if err == nil && m != nil { preferred = m . Driver } } if preferred == " " || len ( preferred ) < 1 { preferred = platformPreferred ( ) } if preferred == " " { vboxManageCmd , found := DetectVBoxManageCmd ( ) if ! found { err := downloadVirtualBoxIfNecessary ( ) if err != nil { fmt . Println ( " " + err . Error ( ) ) fmt . Println ( " " ) } else { fmt . Println ( " " ) err = relaunchForInstall ( " " ) vboxManageCmd , found := DetectVBoxManageCmd ( ) if found { vbox = vboxManageCmd } if err != nil { fmt . Println ( " " + err . Error ( ) ) fmt . Println ( " " ) } else { fmt . Println ( " " ) } } } else { vbox = vboxManageCmd } } else if preferred == " " { if ! isxhyveInstalled ( ) { fmt . Println ( " " ) relaunchForInstall ( " " ) } } if m != nil && ( m . Driver != preferred || ( preferred == " " && m . VirtualBox != vbox ) ) { m . Driver = preferred m . VirtualBox = vbox metadata . SaveMetadata ( m ) } return preferred }
SelectAndPrepareHypervisor Select the preferred hypervisor for the platform, and prepare it if necessary
SelectAndPrepareHypervisor Select the preferred hypervisor for the platform and prepare it if necessary