QMP: add server mode to QEMUMonitorProtocol
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Wed, 25 May 2011 18:48:01 +0000 (19:48 +0100)
committerLuiz Capitulino <lcapitulino@redhat.com>
Wed, 1 Jun 2011 14:43:18 +0000 (11:43 -0300)
commit8c9276792b7b5c85df39f1352a28e02e90ea041f
tree6c97f37b0f3262d6c32d0074699ce2651399cc10
parentb366b77edef34536dbb9f89b5b4c203aa0ea57ea
QMP: add server mode to QEMUMonitorProtocol

QEMU supports socket chardevs that establish connections like a server
or a client.  The QEMUMonitorProtocol class only supports connecting as
a client.  It is not possible to connect race-free when launching QEMU
since trying to connect before QEMU has bound and is listening on the
socket results in failure.

Add the QEMUMonitorProtocol(server=True) argument to bind and listen on
the socket.  The QEMU process can then be launched and connects to the
already existing QMP socket without a race condition:

  qmp = qmp.QEMUMonitorProtocol(monitor_path, server=True)
  popen = subprocess.Popen(args)
  qmp.accept()

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
QMP/qmp.py