On Mon, Apr 7, 2014 at 3:37 PM, Apollon Oikonomopoulos <[email protected]>wrote:
> 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: Apollon Oikonomopoulos <[email protected]> > --- > lib/hypervisor/hv_kvm/monitor.py | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/lib/hypervisor/hv_kvm/monitor.py > b/lib/hypervisor/hv_kvm/monitor.py > index 16bf7cc..8176a41 100644 > --- a/lib/hypervisor/hv_kvm/monitor.py > +++ b/lib/hypervisor/hv_kvm/monitor.py > @@ -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" > @@ -229,6 +232,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 = "" > -- > 1.9.1 > > LGTM, thanks. -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
