[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for excepti
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly |
Date: |
Thu, 23 May 2013 14:30:08 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, May 21, 2013 at 11:34:16AM -0400, Tomoki Sekiyama wrote:
> qemu-ga in Windows may return error message with multibyte characters
> when the guest OS language is set to other than English. To display such
> messages correctly, this encodes the message based on the locale settings.
>
> Signed-off-by: Tomoki Sekiyama <address@hidden>
> ---
> QMP/qmp.py | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/QMP/qmp.py b/QMP/qmp.py
> index c551df1..ee21819 100644
> --- a/QMP/qmp.py
> +++ b/QMP/qmp.py
> @@ -11,6 +11,7 @@
> import json
> import errno
> import socket
> +import locale
>
> class QMPError(Exception):
> pass
> @@ -133,7 +134,8 @@ class QEMUMonitorProtocol:
> def command(self, cmd, **kwds):
> ret = self.cmd(cmd, kwds)
> if ret.has_key('error'):
> - raise Exception(ret['error']['desc'])
> + enc = locale.getpreferredencoding()
> + raise Exception(ret['error']['desc'].encode(enc))
You should not need to explicitly encode the error descriptor. The
error description should be UTF-8 on the wire and a Unicode Python
string in this script.
I think the real problem is:
1. Guest qga is writing strings in local encoding onto the wire.
or
2. qmp.py isn't UTF-8-decoding strings received over the wire.
Either or both bugs could be present. Once they are fixed you shouldn't
see encoding problems.
Stefan
- Re: [Qemu-devel] [RFC PATCH v3 02/11] Fix errors and warnings while compiling with c++ compilier, (continued)
- [Qemu-devel] [RFC PATCH v3 01/11] configure: Support configuring c++ compiler, Tomoki Sekiyama, 2013/05/21
- [Qemu-devel] [RFC PATCH v3 07/11] qemu-ga: call Windows VSS requester in fsfreeze command handler, Tomoki Sekiyama, 2013/05/21
- [Qemu-devel] [RFC PATCH v3 08/11] qemu-ga: install Windows VSS provider on `qemu-ga -s install', Tomoki Sekiyama, 2013/05/21
- [Qemu-devel] [RFC PATCH v3 10/11] QMP/qemu-ga-client: make timeout longer for guest-fsfreeze-freeze command, Tomoki Sekiyama, 2013/05/21
- [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly, Tomoki Sekiyama, 2013/05/21
- Re: [Qemu-devel] [RFC PATCH v3 11/11] QMP/qmp.py: set locale for exceptions to display non-ascii messages correctly,
Stefan Hajnoczi <=
- [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system, Tomoki Sekiyama, 2013/05/21
- Re: [Qemu-devel] [RFC PATCH v3 03/11] Add a script to extract VSS SDK headers on POSIX system, Laszlo Ersek, 2013/05/24
[Qemu-devel] [RFC PATCH v3 04/11] qemu-ga: Add an configure option to specify path to Windows VSS SDK, Tomoki Sekiyama, 2013/05/21