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

QMP: keep greeting message version info



QMP will always report the QEMU version and package-specific string in
the greeting message, as per the QEMU Machine Protocol Specification. We
store this information and make it available to users of the monitor.
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 5d94ddf6
......@@ -195,6 +195,9 @@ class QmpConnection(MonitorSocket):
_ERROR_DESC_KEY = "desc"
_EXECUTE_KEY = "execute"
_ARGUMENTS_KEY = "arguments"
_VERSION_KEY = "version"
_PACKAGE_KEY = "package"
_QEMU_KEY = "qemu"
_CAPABILITIES_COMMAND = "qmp_capabilities"
_QUERY_COMMANDS = "query-commands"
_MESSAGE_END_TOKEN = "\r\n"
......@@ -223,6 +226,15 @@ class QmpConnection(MonitorSocket):
raise errors.HypervisorError("kvm: QMP communication error (wrong"
" server greeting")
# Extract the version info from the greeting and make it available to users
# of the monitor.
version_info = greeting[self._FIRST_MESSAGE_KEY][self._VERSION_KEY]
self.version = (version_info[self._QEMU_KEY]["major"],
version_info[self._QEMU_KEY]["minor"],
version_info[self._QEMU_KEY]["micro"])
self.package = version_info[self._PACKAGE_KEY].strip()
# This is needed because QMP can return more than one greetings
# see https://groups.google.com/d/msg/ganeti-devel/gZYcvHKDooU/SnukC8dgS5AJ
self._buf = ""
......
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