qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Michael Tsirkin <mst@redhat.com>,
	qemu-devel@nongnu.org, Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] qdev: make reset propagation overrideable by subclasses
Date: Fri, 11 Jan 2013 15:48:44 +0100	[thread overview]
Message-ID: <50F0264C.4070902@suse.de> (raw)
In-Reply-To: <1357913836-4560-2-git-send-email-aliguori@us.ibm.com>

Am 11.01.2013 15:17, schrieb Anthony Liguori:
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/qdev-core.h | 16 +++++++++++++++-
>  hw/qdev.c      | 11 ++++++++++-
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/qdev-core.h b/hw/qdev-core.h
> index 853bd08..f40fd15 100644
> --- a/hw/qdev-core.h
> +++ b/hw/qdev-core.h
> @@ -36,9 +36,23 @@ typedef struct DeviceClass {
>      Property *props;
>      int no_user;
>  
> -    /* callbacks */
> +    /**
> +     * reset:
> +     *
> +     * Cold reset of a device. This function must be implemented by a device's
> +     * that never have children busses.
> +     */
>      void (*reset)(DeviceState *dev);
>  
> +    /**
> +     * reset_all:
> +     *
> +     * Cold reset of a device with children.  The default implementation of this
> +     * method will invoke DeviceClass::reset and then recursively call
> +     * qbus_reset_all() on each child in an arbitrary order.
> +     */
> +    void (*reset_all)(DeviceState *dev);

This documentation is bogus, it should go into DeviceClass as @reset and
@reset_all since these are struct fields, not standalone functions.

This also happens to conflict with the realize/unrealize callbacks being
added, v3 adding DeviceClass documentation on Eduardo's request. Can you
please apply mine first?

No objections to adding such a second reset callback. Maybe add a
DeviceReset typedef to facilitate overriding these in subclasses?

Regards,
Andreas

> +
>      /* device state */
>      const struct VMStateDescription *vmsd;
>  
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 1b68d02..e02b5be 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -223,11 +223,17 @@ static int qbus_reset_one(BusState *bus, void *opaque)
>      return 0;
>  }
>  
> -void qdev_reset_all(DeviceState *dev)
> +static void qdev_reset_children(DeviceState *dev)
>  {
>      qdev_walk_children(dev, qdev_reset_one, qbus_reset_one, NULL);
>  }
>  
> +void qdev_reset_all(DeviceState *dev)
> +{
> +    DeviceClass *dc = DEVICE_GET_CLASS(dev);
> +    dc->reset_all(dev);
> +}
> +
>  void qbus_reset_all(BusState *bus)
>  {
>      qbus_walk_children(bus, qdev_reset_one, qbus_reset_one, NULL);
> @@ -714,7 +720,10 @@ static void device_unparent(Object *obj)
>  
>  static void device_class_init(ObjectClass *class, void *data)
>  {
> +    DeviceClass *dc = DEVICE_CLASS(class);
> +
>      class->unparent = device_unparent;
> +    dc->reset_all = qdev_reset_children;
>  }
>  
>  void device_reset(DeviceState *dev)

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

  reply	other threads:[~2013-01-11 14:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 14:17 [Qemu-devel] [PATCH 0/2] qdev: make reset propagation overrideable by subclasses Anthony Liguori
2013-01-11 14:17 ` [Qemu-devel] [PATCH 1/2] " Anthony Liguori
2013-01-11 14:48   ` Andreas Färber [this message]
2013-01-11 14:17 ` [Qemu-devel] [PATCH 2/2] qbus: make bus reset " Anthony Liguori
2013-01-11 14:21   ` Paolo Bonzini
2013-01-11 14:48     ` Anthony Liguori

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=50F0264C.4070902@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=ehabkost@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).