All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Amos Kong <akong@redhat.com>
Cc: aliguori@us.ibm.com, kevin@koconnor.net, seabios@seabios.org,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] qdev: don't add typename to fw_dev_path when get_fw_dev_path isn't implemented
Date: Tue, 28 May 2013 13:15:57 +0200	[thread overview]
Message-ID: <51A491ED.2080504@redhat.com> (raw)
In-Reply-To: <1369738859-16557-1-git-send-email-akong@redhat.com>

Il 28/05/2013 13:00, Amos Kong ha scritto:
> Recent virtio refactoring in QEMU made virtio-bus become the parent bus
> of scsi-bus, and virtio-bus doesn't have get_fw_dev_path implementation,
> so redundant typename will be added to fw_dev_path. It causes that
> bootindex parameter of scsi device doesn't work.
> 
> This patch changes qdev_get_fw_dev_path_helper() to add nothing if
> implemented get_fw_dev_path() returns NULL.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> --
> v2: only add nothing to fw_dev_path when get_fw_dev_path() is
>     implemented and return NULL. then it will not effect other devices
>     don't have get_fw_dev_path() implementation.

To achieve the same result, you can simply ensure that all classes
implement the method.  The default implementation is just
g_strdup(object_get_typename(OBJECT(dev))).

Remember that if you do not specify a method in a BusClass's class_init
function, it is inherited from the superclass.

Paolo

> ---
>  hw/core/qdev.c         | 5 +++++
>  hw/virtio/virtio-bus.c | 6 ++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6985ad8..2a08368 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -509,11 +509,16 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
>  
>      if (dev && dev->parent_bus) {
>          char *d;
> +        BusClass *parent_bc = BUS_GET_CLASS(dev->parent_bus);
> +
>          l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
>          d = bus_get_fw_dev_path(dev->parent_bus, dev);
> +
>          if (d) {
>              l += snprintf(p + l, size - l, "%s", d);
>              g_free(d);
> +        } else if (parent_bc->get_fw_dev_path) {
> +            return l;
>          } else {
>              l += snprintf(p + l, size - l, "%s", object_get_typename(OBJECT(dev)));
>          }
> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
> index ea2e11a..6849a01 100644
> --- a/hw/virtio/virtio-bus.c
> +++ b/hw/virtio/virtio-bus.c
> @@ -161,10 +161,16 @@ static char *virtio_bus_get_dev_path(DeviceState *dev)
>      return qdev_get_dev_path(proxy);
>  }
>  
> +static char *virtio_bus_get_fw_dev_path(DeviceState *dev)
> +{
> +    return NULL;
> +}
> +
>  static void virtio_bus_class_init(ObjectClass *klass, void *data)
>  {
>      BusClass *bus_class = BUS_CLASS(klass);
>      bus_class->get_dev_path = virtio_bus_get_dev_path;
> +    bus_class->get_fw_dev_path = virtio_bus_get_fw_dev_path;

This hunk is correct.

>  }
>  
>  static const TypeInfo virtio_bus_info = {
> 

  reply	other threads:[~2013-05-28 11:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 11:00 [Qemu-devel] [PATCH v2] qdev: don't add typename to fw_dev_path when get_fw_dev_path isn't implemented Amos Kong
2013-05-28 11:15 ` Paolo Bonzini [this message]
2013-05-29  4:41   ` Amos Kong
2013-05-29  6:27     ` Paolo Bonzini
2013-05-28 11:18 ` Amos Kong

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=51A491ED.2080504@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=kevin@koconnor.net \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=seabios@seabios.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.