[libvirt] [PATCH] qemu_agent: Produce more readable error messages

Not every error message from qemu-ga has to have the 'class' field filled out. For instance, I've seen this error message lately: qemuAgentCheckError:1047 : unable to execute QEMU agent command \ {"execute":"guest-set-time"}: \ {"error":{"desc":"Invalid parameter type, expected: integer"}} However, this got translated into rather generic error message: internal error: unable to execute QEMU agent command 'guest-set-time': unknown QEMU command error So we've dropped better error message in favor of a generic one. This is due to our code which expects 'class' which is not present here. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_agent.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fe38f6d..9f673bf 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1009,14 +1009,12 @@ static const char * qemuAgentStringifyError(virJSONValuePtr error) { const char *klass = virJSONValueObjectGetString(error, "class"); - const char *detail = NULL; + const char *detail = virJSONValueObjectGetString(error, "desc"); /* The QMP 'desc' field is usually sufficient for our generic - * error reporting needs. + * error reporting needs. However, if not present, translate + * the class into something readable. */ - if (klass) - detail = virJSONValueObjectGetString(error, "desc"); - if (!detail) detail = qemuAgentStringifyErrorClass(klass); -- 2.0.4

On 10/27/2014 08:59 PM, Michal Privoznik wrote:
Not every error message from qemu-ga has to have the 'class' field filled out. For instance, I've seen this error message lately:
Is that a bug in qemu-ga? Worth asking on the qemu list. But we have to deal with it in the meantime, so this patch is still worthwhile.
qemuAgentCheckError:1047 : unable to execute QEMU agent command \ {"execute":"guest-set-time"}: \ {"error":{"desc":"Invalid parameter type, expected: integer"}}
However, this got translated into rather generic error message:
internal error: unable to execute QEMU agent command 'guest-set-time': unknown QEMU command error
So we've dropped better error message in favor of a generic one. This is due to our code which expects 'class' which is not present here.
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 28.10.2014 16:09, Eric Blake wrote:
On 10/27/2014 08:59 PM, Michal Privoznik wrote:
Not every error message from qemu-ga has to have the 'class' field filled out. For instance, I've seen this error message lately:
Is that a bug in qemu-ga? Worth asking on the qemu list. But we have to deal with it in the meantime, so this patch is still worthwhile.
This seems to be rather very old qemu-ga. I was unable to reproduce this with the latest one. So it's probably fixed.
qemuAgentCheckError:1047 : unable to execute QEMU agent command \ {"execute":"guest-set-time"}: \ {"error":{"desc":"Invalid parameter type, expected: integer"}}
However, this got translated into rather generic error message:
internal error: unable to execute QEMU agent command 'guest-set-time': unknown QEMU command error
So we've dropped better error message in favor of a generic one. This is due to our code which expects 'class' which is not present here.
ACK.
And pushed now. Thanks! Michal
participants (2)
-
Eric Blake
-
Michal Privoznik