Commit 8926b648 authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos Committed by Thomas Thrainer
Browse files

QMP: raise exception on unsupported QMP command



Raise a special exception, qmp.QmpCommandNotSupported, whenever an
unsupported QMP command is about to be executed. This is intended to
assist in falling back to the human monitor for hotplug operations. As
such, it is KVM-internal and therefore the exception is not defined
in ganeti.errors.
Signed-off-by: default avatarApollon Oikonomopoulos <apoikos@gmail.com>
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarThomas Thrainer <thomasth@google.com>
parent bb439d22
......@@ -35,6 +35,19 @@ from ganeti import utils
from ganeti import serializer
class QmpCommandNotSupported(errors.HypervisorError):
"""QMP command not supported by the monitor.
This is raised in case a QmpMonitor instance is asked to execute a command
not supported by the instance.
This is a KVM-specific exception, intended to assist in falling back to using
the human monitor for operations QMP does not support.
"""
pass
class QmpMessage(object):
"""QEMU Messaging Protocol (QMP) message.
......@@ -189,7 +202,7 @@ class QmpConnection(MonitorSocket):
def __init__(self, monitor_filename):
super(QmpConnection, self).__init__(monitor_filename)
self._buf = ""
self.supported_commands = frozenset()
self.supported_commands = None
def connect(self):
"""Connects to the QMP monitor.
......@@ -324,6 +337,14 @@ class QmpConnection(MonitorSocket):
"""
self._check_connection()
# During the first calls of Execute, the list of supported commands has not
# yet been populated, so we can't use it.
if (self.supported_commands is not None and
command not in self.supported_commands):
raise QmpCommandNotSupported("Instance does not support the '%s'"
" QMP command." % command)
message = QmpMessage({self._EXECUTE_KEY: command})
if arguments:
message[self._ARGUMENTS_KEY] = arguments
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment