All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: peter.maydell@linaro.org, mst@redhat.com, somlo@cmu.edu,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	qemu-devel@nongnu.org, rjones@redhat.com, pbonzini@redhat.com,
	lersek@redhat.com
Subject: Re: [Qemu-devel] [PATCHv7 5/6] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers
Date: Mon, 10 Jul 2017 14:38:21 -0300	[thread overview]
Message-ID: <20170710173821.GD5167@localhost.localdomain> (raw)
In-Reply-To: <20170710172336.33c64f86@nial.brq.redhat.com>

On Mon, Jul 10, 2017 at 05:23:36PM +0200, Igor Mammedov wrote:
> On Mon, 10 Jul 2017 11:53:31 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Mon, Jul 10, 2017 at 10:01:47AM +0200, Igor Mammedov wrote:
> > > On Fri, 7 Jul 2017 17:20:25 +0100
> > > Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote:
> > >   
> > > > On 07/07/17 16:07, Eduardo Habkost wrote:
> > > >   
> > > > >> looks fine,
> > > > >>
> > > > >> so what I'd do is:
> > > > >>  * drop 4/6    
> > > > 
> > > > Yes.
> > > >   
> > > > > Agreed on this point.  But:
> > > > >     
> > > > >>  * make fw_cfg_find() use ambiguous argument and error_abort if ambiguous == true    
> > > > 
> > > > During my latest tests I've found that everything works fine without the
> > > > ambiguous argument.
> > > > 
> > > > Do we still want to keep it? And I don't think error_abort() is the
> > > > right thing to do here, I'd much rather return NULL and add a suitable
> > > > comment.  
> > > I'd still use ambiguous argument and since you prefer not to assert
> > > I'd add errp argument to fw_cfg_find() and handle error at callsites.
> > > 
> > > Just returning NULL isn't sufficient if you need to distinguish
> > > 'not found' vs 'duplicate' usecases, additionally  'not found'
> > > in most cases isn't even error but 'duplicate' definitely is.
> > > 
> > > Aborting on diplicate in fw_cfg_find() is fine and would
> > > help to avoid touching current callers if you wish to limit
> > > patches scope, but you can go with proper error propagating
> > > route if you wish.  
> > 
> > Just making realize refuse to create two devices sounds much
> > simpler to me.  No need to make fw_cfg_find() more complex (if we
> > add errp argument to it) or less useful (if we add
> > assert(!ambiguous) to it).
> the problem here was a error message to print if fw_cfg_find()
> returns NULL for missing or duplicate, if we need to print
> precise error we would need proper error handling.

I don't see where we would need a precise error message, except
for realizefn (where the only case fw_cfg_find() would return
NULL is for duplicate devices).

> 
> Considering to fw_cfg is builtin device I'd prefer just
> assert in fw_cfg_find() on duplicate (all the callers consider it as error)
> and let developer to deal with assert if it is triggered.

Except that it would make it more difficult for realizefn to
return a proper error message.

Anyway, I am not completely against adding assert(!ambiguous) to
fw_cfg_find() if Mark wants to follow your advice.  I just think
it's not necessary.  I will only continue discussing this if I
see issues in the next version of the series.

-- 
Eduardo

  reply	other threads:[~2017-07-10 17:38 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 14:07 [Qemu-devel] [PATCHv7 0/6] fw_cfg: qdev-related tidy-ups Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 1/6] fw_cfg: don't map the fw_cfg IO ports in fw_cfg_io_realize() Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 2/6] fw_cfg: move setting of FW_CFG_VERSION_DMA bit to fw_cfg_init1() Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 3/6] fw_cfg: switch fw_cfg_find() to locate the fw_cfg device by type rather than path Mark Cave-Ayland
2017-07-03  9:42   ` Igor Mammedov
2017-07-04 18:14     ` Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 4/6] fw_cfg: add assert() to ensure the fw_cfg device has been added as a child property Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 5/6] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers Mark Cave-Ayland
2017-07-03  9:39   ` Igor Mammedov
2017-07-04 18:08     ` Mark Cave-Ayland
2017-07-07 11:33       ` Igor Mammedov
2017-07-07 13:12         ` Mark Cave-Ayland
2017-07-07 13:26           ` Eduardo Habkost
2017-07-07 13:54             ` Mark Cave-Ayland
2017-07-07 14:48               ` Eduardo Habkost
2017-07-07 16:16                 ` Mark Cave-Ayland
2017-07-07 14:44           ` Igor Mammedov
2017-07-07 14:50             ` Eduardo Habkost
2017-07-07 15:07             ` Eduardo Habkost
2017-07-07 16:20               ` Mark Cave-Ayland
2017-07-10  8:01                 ` Igor Mammedov
2017-07-10 14:53                   ` Eduardo Habkost
2017-07-10 15:23                     ` Igor Mammedov
2017-07-10 17:38                       ` Eduardo Habkost [this message]
2017-07-11 18:05                         ` Mark Cave-Ayland
2017-07-10  7:49               ` Igor Mammedov
2017-07-10 14:51                 ` Eduardo Habkost
2017-07-07 13:13         ` Eduardo Habkost
2017-07-07 14:58           ` Igor Mammedov
2017-07-07 15:09             ` Eduardo Habkost
2017-07-07 18:18               ` Igor Mammedov
2017-07-07 19:30                 ` Eduardo Habkost
2017-07-07 19:54                   ` Eduardo Habkost
2017-07-07 20:03                     ` Laszlo Ersek
2017-07-07 16:13           ` Mark Cave-Ayland
2017-06-29 14:07 ` [Qemu-devel] [PATCHv7 6/6] fw_cfg: move QOM type defines and fw_cfg types into fw_cfg.h Mark Cave-Ayland
2017-06-29 15:32 ` [Qemu-devel] [PATCHv7 0/6] fw_cfg: qdev-related tidy-ups Gabriel L. Somlo

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=20170710173821.GD5167@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=somlo@cmu.edu \
    /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.