qemu-init

A virtual machine manager to make life with qemu more comfortable

User Tools

Site Tools


Internals

Monitor redirection

qemu-init uses the qemu monitor to communicate with the registered guests. This will be done through monitor redirection with 2 types of sockets: tcp sockets and unix sockets. The behavior of qemu with (at least) socket redirection makes is necessary to have 2 channels:

  • interactive channel - stay connected until the user actively dissconnects
  • command channel - send a single command to the monitor and disconnect
Socket and channel combinations
Type Channel Status
unix socket interactive always set
command always set
tcp socket interactive always set
command optional

qemu monitor

The qemu monitor is important cause qemu-init requires it for communication. It will be started by default, redirected via tcp at localhost. The first port number is defined in  /etc/qemu/monitor.conf  (default: 30320). For each virtual machine started by  qemu-init  the port will be increased by 1. Make sure that no other programs uses a port inside the range required by  qemu-init . If no valid port could be determined, the monitor will be disabled silently.

The qemu monitor will be bound to  127.0.0.1  localhost (IPv4) by default always.  qemu-init  checks for address  ::1  (IPv6) too. If it is available the qemu monitor will be bound to ::1 additional.

FIXME It is a requirement that the monitor could be accessed via a tcp socket. The stop function of  qemu-init  uses a socket to shutdown virtual machines clean. See Stop a VM below for details.

Ports

There are multiple ports used by the monitor. The first one is MONPORT (monitor port), calculated like described above. The MONPORT is used by  qemu-mon  to establish a permanent connection. The second one is the CTLPORT (control port). Its number is MONPORT+100. The CTLPORT is used by  qemu-cmd . Both tools checks for the proper IP version of the socket. The background to have multiple ports is, that there is only one connection to a socket possible at the same time.