qemu.machine.console_socket module

QEMU Console Socket Module:

This python module implements a ConsoleSocket object, which can drain a socket and optionally dump the bytes to file.

class qemu.machine.console_socket.ConsoleSocket(address: str, file: Optional[str] = None, drain: bool = False)[source]

Bases: socket.socket

ConsoleSocket represents a socket attached to a char device.

Optionally (if drain==True), drains the socket and places the bytes into an in memory buffer for later processing.

Optionally a file path can be passed in and we will also dump the characters to this file for debugging purposes.

close()None[source]

Close the base object and wait for the thread to terminate

recv(bufsize: int = 1, flags: int = 0)bytes[source]

Return chars from in memory buffer. Maintains the same API as socket.socket.recv.

setblocking(value: bool)None[source]

When not draining we pass thru to the socket, since when draining we control socket blocking.

settimeout(value: Optional[float])None[source]

When not draining we pass thru to the socket, since when draining we control the timeout.