Class QemuConnector

All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager
Direct Known Subclasses:
AgentConnector, QemuMonitor

public abstract class QemuConnector extends Component
A component that handles the communication with QEMU over a socket.

Derived classes should log the messages exchanged on the socket if the log level is set to fine.

  • Field Details

    • mapper

      protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
  • Constructor Details

    • QemuConnector

      public QemuConnector(Channel componentChannel) throws IOException
      Instantiates a new QEMU connector.
      Parameters:
      componentChannel - the component channel
      Throws:
      IOException - Signals that an I/O exception has occurred.
  • Method Details

    • configure

      void configure(Path socketPath)
      As the initial configuration of this component depends on the configuration of the Runner, it doesn’t have a handler for the ConfigurationUpdate event.

      The values are forwarded from the Runner instead.

      Parameters:
      socketPath - the socket path
    • onStart

      @Handler public void onStart(Start event) throws IOException
      Note the runner’s event processor and delete the socket.
      Parameters:
      event - the event
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • rep

      protected EventPipeline rep()
      Return the runner’s event pipeline.
      Returns:
      the event pipeline
    • onFileChanged

      @Handler public void onFileChanged(FileChanged event)
      Watch for the creation of the swtpm socket and start the qemu process if it has been created.
      Parameters:
      event - the event
    • onClientConnected

      Check if this is from opening the agent socket and if true, save the socket in the context and associate the channel with the context.
      Parameters:
      event - the event
      channel - the channel
    • qemuChannel

      Return the QEMU channel if the connection has been established.
      Returns:
      the socket IO channel
    • writer

      protected Optional<Writer> writer()
      Return the Writer for the connection if the connection has been established.
      Returns:
      the optional
    • sendCommand

      protected boolean sendCommand(String command) throws IOException
      Send the given command to QEMU.

      A newline is appended to the command automatically.

      Parameters:
      command - the command
      Returns:
      true, if successful
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • socketConnected

      protected void socketConnected()
      Called when the connector has been connected to the socket.
    • onConnectError

      @Handler public void onConnectError(ConnectError event, SocketIOChannel channel)
      Called when a connection attempt fails.
      Parameters:
      event - the event
      channel - the channel
    • onInput

      @Handler public void onInput(Input<?> event, SocketIOChannel channel)
      Handle data from the socket connection.
      Parameters:
      event - the event
      channel - the channel
    • processInput

      protected abstract void processInput(String line) throws IOException
      Process agent input.
      Parameters:
      line - the line
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • onClosed

      @Handler public void onClosed(Closed<?> event, SocketIOChannel channel)
      On closed.
      Parameters:
      event - the event
      channel - the channel