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: Wanpeng Li <liwp@linux.vnet.ibm.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 08/14] qdev: convert busses to QEMU Object Model
Date: Tue, 01 May 2012 21:31:46 +0200	[thread overview]
Message-ID: <4FA03A22.9050406@suse.de> (raw)
In-Reply-To: <1335896294-9530-9-git-send-email-aliguori@us.ibm.com>

Am 01.05.2012 20:18, schrieb Anthony Liguori:
> This is far less interesting than it sounds.  We simply add an Object to each
> BusInfo and then register the types appropriately.  Most of the interesting
> refactoring will follow in the next patches.
> 
> Since we're changing fundamental type names (BusInfo -> BusClass), it all needs
> to convert at once.  Fortunately, not a lot of code is affected.
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
[...]
> diff --git a/hw/intel-hda.c b/hw/intel-hda.c
> index 9405f54..58497e5 100644
> --- a/hw/intel-hda.c
> +++ b/hw/intel-hda.c
> @@ -29,16 +29,19 @@
>  /* --------------------------------------------------------------------- */
>  /* hda bus                                                               */
>  
> -static struct BusInfo hda_codec_bus_info = {
> -    .name      = "HDA",
> -    .size      = sizeof(HDACodecBus),
> +#define TYPE_HDA_BUS "HDA"

I stumbled over this being a pretty generic term for a type name.
"HDA-codec-bus" maybe?

> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
> index f5ee166..97673dd 100644
> --- a/hw/qdev-monitor.c
> +++ b/hw/qdev-monitor.c
[...]
> @@ -432,16 +433,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>          if (!bus) {
>              return NULL;
>          }
> -        if (bus->info != k->bus_info) {
> +        if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0){

Space before {.

> diff --git a/hw/qdev.h b/hw/qdev.h
> index 6d2261f..8ac703e 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
[...]
> @@ -79,28 +79,30 @@ struct DeviceState {
>      int alias_required_for_version;
>  };
>  
> -typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
> -typedef char *(*bus_get_dev_path)(DeviceState *dev);
>  /*
>   * This callback is used to create Open Firmware device path in accordance with
>   * OF spec http://forthworks.com/standards/of1275.pdf. Indicidual bus bindings
>   * can be found here http://playground.sun.com/1275/bindings/.
>   */
> -typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
> -typedef int (qbus_resetfn)(BusState *bus);
>  
> -struct BusInfo {
> -    const char *name;
> -    size_t size;
> -    bus_dev_printfn print_dev;
> -    bus_get_dev_path get_dev_path;
> -    bus_get_fw_dev_path get_fw_dev_path;
> -    qbus_resetfn *reset;
> +#define TYPE_BUS "bus"
> +#define BUS(obj) OBJECT_CHECK(BusState, (obj), TYPE_BUS)
> +#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
> +#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
> +
> +struct BusClass {
> +    ObjectClass parent_class;
> +
> +    /* FIXME first arg should be BusState */
> +    void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
> +    char *(*get_dev_path)(DeviceState *dev);
> +    char *(*get_fw_dev_path)(DeviceState *dev);
> +    int (*reset)(BusState *bus);
>  };
>  
>  struct BusState {
> +    Object obj;
>      DeviceState *parent;
> -    BusInfo *info;
>      const char *name;
>      int allow_hotplug;
>      int qdev_allocated;

Indicate what is /*< private >*/ and what not?

> @@ -321,7 +323,7 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
>  char *qdev_get_fw_dev_path(DeviceState *dev);
>  
>  /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
> -extern struct BusInfo system_bus_info;
> +#define TYPE_SYSTEM_BUS "System"

"System-bus"?

Regarding the bus names, these have been merely moved here but I'm
raising the topic because they are now in the global name space where
they will potentially conflict with devices and other types.

Otherwise looks okay, thanks for your work on this.

Andreas

-- 
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:[~2012-05-01 19:31 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01 18:18 [Qemu-devel] [PATCH 0/14] qom: convert busses to QOM (v2) Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 01/14] qdev: fix adding of ptr properties Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 02/14] object: add object_property_foreach Anthony Liguori
2012-05-01 19:02   ` Andreas Färber
2012-05-01 18:18 ` [Qemu-devel] [PATCH 03/14] qdev: add qdev_add_properties Anthony Liguori
2012-05-01 19:05   ` Andreas Färber
2012-05-01 20:37     ` Anthony Liguori
2012-05-01 20:43       ` Andreas Färber
2012-05-01 20:48         ` Anthony Liguori
2012-05-01 20:57           ` Peter Maydell
2012-05-01 22:01             ` Anthony Liguori
2012-05-01 22:12               ` Paolo Bonzini
2012-05-01 22:23                 ` Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 04/14] qdev: don't allow globals to be set by bus name Anthony Liguori
2012-05-01 20:37   ` Paolo Bonzini
2012-05-01 20:46     ` Anthony Liguori
2012-05-01 21:47       ` Paolo Bonzini
2012-05-01 22:18         ` Andreas Färber
2012-05-01 22:23           ` Anthony Liguori
2012-05-01 22:18         ` Anthony Liguori
2012-05-02  6:32           ` Paolo Bonzini
2012-05-01 18:18 ` [Qemu-devel] [PATCH 05/14] qdev: use wrapper for qdev_get_path Anthony Liguori
2012-05-01 18:36   ` Anthony Liguori
2012-05-02 12:35     ` Gerd Hoffmann
2012-05-01 18:18 ` [Qemu-devel] [PATCH 06/14] qdev: move properties from businfo to base class instance init Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 07/14] qdev: fix info qtree/qdm Anthony Liguori
2012-05-02  7:14   ` Paolo Bonzini
2012-05-01 18:18 ` [Qemu-devel] [PATCH 08/14] qdev: convert busses to QEMU Object Model Anthony Liguori
2012-05-01 19:31   ` Andreas Färber [this message]
2012-05-01 20:40     ` Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 09/14] qdev: connect some links and move type to object (v2) Anthony Liguori
2012-05-01 19:47   ` Andreas Färber
2012-05-01 18:18 ` [Qemu-devel] [PATCH 10/14] qbus: move get_dev_path to DeviceState Anthony Liguori
2012-05-02  7:15   ` Paolo Bonzini
2012-05-01 18:18 ` [Qemu-devel] [PATCH 11/14] qbus: move get_fw_dev_path to DeviceClass Anthony Liguori
2012-05-01 19:34   ` Andreas Färber
2012-05-01 22:24     ` Anthony Liguori
2012-05-01 22:36       ` Andreas Färber
2012-05-02  7:22         ` Paolo Bonzini
2012-05-01 18:18 ` [Qemu-devel] [PATCH 12/14] qbus: move print_dev " Anthony Liguori
2012-05-01 19:37   ` Andreas Färber
2012-05-01 18:18 ` [Qemu-devel] [PATCH 13/14] qbus: make child devices links Anthony Liguori
2012-05-01 18:18 ` [Qemu-devel] [PATCH 14/14] qbus: initialize in standard way Anthony Liguori
2012-05-02  8:34   ` Paolo Bonzini

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=4FA03A22.9050406@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=liwp@linux.vnet.ibm.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).