Help us shape the future of Go! Take the 2026 Go Developer Survey

vbox

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

README

VirtualBox implement tips

Volume

  • Use the vdi created by VboxManage if the user do not specific the volume directory, such as

    Create a 32GB “dynamic” disk:

    VBoxManage createhd --filename volume.vdi --size 32768
    

    And attach it to the VM:

     VBoxManage storageattach $VM --storagectl "SATA Controller" \
                --port 0 --device 0 --type hdd --medium volume.vdi
    
    Attention:
    There is no any interface to create a new vdi in **go-virtualbox** library, need to patch it.
    
  • Use the shared folder to attach a volume if the user specific the volume directory, such as

    VBoxManage sharedfolder add add <uuid|vmname> --name <name> --hostpath <hostpath>
    

Image

  • VirtualBox boot from a iso image, which includes kernel and initrd.img
  • Not sure the boot time, we may focus the boot successfully, not performance

Serial Port

  • Use ttyS0 and ttyS1 to communicate between host and guest via socket, since VirtualBox only support two serial ports
  • Set the serial port to use Host Pipe of VirtualBox

The following other hardware settings are available through VBoxManage modifyvm:

--uart<1-N> off|<I/O base> :
With this option you can configure virtual serial ports for the VM.
--uartmode<1-N> arg:
This setting controls how VirtualBox connects a given virtual serial port (previously configured with the --uartX setting, see above) to the host on which the virtual machine is running. As described in detail in Section 3.9, “Serial ports”, for each such port, you can specify <arg> as one of the following options:
* disconnected: Even though the serial port is shown to the guest, it has no "other end" -- like a real COM port without a cable.
* server <pipename>: On a Windows host, this tells VirtualBox to create a named pipe on the host named <pipename> and connect the virtual serial device to it. Note that Windows requires that the name of a named pipe begin with \\.\pipe\.
On a Linux host, instead of a named pipe, a local domain socket is used.
* client <pipename>: This operates just like server ..., except that the pipe (or local domain socket) is not created by VirtualBox, but assumed to exist already.
* <devicename>: If, instead of the above, the device name of a physical hardware serial port of the host is specified, the virtual serial port is connected to that hardware port. On a Windows host, the device name will be a COM port such as COM1; on a Linux host, the device name will look like /dev/ttyS0. This allows you to "wire" a real serial port to a virtual machine.
Attention:
This interface is not implemented in go-virtualbox library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReleasePortMaps

func ReleasePortMaps(vmId string, containerip string, maps []pod.UserContainerPort) error

func SetupPortMaps

func SetupPortMaps(vmId string, containerip string, maps []pod.UserContainerPort) error

Types

type VBoxContext

type VBoxContext struct {
	Driver  *VBoxDriver
	Machine *virtualbox.Machine
	// contains filtered or unexported fields
}

func (*VBoxContext) AddDir

func (vc *VBoxContext) AddDir(name, path string, readonly bool) error

For shared directory between host and guest OS

func (*VBoxContext) AddDisk

func (vc *VBoxContext) AddDisk(ctx *hypervisor.VmContext, sourceType string, blockInfo *hypervisor.BlockDescriptor)

func (*VBoxContext) AddMem

func (vc *VBoxContext) AddMem(ctx *hypervisor.VmContext, slot, size int, result chan<- error)

func (*VBoxContext) AddNic

func (vc *VBoxContext) AddNic(ctx *hypervisor.VmContext, host *hypervisor.HostNicInfo, guest *hypervisor.GuestNicInfo, result chan<- hypervisor.VmEvent)

func (*VBoxContext) AllocateNetwork

func (vc *VBoxContext) AllocateNetwork(vmId, requestedIP string,
	maps []pod.UserContainerPort) (*network.Settings, error)

func (*VBoxContext) Associate

func (vc *VBoxContext) Associate(ctx *hypervisor.VmContext)

