qga

package
v0.0.0-...-6410feb Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QGA_DEFAULT_READ_TIMEOUT_SECOND int = 5
	QGA_EXEC_DEFAULT_WAIT_TIMEOUT   int = 5
)

Variables

View Source
var NETWORK_RESTRT_SCRIPT = `` /* 572-byte string literal not displayed */

Functions

func ParseIPAndSubnet

func ParseIPAndSubnet(input string) (string, string, error)

Types

type GuestCommand

type GuestCommand struct {
	Enabled bool   `json:"enabled"`
	Name    string `json:"name"`

	// whether command returns a response on success (since 1.7)
	SuccessResp bool `json:"success-response"`
}

type GuestExec

type GuestExec struct {
	Pid int
}

type GuestExecStatus

type GuestExecStatus struct {
	Exited       bool
	Exitcode     int
	Signal       int
	OutData      string `json:"out-data"`
	ErrData      string `json:"err-data"`
	OutTruncated bool   `json:"out-truncated"`
	ErrTruncated bool   `json:"err-truncated"`
}

## # @GuestExecStatus: # # @exited: true if process has already terminated. # @exitcode: process exit code if it was normally terminated. # @signal: signal number (linux) or unhandled exception code # (windows) if the process was abnormally terminated. # @out-data: base64-encoded stdout of the process # @err-data: base64-encoded stderr of the process # Note: @out-data and @err-data are present only # if 'capture-output' was specified for 'guest-exec' # @out-truncated: true if stdout was not fully captured # due to size limitation. # @err-truncated: true if stderr was not fully captured # due to size limitation. # # Since: 2.5 ## { 'struct': 'GuestExecStatus',

'data': { 'exited': 'bool', '*exitcode': 'int', '*signal': 'int',
          '*out-data': 'str', '*err-data': 'str',
          '*out-truncated': 'bool', '*err-truncated': 'bool' }}

type GuestFileRead

type GuestFileRead struct {
	Count  int    `json:"count"`
	BufB64 string `json:"buf-b64"`
	Eof    bool   `json:"eof"`
}

type GuestFileWrite

type GuestFileWrite struct {
	Count int  `json:"count"`
	Eof   bool `json:"eof"`
}

type GuestInfo

type GuestInfo struct {
	Version           string         `json:"version"`
	SupportedCommands []GuestCommand `json:"supported_commands"`
}

type GuestOsInfo

type GuestOsInfo struct {
	Id            string `json:"id"`
	KernelRelease string `json:"kernel-release"`
	KernelVersion string `json:"kernel-version"`
	Machine       string `json:"machine"`
	Name          string `json:"name"`
	PrettyName    string `json:"pretty-name"`
	Version       string `json:"version"`
	VersionId     string `json:"version-id"`
}

type QemuGuestAgent

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

func NewQemuGuestAgent

func NewQemuGuestAgent(id, qgaSocketPath string) (*QemuGuestAgent, error)

func (*QemuGuestAgent) Close

func (qga *QemuGuestAgent) Close() error

func (*QemuGuestAgent) CommandWithTimeout

func (qga *QemuGuestAgent) CommandWithTimeout(
	cmdPath string, args, env []string, inputData string, captureOutput bool,
	timeoutSecond int,
) (int, string, string, error)

func (*QemuGuestAgent) FileGetContents

func (qga *QemuGuestAgent) FileGetContents(path string) (string, error)

func (*QemuGuestAgent) FilePutContents

func (qga *QemuGuestAgent) FilePutContents(path, content string, modAppend bool) error

func (*QemuGuestAgent) GuestExecCommand

func (qga *QemuGuestAgent) GuestExecCommand(
	cmdPath string, args, env []string, inputData string, captureOutput bool,
) (*GuestExec, error)

func (*QemuGuestAgent) GuestExecStatusCommand

func (qga *QemuGuestAgent) GuestExecStatusCommand(pid int) (*GuestExecStatus, error)

func (*QemuGuestAgent) GuestInfo

func (qga *QemuGuestAgent) GuestInfo() (*GuestInfo, error)

func (*QemuGuestAgent) GuestInfoTask

func (qga *QemuGuestAgent) GuestInfoTask() ([]byte, error)

func (*QemuGuestAgent) GuestPing

func (qga *QemuGuestAgent) GuestPing(timeout int) error

func (*QemuGuestAgent) GuestSetUserPassword

func (qga *QemuGuestAgent) GuestSetUserPassword(username, password string, crypted bool) error

# @username: the user account whose password to change # @password: the new password entry string, base64 encoded # @crypted: true if password is already crypt()d, false if raw # # If the @crypted flag is true, it is the caller's responsibility # to ensure the correct crypt() encryption scheme is used. This # command does not attempt to interpret or report on the encryption # scheme. Refer to the documentation of the guest operating system # in question to determine what is supported. # # Not all guest operating systems will support use of the # @crypted flag, as they may require the clear-text password # # The @password parameter must always be base64 encoded before # transmission, even if already crypt()d, to ensure it is 8-bit # safe when passed as JSON. # # Returns: Nothing on success. # # Since: 2.3

func (*QemuGuestAgent) QgaAddFileExec

func (qga *QemuGuestAgent) QgaAddFileExec(filePath string) error

func (*QemuGuestAgent) QgaCommand

func (qga *QemuGuestAgent) QgaCommand(cmd *monitor.Command) ([]byte, error)

func (*QemuGuestAgent) QgaFileClose

func (qga *QemuGuestAgent) QgaFileClose(fileNum int) error

func (*QemuGuestAgent) QgaFileOpen

func (qga *QemuGuestAgent) QgaFileOpen(path, mode string) (int, error)

func (*QemuGuestAgent) QgaFileRead

func (qga *QemuGuestAgent) QgaFileRead(fileNum, readCount int) ([]byte, bool, error)

func (*QemuGuestAgent) QgaFileWrite

func (qga *QemuGuestAgent) QgaFileWrite(fileNum int, content string) (int, bool, error)

func (*QemuGuestAgent) QgaGetNetwork

func (qga *QemuGuestAgent) QgaGetNetwork() ([]byte, error)

func (*QemuGuestAgent) QgaGuestGetOsInfo

func (qga *QemuGuestAgent) QgaGuestGetOsInfo() (*GuestOsInfo, error)

func (*QemuGuestAgent) QgaRestartLinuxNetwork

func (qga *QemuGuestAgent) QgaRestartLinuxNetwork(qgaNetMod *monitor.NetworkModify) error

func (*QemuGuestAgent) QgaSetNetwork

func (qga *QemuGuestAgent) QgaSetNetwork(qgaNetMod *monitor.NetworkModify, guestNics []*types.SServerNic) error

func (*QemuGuestAgent) QgaSetWindowsNetwork

func (qga *QemuGuestAgent) QgaSetWindowsNetwork(qgaNetMod *monitor.NetworkModify) error

func (*QemuGuestAgent) ResetTimeout

func (qga *QemuGuestAgent) ResetTimeout()

func (*QemuGuestAgent) SetTimeout

func (qga *QemuGuestAgent) SetTimeout(timeout int)

func (*QemuGuestAgent) TryLock

func (qga *QemuGuestAgent) TryLock() bool

Lock before execute qemu guest agent commands

func (*QemuGuestAgent) Unlock

func (qga *QemuGuestAgent) Unlock()

Unlock after execute qemu guest agent commands

type QemuGuestAgentPartition

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

func NewQGAPartition

func NewQGAPartition(agent *QemuGuestAgent) *QemuGuestAgentPartition

func (*QemuGuestAgentPartition) CheckOrAddUser

func (p *QemuGuestAgentPartition) CheckOrAddUser(user, homeDir string, isSys bool) (string, error)

func (*QemuGuestAgentPartition) Chmod

func (p *QemuGuestAgentPartition) Chmod(sPath string, mode uint32, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Chown

func (p *QemuGuestAgentPartition) Chown(sPath string, uid, gid int, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Cleandir

func (p *QemuGuestAgentPartition) Cleandir(dir string, keepdir, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Exists

func (p *QemuGuestAgentPartition) Exists(sPath string, caseInsensitive bool) bool

func (*QemuGuestAgentPartition) FileGetContents

func (p *QemuGuestAgentPartition) FileGetContents(sPath string, caseInsensitive bool) ([]byte, error)

func (*QemuGuestAgentPartition) FileGetContentsByPath

func (p *QemuGuestAgentPartition) FileGetContentsByPath(sPath string) ([]byte, error)

func (*QemuGuestAgentPartition) FilePutContents

func (p *QemuGuestAgentPartition) FilePutContents(sPath, content string, modAppend, caseInsensitive bool) error

func (*QemuGuestAgentPartition) GenerateSshHostKeys

func (*QemuGuestAgentPartition) GenerateSshHostKeys() error

func (*QemuGuestAgentPartition) GetLocalPath

func (p *QemuGuestAgentPartition) GetLocalPath(sPath string, caseInsensitive bool) string

func (*QemuGuestAgentPartition) GetMountPath

func (*QemuGuestAgentPartition) GetMountPath() string

func (*QemuGuestAgentPartition) GetPartDev

func (*QemuGuestAgentPartition) GetPartDev() string

func (*QemuGuestAgentPartition) GetPhysicalPartitionType

func (*QemuGuestAgentPartition) GetPhysicalPartitionType() string

func (*QemuGuestAgentPartition) IsMounted

func (*QemuGuestAgentPartition) IsMounted() bool

func (*QemuGuestAgentPartition) IsReadonly

func (*QemuGuestAgentPartition) IsReadonly() bool

func (*QemuGuestAgentPartition) ListDir

func (p *QemuGuestAgentPartition) ListDir(sPath string, caseInsensitive bool) []string

func (*QemuGuestAgentPartition) Mkdir

func (p *QemuGuestAgentPartition) Mkdir(sPath string, mode int, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Mount

func (*QemuGuestAgentPartition) Mount() bool

func (*QemuGuestAgentPartition) MountPartReadOnly

func (*QemuGuestAgentPartition) MountPartReadOnly() bool

func (*QemuGuestAgentPartition) Passwd

func (p *QemuGuestAgentPartition) Passwd(account, password string, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Remove

func (p *QemuGuestAgentPartition) Remove(sPath string, caseInsensitive bool)

func (*QemuGuestAgentPartition) Stat

func (p *QemuGuestAgentPartition) Stat(sPath string, caseInsensitive bool) os.FileInfo

func (*QemuGuestAgentPartition) SupportSerialPorts

func (*QemuGuestAgentPartition) SupportSerialPorts() bool
func (p *QemuGuestAgentPartition) Symlink(src, dst string, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Umount

func (*QemuGuestAgentPartition) Umount() error

func (*QemuGuestAgentPartition) Zerofiles

func (*QemuGuestAgentPartition) Zerofiles(dir string, caseInsensitive bool) error

func (*QemuGuestAgentPartition) Zerofree

func (*QemuGuestAgentPartition) Zerofree()

type TryMutex

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

func (*TryMutex) TryLock

func (m *TryMutex) TryLock() bool

func (*TryMutex) Unlock

func (m *TryMutex) Unlock()

Jump to

Keyboard shortcuts

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