mirror of https://github.com/docker/docs.git
Merge pull request #3463 from malex984/add-virtualbox-ui-type
Adding an optional VM's UI type for the virtualbox driver
This commit is contained in:
commit
ba9219eb03
|
|
@ -28,6 +28,7 @@ const (
|
||||||
defaultHostOnlyCIDR = "192.168.99.1/24"
|
defaultHostOnlyCIDR = "192.168.99.1/24"
|
||||||
defaultHostOnlyNictype = "82540EM"
|
defaultHostOnlyNictype = "82540EM"
|
||||||
defaultHostOnlyPromiscMode = "deny"
|
defaultHostOnlyPromiscMode = "deny"
|
||||||
|
defaultUIType = "headless"
|
||||||
defaultDiskSize = 20000
|
defaultDiskSize = 20000
|
||||||
defaultDNSProxy = true
|
defaultDNSProxy = true
|
||||||
defaultDNSResolver = false
|
defaultDNSResolver = false
|
||||||
|
|
@ -62,6 +63,7 @@ type Driver struct {
|
||||||
HostOnlyCIDR string
|
HostOnlyCIDR string
|
||||||
HostOnlyNicType string
|
HostOnlyNicType string
|
||||||
HostOnlyPromiscMode string
|
HostOnlyPromiscMode string
|
||||||
|
UIType string
|
||||||
NoShare bool
|
NoShare bool
|
||||||
DNSProxy bool
|
DNSProxy bool
|
||||||
NoVTXCheck bool
|
NoVTXCheck bool
|
||||||
|
|
@ -86,6 +88,7 @@ func NewDriver(hostName, storePath string) *Driver {
|
||||||
HostOnlyCIDR: defaultHostOnlyCIDR,
|
HostOnlyCIDR: defaultHostOnlyCIDR,
|
||||||
HostOnlyNicType: defaultHostOnlyNictype,
|
HostOnlyNicType: defaultHostOnlyNictype,
|
||||||
HostOnlyPromiscMode: defaultHostOnlyPromiscMode,
|
HostOnlyPromiscMode: defaultHostOnlyPromiscMode,
|
||||||
|
UIType: defaultUIType,
|
||||||
DNSProxy: defaultDNSProxy,
|
DNSProxy: defaultDNSProxy,
|
||||||
HostDNSResolver: defaultDNSResolver,
|
HostDNSResolver: defaultDNSResolver,
|
||||||
BaseDriver: &drivers.BaseDriver{
|
BaseDriver: &drivers.BaseDriver{
|
||||||
|
|
@ -158,6 +161,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
|
||||||
Value: defaultHostOnlyPromiscMode,
|
Value: defaultHostOnlyPromiscMode,
|
||||||
EnvVar: "VIRTUALBOX_HOSTONLY_NIC_PROMISC",
|
EnvVar: "VIRTUALBOX_HOSTONLY_NIC_PROMISC",
|
||||||
},
|
},
|
||||||
|
mcnflag.StringFlag{
|
||||||
|
Name: "virtualbox-ui-type",
|
||||||
|
Usage: "Specify the UI Type: (gui|sdl|headless|separate)",
|
||||||
|
Value: defaultUIType,
|
||||||
|
EnvVar: "VIRTUALBOX_UI_TYPE",
|
||||||
|
},
|
||||||
mcnflag.BoolFlag{
|
mcnflag.BoolFlag{
|
||||||
Name: "virtualbox-no-share",
|
Name: "virtualbox-no-share",
|
||||||
Usage: "Disable the mount of your home directory",
|
Usage: "Disable the mount of your home directory",
|
||||||
|
|
@ -220,6 +229,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||||
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
|
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
|
||||||
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
|
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
|
||||||
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
|
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
|
||||||
|
d.UIType = flags.String("virtualbox-ui-type")
|
||||||
d.NoShare = flags.Bool("virtualbox-no-share")
|
d.NoShare = flags.Bool("virtualbox-no-share")
|
||||||
d.DNSProxy = !flags.Bool("virtualbox-no-dns-proxy")
|
d.DNSProxy = !flags.Bool("virtualbox-no-dns-proxy")
|
||||||
d.NoVTXCheck = flags.Bool("virtualbox-no-vtx-check")
|
d.NoVTXCheck = flags.Bool("virtualbox-no-vtx-check")
|
||||||
|
|
@ -493,14 +503,14 @@ func (d *Driver) Start() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil {
|
if err := d.vbm("startvm", d.MachineName, "--type", d.UIType); err != nil {
|
||||||
if lines, readErr := d.readVBoxLog(); readErr == nil && len(lines) > 0 {
|
if lines, readErr := d.readVBoxLog(); readErr == nil && len(lines) > 0 {
|
||||||
return fmt.Errorf("Unable to start the VM: %s\nDetails: %s", err, lines[len(lines)-1])
|
return fmt.Errorf("Unable to start the VM: %s\nDetails: %s", err, lines[len(lines)-1])
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Unable to start the VM: %s", err)
|
return fmt.Errorf("Unable to start the VM: %s", err)
|
||||||
}
|
}
|
||||||
case state.Paused:
|
case state.Paused:
|
||||||
if err := d.vbm("controlvm", d.MachineName, "resume", "--type", "headless"); err != nil {
|
if err := d.vbm("controlvm", d.MachineName, "resume", "--type", d.UIType); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Infof("Resuming VM ...")
|
log.Infof("Resuming VM ...")
|
||||||
|
|
@ -569,7 +579,7 @@ func (d *Driver) Start() error {
|
||||||
// We have to be sure the adapter is updated before starting the VM
|
// We have to be sure the adapter is updated before starting the VM
|
||||||
d.sleeper.Sleep(5 * time.Second)
|
d.sleeper.Sleep(5 * time.Second)
|
||||||
|
|
||||||
if err := d.vbm("startvm", d.MachineName, "--type", "headless"); err != nil {
|
if err := d.vbm("startvm", d.MachineName, "--type", d.UIType); err != nil {
|
||||||
return fmt.Errorf("Unable to start the VM: %s", err)
|
return fmt.Errorf("Unable to start the VM: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -584,7 +594,7 @@ func (d *Driver) Stop() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if currentState == state.Paused {
|
if currentState == state.Paused {
|
||||||
if err := d.vbm("controlvm", d.MachineName, "resume"); err != nil { // , "--type", "headless"
|
if err := d.vbm("controlvm", d.MachineName, "resume"); err != nil { // , "--type", d.UIType
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Infof("Resuming VM ...")
|
log.Infof("Resuming VM ...")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue