Revision bb439d22 lib/hypervisor/hv_kvm/monitor.py

b/lib/hypervisor/hv_kvm/monitor.py
183 183
  _EXECUTE_KEY = "execute"
184 184
  _ARGUMENTS_KEY = "arguments"
185 185
  _CAPABILITIES_COMMAND = "qmp_capabilities"
186
  _QUERY_COMMANDS = "query-commands"
186 187
  _MESSAGE_END_TOKEN = "\r\n"
187 188

  
188 189
  def __init__(self, monitor_filename):
189 190
    super(QmpConnection, self).__init__(monitor_filename)
190 191
    self._buf = ""
192
    self.supported_commands = frozenset()
191 193

  
192 194
  def connect(self):
193 195
    """Connects to the QMP monitor.
......
216 218
    # command, or else no command will be executable.
217 219
    # (As per the QEMU Protocol Specification 0.1 - section 4)
218 220
    self.Execute(self._CAPABILITIES_COMMAND)
221
    self.supported_commands = self._GetSupportedCommands()
219 222

  
220 223
  def _ParseMessage(self, buf):
221 224
    """Extract and parse a QMP message from the given buffer.
......
300 303
      raise errors.HypervisorError("Unable to send data from KVM using the"
301 304
                                   " QMP protocol: %s" % err)
302 305

  
306
  def _GetSupportedCommands(self):
307
    """Update the list of supported commands.
308

  
309
    """
310
    result = self.Execute(self._QUERY_COMMANDS)
311
    return frozenset(com["name"] for com in result[self._RETURN_KEY])
312

  
303 313
  def Execute(self, command, arguments=None):
304 314
    """Executes a QMP command and returns the response of the server.
305 315

  

Also available in: Unified diff