Documentation ¶
Index ¶
- Constants
- type VM
- func (vm *VM) ClickMouse(leftButton bool) error
- func (vm *VM) DoubleClickMouse(leftButton bool) error
- func (vm *VM) DownloadISO(isoURL string, destPath string) error
- func (vm *VM) GetDebugOutput() string
- func (vm *VM) HoldMouse(leftButton, holdDown bool) error
- func (vm *VM) Initialise() error
- func (vm *VM) Kill()
- func (vm *VM) MoveMouse(x, y int) error
- func (vm *VM) PressKeysOneByOne(qKeyCodes ...string) error
- func (vm *VM) PressKeysSimultaneously(qKeyCodes ...string) error
- func (vm *VM) Start(isoFilePath string) error
- func (vm *VM) TakeScreenshot(outputFileName string) error
Constants ¶
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 ¶
ClickMouse makes a 100 milliseconds long mouse click with either the left button or right mouse button.
func (*VM) DoubleClickMouse ¶
DoubleClickMouse makes a double click with either left or right mouse button in 200 milliseconds.
func (*VM) DownloadISO ¶
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 ¶
GetDebugOutput returns the QEMU/KVM emulator output along with recent QMP command and responses.
func (*VM) MoveMouse ¶
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 ¶
PressKeysOneByOne pushes and releases the keys given in the input sequence, one key at a time.
func (*VM) PressKeysSimultaneously ¶
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 ¶
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 ¶
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.