Am 30. August 2011 18:29 schrieb Andrea Spadaccini <[email protected]>:
> --- a/lib/hypervisor/hv_kvm.py
> +++ b/lib/hypervisor/hv_kvm.py
> +  def _ParseMessage(self, buf):
> +    """Extract and parse a QMP message from the given buffer.
> +
> +    Seeks for a QMP message in the given buf. If found, it parses it and
> +    returns it together with the rest of the characters in the buf.
> +    If no message is found, returns None and the whole buffer.
> +
> +    @raise errors.ProgrammerError: when there are data serialization errors
> +    """

Missing the empty line before the docstring ends.

> +    message = None
> +    # Check if we got the message end token (CRLF, as per the QEMU Protocol
> +    # Specification 0.1 - Section 2.1.1)
> +    if self._MESSAGE_END_TOKEN in buf:
> +      pos = buf.index(self._MESSAGE_END_TOKEN)

This will search the string twice. Just use buf.index and see if the
result isn't < 0.

Rest LGTM.

Reply via email to