All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v0 00/21]: Monitor: improve handlers error handling
Date: Thu, 11 Feb 2010 16:27:00 +0100	[thread overview]
Message-ID: <m3sk97bxob.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <4B740E7A.9060105@codemonkey.ws> (Anthony Liguori's message of "Thu, 11 Feb 2010 08:04:42 -0600")

Anthony Liguori <anthony@codemonkey.ws> writes:

> On 02/10/2010 07:49 PM, Luiz Capitulino wrote:
>>   Hi there,
>>
>>   When I started converting handlers to the QObject style, I thought that
>> returning an error code wouldn't be needed. That is, we have an error object
>> already, so if the handler returns the error object it has failed, otherwise
>> it has succeeded.
>>
>>   This was also very convenient, because handlers have never returned an error
>> code, and thus it would be easier to add a call to qemu_error_new() in the
>> right place instead of returning error codes.
>>
>>   Turns out we need both. Actually, I should not have abused the error object
>> this way because (as Markus says) this is too fragile and we can end up
>> reporting bogus errors to clients (among other problems).
>>
>>   The good news is that it's easy to fix.
>>
>>   All we have to do is to change cmd_new() (the handler callback) to return an
>> error code and convert existing QObject handlers to it. This series does that
>> and most of the patches are really straightforward conversions.
>>
>>   Additionally, Markus has designed an excellent debug mechanism for QMP, which
>> is implemented by the last patches in this series, and will allow us to catch
>> important QObject conversion and error handling bugs in handlers.
>>    
>
> Instead of returning -1, would it make more sense to return an error
> object?  If fact, why not drop ret_data as a passed in parameter, and
> just always return either the result or an error object.

Tempting, isn't it?

The practical trouble with this idea is that you have to adjust a lot of
code to return error objects all the way up into the handler.  With the
current design, you emit error objects "sideways", into the monitor
state.  This lets us keep the current mechanisms to report success /
failure (return >= 0 / -1; non-NULL / NULL, non-zero / zero, ...).

  reply	other threads:[~2010-02-11 15:27 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11  1:49 [Qemu-devel] [PATCH v0 00/21]: Monitor: improve handlers error handling Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 01/21] Monitor: Introduce cmd_new_ret() Luiz Capitulino
2010-02-19 21:28   ` Anthony Liguori
2010-02-11  1:49 ` [Qemu-devel] [PATCH 02/21] Monitor: Convert simple handlers to cmd_new_ret() Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 03/21] Monitor: Convert do_cont() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 04/21] Monitor: Convert do_eject() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 05/21] Monitor: Convert do_cpu_set() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 06/21] Monitor: Convert do_block_set_passwd() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 07/21] Monitor: Convert do_getfd() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 08/21] Monitor: Convert do_closefd() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 09/21] Monitor: Convert pci_device_hot_add() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 10/21] Monitor: Convert pci_device_hot_remove() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 11/21] Monitor: Convert do_migrate() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 12/21] Monitor: Convert do_memory_save() " Luiz Capitulino
2010-02-11  1:49 ` [Qemu-devel] [PATCH 13/21] Monitor: Convert do_physical_memory_save() " Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 14/21] Monitor: Convert do_info() " Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 15/21] Monitor: Convert do_change() " Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 16/21] Monitor: Rename cmd_new_ret() Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 17/21] Monitor: Debugging support Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 18/21] Monitor: Drop the print disabling mechanism Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 19/21] Monitor: Audit handler return Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 20/21] Monitor: Debug stray prints the right way Luiz Capitulino
2010-02-11  1:50 ` [Qemu-devel] [PATCH 21/21] Monitor: Report more than one error in handlers Luiz Capitulino
2010-02-11  8:58 ` [Qemu-devel] [PATCH v0 00/21]: Monitor: improve handlers error handling Markus Armbruster
2010-02-11 11:48   ` Luiz Capitulino
2010-02-11 12:21     ` Markus Armbruster
2010-02-11 14:04 ` Anthony Liguori
2010-02-11 15:27   ` Markus Armbruster [this message]
2010-02-11 16:00     ` Luiz Capitulino
2010-02-11 16:12     ` Anthony Liguori
2010-02-11 16:57       ` Markus Armbruster
2010-02-11 17:17         ` Anthony Liguori
2010-02-12 10:04           ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3sk97bxob.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.