qemu

package
v0.0.0-...-88bc37c Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MachineState = map[string]State{
	"STOPPED":      STOPPED,
	"STARTING":     STARTING,
	"RUNNING":      RUNNING,
	"STOPPING":     STOPPING,
	"REBOOTING":    REBOOTING,
	"SHUTTINGDOWN": SHUTTINGDOWN,
	"TERMINATING":  TERMINATING,
	"FAILED":       FAILED,
}

Functions

func Base64toUTF8

func Base64toUTF8(str string) string

Types

type BridgeType

type BridgeType int
const (
	None BridgeType = iota // 0
	Linux
	OVS
)

func (BridgeType) String

func (t BridgeType) String() string

type CommandType

type CommandType int
const (
	GuestExec CommandType = iota // 0
	GuestExecStatus
	GuestPing
)

TODO: add more types?

type Device

type Device struct {
	DeviceType string
	Params     *DeviceParams
}

func NewDevice

func NewDevice(deviceType DeviceType) *Device

func (*Device) AddDriver

func (d *Device) AddDriver(driverType string) error

func (*Device) AddDriverOption

func (d *Device) AddDriverOption(key string, value string) error

func (*Device) BuildArg

func (d *Device) BuildArg() []string

func (*Device) LinkToGuestDevice

func (d *Device) LinkToGuestDevice(id string, guestDevice *Device)

type DeviceParams

type DeviceParams struct {
	Driver string
	// Wrap the key value pair here because maps are not sorted
	Options []DriverOption
}

type DeviceType

type DeviceType int

-device virtio-serial -chardev socket,path=/tmp/foo,server,nowait,id=foo -device virtserialport,chardev=foo,name=org.fedoraproject.port.0

const (
	DevType DeviceType = iota // 0
	NetType
	CharType
)

func (DeviceType) String

func (t DeviceType) String() string

type Drive

type Drive struct {
	Image *Image
	If    string
}

type DriverOption

type DriverOption struct {
	// contains filtered or unexported fields
}

type ExecRequest

type ExecRequest struct {
	Path            string   `json:"path,omitempty"`
	Args            []string `json:"arg,omitempty"`
	EnvironmentVars []string `json:"env,omitempty"`
	CaptureOutput   bool     `json:"capture-output,omitempty"`
}

type ExecResponse

type ExecResponse struct {
	Pid int `json:"pid,omitempty"`
}

type ExecStatusRequest

type ExecStatusRequest struct {
	Pid int `json:"pid,omitempty"`
}

type ExecStatusResponse

type ExecStatusResponse struct {
	Exited      bool   `json:"exited,omitempty"`
	Signal      int    `json:"signal,omitempty"`
	Exitcode    int    `json:"exitcode,omitempty"`
	Stdout      string `json:"out-data,omitempty"`
	Stderr      string `json:"err-data,omitempty"`
	TruncStdOut string `json:"out-truncated,omitempty"`
	TruncStdErr string `json:"err-truncated,omitempty"`
}

type GuestAgentRequest

type GuestAgentRequest struct {
	Command   string      `json:"execute"`
	Arguments interface{} `json:"arguments,omitempty"`
}

func NewGuestAgentExecRequest

func NewGuestAgentExecRequest(cmd []string, output bool) *GuestAgentRequest

func NewGuestAgentExecStatusRequest

func NewGuestAgentExecStatusRequest(pid int) *GuestAgentRequest

func NewGuestAgentRequest

func NewGuestAgentRequest(cmdType CommandType) *GuestAgentRequest

func (*GuestAgentRequest) SendRequest

func (c *GuestAgentRequest) SendRequest(conn net.Conn, response *GuestAgentResponse) error

type GuestAgentResponse

type GuestAgentResponse struct {
	Return interface{} `json:"return"`
}

type Image

type Image struct {
	Path   string
	Format string
	Size   int
	// contains filtered or unexported fields
}

func NewImage

func NewImage(path string, format string) *Image

func (*Image) CreateImage

func (i *Image) CreateImage() error

func (*Image) SetBaseImage

func (i *Image) SetBaseImage(baseImage string) error

func (*Image) SetSize

func (i *Image) SetSize(size int) error

type Machine

type Machine struct {
	State             State
	Cores             int
	Memory            uint64
	Name              string
	Display           string
	Vnc               string
	MonitorSocketPath string
	SerialSocketPath  string
	AgentSocketPath   string
	Devices           []*Device
	Pidfile           string
	Nics              []Nic
	Drives            map[string]Drive
	Process           *os.Process
	Kvm               bool
}

func NewMachine

func NewMachine(cores int, mem uint64) *Machine

func (*Machine) AddDevice

func (m *Machine) AddDevice(device *Device)

func (*Machine) AddNICs

func (m *Machine) AddNICs(nics []Nic) []*Device

func (*Machine) HavePrompt

func (m *Machine) HavePrompt() bool

func (*Machine) MonitorCommand

func (m *Machine) MonitorCommand(cmd string) error

func (*Machine) Reboot

func (m *Machine) Reboot() error

func (*Machine) ScheduleState

func (m *Machine) ScheduleState(nextState State, timeout time.Duration, evaluation func() bool) error

since machine struct does not get saved in memory for each instance there may not be any points in scheduling states as they are not stored anywhere

func (*Machine) Start

func (m *Machine) Start(startCmd string) error

func (*Machine) Stop

func (m *Machine) Stop() error

func (*Machine) WaitForPrompt

func (m *Machine) WaitForPrompt() bool

type Nic

type Nic struct {
	IfName       string
	Index        string
	Ipv4Addr     string
	MacAddr      string
	Bridge       string
	BridgeHelper string
	Type         string
	Ipv4Gateway  string
}

type QEMUHypervisorDriver

type QEMUHypervisorDriver struct {
	hypervisor.Base
	// contains filtered or unexported fields
}

func (*QEMUHypervisorDriver) CreateInstance

func (d *QEMUHypervisorDriver) CreateInstance() error

func (*QEMUHypervisorDriver) DestroyInstance

func (d *QEMUHypervisorDriver) DestroyInstance() error

func (*QEMUHypervisorDriver) InstanceConsole

func (d *QEMUHypervisorDriver) InstanceConsole() hypervisor.Console

func (*QEMUHypervisorDriver) MetadataDriveDatamap

func (d *QEMUHypervisorDriver) MetadataDriveDatamap() map[string]interface{}

func (*QEMUHypervisorDriver) MetadataDrivePath

func (d *QEMUHypervisorDriver) MetadataDrivePath() string

func (QEMUHypervisorDriver) RebootInstance

func (d QEMUHypervisorDriver) RebootInstance() error

func (*QEMUHypervisorDriver) Recover

func (d *QEMUHypervisorDriver) Recover(instanceState model.InstanceState) error

func (*QEMUHypervisorDriver) StartInstance

func (d *QEMUHypervisorDriver) StartInstance() error

func (*QEMUHypervisorDriver) StopInstance

func (d *QEMUHypervisorDriver) StopInstance() error

type QEMUHypervisorProvider

type QEMUHypervisorProvider struct {
}

func (*QEMUHypervisorProvider) CreateDriver

func (*QEMUHypervisorProvider) LoadConfig

func (p *QEMUHypervisorProvider) LoadConfig(sub *viper.Viper) error

func (*QEMUHypervisorProvider) Name

func (p *QEMUHypervisorProvider) Name() string

type State

type State int
const (
	STOPPED State = iota // 0
	STARTING
	RUNNING
	STOPPING
	REBOOTING
	SHUTTINGDOWN
	TERMINATING
	FAILED
)

Jump to

Keyboard shortcuts

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