All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, "Eduardo Habkost" <ehabkost@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	dgilbert@redhat.com, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"Artyom Tarasenko" <atar4qemu@gmail.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH 5/9] qom/globals: generalize object_property_set_globals()
Date: Mon, 29 Oct 2018 14:11:48 +0100	[thread overview]
Message-ID: <20181029141148.170dad3f@redhat.com> (raw)
In-Reply-To: <20180912125531.32131-6-marcandre.lureau@redhat.com>

On Wed, 12 Sep 2018 16:55:27 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Handle calls of object_property_set_globals() with any object type,
> but only apply globals to TYPE_DEVICE & TYPE_USER_CREATABLE.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qom/globals.c | 22 ++++++++++++++--------
>  1 file changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/qom/globals.c b/qom/globals.c
> index 587f4a1b5c..8664baebe0 100644
> --- a/qom/globals.c
> +++ b/qom/globals.c
> @@ -15,22 +15,28 @@ void object_property_register_global(GlobalProperty *prop)
>  
>  void object_property_set_globals(Object *obj)
>  {
> -    DeviceState *dev = DEVICE(obj);
>      GList *l;
> +    DeviceState *dev = (DeviceState *)object_dynamic_cast(obj, TYPE_DEVICE);
> +
> +    if (!dev && !IS_USER_CREATABLE(obj)) {
> +        /* only TYPE_DEVICE and TYPE_USER_CREATABLE support globals */
> +        return;
> +    }
more dynamic casts but now imposed on every create object :(

Maybe we should add ObjectClass::check/set_globals hook?
It would be cheap to check and only objects we intend to work with
it would be affected. On top of that hooks could be different so
that device/user_creatable specifics won't be in generic code
(like it's implemented here).

>  
>      for (l = global_props; l; l = l->next) {
>          GlobalProperty *prop = l->data;
>          Error *err = NULL;
>  
> -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> +        if (object_dynamic_cast(obj, prop->driver) == NULL) {
>              continue;
>          }
>          prop->used = true;
> -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> +        object_property_parse(obj, prop->value, prop->property, &err);
>          if (err != NULL) {
>              error_prepend(&err, "can't apply global %s.%s=%s: ",
>                            prop->driver, prop->property, prop->value);
> -            if (!dev->hotplugged && prop->errp) {
> +
> +            if (dev && !dev->hotplugged && prop->errp) {
>                  error_propagate(prop->errp, err);
>              } else {
>                  assert(prop->user_provided);
> @@ -56,15 +62,15 @@ int object_property_check_globals(void)
>              continue;
>          }
>          oc = object_class_by_name(prop->driver);
> -        oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
> -        if (!oc) {
> +        dc = (DeviceClass *)object_class_dynamic_cast(oc, TYPE_DEVICE);
> +        if (!IS_USER_CREATABLE_CLASS(oc) && !dc) {
>              warn_report("global %s.%s has invalid class name",
>                          prop->driver, prop->property);
>              ret = 1;
>              continue;
>          }
> -        dc = DEVICE_CLASS(oc);
> -        if (!dc->hotpluggable && !prop->used) {
> +
> +        if (dc && !dc->hotpluggable) {
>              warn_report("global %s.%s=%s not used",
>                          prop->driver, prop->property, prop->value);
>              ret = 1;

  reply	other threads:[~2018-10-29 13:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 12:55 [Qemu-devel] [PATCH 0/9] hostmem-ram: use whole path for region name with >= 3.1 Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 1/9] qom/user-creatable: add a few helper macros Marc-André Lureau
2018-10-22 14:33   ` Igor Mammedov
2018-10-26 15:13     ` Eduardo Habkost
2018-10-29  9:56       ` Igor Mammedov
2018-10-30  1:37         ` Eduardo Habkost
2018-10-30  9:26           ` Marc-André Lureau
2018-10-30 14:22             ` Igor Mammedov
2018-10-30 23:07               ` Eduardo Habkost
2018-11-01 12:16                 ` Igor Mammedov
2018-11-01 15:02                   ` Eduardo Habkost
2018-11-01 15:46                     ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 2/9] accel: register global_props like machine globals Marc-André Lureau
2018-10-22 14:47   ` Igor Mammedov
2018-10-22 14:47     ` [Qemu-devel] " Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 3/9] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-10-22 14:51   ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 4/9] qom/globals: move qdev globals to qom Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 5/9] qom/globals: generalize object_property_set_globals() Marc-André Lureau
2018-10-29 13:11   ` Igor Mammedov [this message]
2018-10-30 12:16     ` Marc-André Lureau
2018-10-30 14:05       ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 6/9] qom/object: set globals when initializing object Marc-André Lureau
2018-10-29 12:20   ` Igor Mammedov
2018-09-12 12:55 ` [Qemu-devel] [PATCH 7/9] tests: add user-creatable test to test-qdev-global-props Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 8/9] hw/i386: add pc-i440fx-3.1 & pc-q35-3.1 Marc-André Lureau
2018-09-12 12:55 ` [Qemu-devel] [PATCH 9/9] hostmem-ram: use whole path for memory region name with >= 3.1 Marc-André Lureau
2018-09-13 10:19   ` Dr. David Alan Gilbert
2018-10-29 15:16   ` Igor Mammedov
2018-10-02 10:24 ` [Qemu-devel] [PATCH 0/9] hostmem-ram: use whole path for " Marc-André Lureau

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=20181029141148.170dad3f@redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=atar4qemu@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.