func (*VBoxContext) Close

func (vc *VBoxContext) Close()

func (*VBoxContext) ConfigureNetwork

func (vc *VBoxContext) ConfigureNetwork(vmId,
	requestedIP string,
	maps []pod.UserContainerPort,
	config pod.UserInterface) (*network.Settings, error)

func (*VBoxContext) CreateVm

func (vc *VBoxContext) CreateVm(name, baseDir, hyperSockFile, ttySockFile string) error

Prepare the conditions for the vm startup * Create VM machine * Create serial port

func (*VBoxContext) Dump

func (vc *VBoxContext) Dump() (map[string]interface{}, error)

func (*VBoxContext) InitVM

func (vc *VBoxContext) InitVM(ctx *hypervisor.VmContext) error

func (*VBoxContext) Kill

func (vc *VBoxContext) Kill(ctx *hypervisor.VmContext)

func (*VBoxContext) Launch

func (vc *VBoxContext) Launch(ctx *hypervisor.VmContext)

Create VM and start it

func (*VBoxContext) LazyAddDisk

func (vc *VBoxContext) LazyAddDisk(ctx *hypervisor.VmContext, name, sourceType, filename, format string, id int)

func (*VBoxContext) LazyAddNic

func (vc *VBoxContext) LazyAddNic(ctx *hypervisor.VmContext, host *hypervisor.HostNicInfo, guest *hypervisor.GuestNicInfo)

func (*VBoxContext) LazyLaunch

func (vc *VBoxContext) LazyLaunch(ctx *hypervisor.VmContext)

func (*VBoxContext) Pause

func (vc *VBoxContext) Pause(ctx *hypervisor.VmContext, pause bool, result chan<- error)

func (*VBoxContext) ReleaseNetwork

func (vc *VBoxContext) ReleaseNetwork(vmId, releasedIP string, maps []pod.UserContainerPort,
	file *os.File) error

Release an interface for a select ip

func (*VBoxContext) RemoveDir

func (vc *VBoxContext) RemoveDir(name string) error

func (*VBoxContext) RemoveDisk

func (vc *VBoxContext) RemoveDisk(ctx *hypervisor.VmContext, blockInfo *hypervisor.BlockDescriptor, callback hypervisor.VmEvent)

func (*VBoxContext) RemoveNic

func (vc *VBoxContext) RemoveNic(ctx *hypervisor.VmContext, n *hypervisor.InterfaceCreated, callback hypervisor.VmEvent)

func (*VBoxContext) Save

func (vc *VBoxContext) Save(ctx *hypervisor.VmContext, path string, result chan<- error)

func (*VBoxContext) SetCpus

func (vc *VBoxContext) SetCpus(ctx *hypervisor.VmContext, cpus int, result chan<- error)

func (*VBoxContext) Shutdown

func (vc *VBoxContext) Shutdown(ctx *hypervisor.VmContext)

func (*VBoxContext) Stats

func (vc *VBoxContext) Stats(ctx *hypervisor.VmContext) (*types.PodStats, error)

type VBoxDriver

type VBoxDriver struct {
	Machines map[string]*hypervisor.VmContext
}

implement the hypervisor.HypervisorDriver interface

func InitDriver

func InitDriver() *VBoxDriver

func (*VBoxDriver) BuildinNetwork

func (vd *VBoxDriver) BuildinNetwork() bool

func (*VBoxDriver) InitContext

func (vd *VBoxDriver) InitContext(homeDir string) hypervisor.DriverContext

func (*VBoxDriver) InitNetwork

func (vd *VBoxDriver) InitNetwork(bIface, bIP string, disableIptables bool) error

func (*VBoxDriver) LoadContext

func (vd *VBoxDriver) LoadContext(persisted map[string]interface{}) (hypervisor.DriverContext, error)

func (*VBoxDriver) SupportLazyMode

func (vc *VBoxDriver) SupportLazyMode() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL