remotevm

package
v0.0.0-...-2db35d6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// QEMUExecutableName is the X86(64-bit) QEMU program's executable name, without the prefix path.
	QEMUExecutableName = "qemu-system-x86_64"
	// QMPCommandResponseTimeoutSec is the number of seconds after which an outstanding QMP command is aborted due to timeout.
	QMPCommandResponseTimeoutSec = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type VM

type VM struct {
	NumCPU    int   // NumCPU is the number of CPU cores allocated to emulator
	MemSizeMB int64 // MemSizeMB is the amount of memory allocated to emulator
	QMPPort   int   // QMPPort is the TCP port number used for interacting with emulator
	// contains filtered or unexported fields
}

VM launches a virtual machine of lightweight Linux distribution via KVM (preferred) or QEMU (fall-back) and offers remote mouse and keyboard control, as well as screenshot capability.

func (*VM) ClickMouse

func (vm *VM) ClickMouse(leftButton bool) error

ClickMouse makes a 100 milliseconds long mouse click with either the left button or right mouse button.

func (*VM) DoubleClickMouse

func (vm *VM) DoubleClickMouse(leftButton bool) error

DoubleClickMouse makes a double click with either left or right mouse button in 200 milliseconds.

func (*VM) DownloadISO

func (vm *VM) DownloadISO(isoURL string, destPath string) error

DownloadISO downloads an ISO file from the input URL and saves it in a file. There is a hard limit of 15 minutes for the download operation to complete.

func (*VM) GetDebugOutput

func (vm *VM) GetDebugOutput() string

GetDebugOutput returns the QEMU/KVM emulator output along with recent QMP command and responses.

func (*VM) HoldMouse

func (vm *VM) HoldMouse(leftButton, holdDown bool) error

HoldMouse holds down or releases the left or right mouse button.

func (*VM) Initialise

func (vm *VM) Initialise() error

Initialise internal variables.

func (*VM) Kill

func (vm *VM) Kill()

Kill the emulator.

func (*VM) MoveMouse

func (vm *VM) MoveMouse(x, y int) error

MoveMouse moves the mouse cursor to the input location. Prior to calling this function the caller should have quite recently taken a screenshot of the VM, because the resolution of the VM screen is internally memorised to help with calculating mouse movement coordinates.

func (*VM) PressKeysOneByOne

func (vm *VM) PressKeysOneByOne(qKeyCodes ...string) error

PressKeysOneByOne pushes and releases the keys given in the input sequence, one key at a time.

func (*VM) PressKeysSimultaneously

func (vm *VM) PressKeysSimultaneously(qKeyCodes ...string) error

PressKeysSimultaneously pushes and releases the keys given in the input sequence all at once. Keys are identified by "QCode", which is a string that indicates key's name. E.g. in order to type the @ symbol, first configure the OS running inside VM to use the US keyboard layout, and then send codes ["shift", "2"].

QEMU developers have made it very challenging to find the comprehensive list of QCodes, but a partial list can be found at: https://en.wikibooks.org/wiki/QEMU/Monitor#sendkey_keys

func (*VM) Start

func (vm *VM) Start(isoFilePath string) error

Start the virtual machine. The function returns to the caller as soon as QEMU/KVM becomes ready to accept commands. The emulator started is subjected to a time-out of 24-hours, after which it will be killed forcibly.

func (*VM) TakeScreenshot

func (vm *VM) TakeScreenshot(outputFileName string) error

TakeScreenshot takes a screenshot of the emulator video display, the screenshot image format is JPEG. The function also updates the screen total resolution tracked internally for calculating mouse movement coordinates.

Jump to

Keyboard shortcuts

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