qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v1 00/14]: Initial QObject conversion


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH v1 00/14]: Initial QObject conversion
Date: Fri, 02 Oct 2009 17:36:13 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-2.7.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4

  Hi,

So maybe they shouldn't be named MonitorError in the first place?

  What do you suggest?

  Hm.. This could be QError, meaning that it's also a QObject,
so that we can put it in dicts, lists, etc.

Makes sense to me.

Attaching the pretty-print callback to the error struct not to the monitor command is a good move too. Makes it easier to reuse these functions.

Hmm, maybe it would be even better to link the pretty-print functions to error codes?

Why user_error is needed in the first place btw?  To maintain
backward-compatible error message formating?

  Yes and to do pretty printing too.

  For example:

qemu_error("Device \"%s\" not found.  Try -device '?' for a list.\n",
            driver);

  Makes sense for humans, but for QMP it would probably look like:

{ "error": { "code": 1234,
              "desc": "device not found",
              "data": { "name": "foobar-device" } } }

You could have a generic function which makes a message like this:

  'device not found: name=foobar-device'

out of the QError.  Not too bad.  You'll loose the '-device ?' hint though.

I think it is reasonable to make the pretty-print callback optional and use the generic function in case it isn't present. So you have something working by default and can override it of the message isn't userfriendly or backward-compatible enougth.

  So, when QMP is disabled that function will be called to print the error
for humans. When QMP is enabled this is never called and the protocol
emission code will use QError to emit something like the { "error" }
dict above.

Thanks for the explanation.

cheers,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]