All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, Laszlo Ersek <lersek@redhat.com>,
	Thomas Huth <thuth@redhat.com>, Alexander Graf <agraf@suse.de>,
	Peter Maydell <peter.maydell@linaro.org>,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable
Date: Thu, 6 Apr 2017 12:31:51 +0300	[thread overview]
Message-ID: <64e61eac-825d-0721-07c1-f3935d63cb6a@redhat.com> (raw)
In-Reply-To: <20170405194216.GA15566@thinpad.lan.raisama.net>

On 04/05/2017 10:42 PM, Eduardo Habkost wrote:
> On Wed, Apr 05, 2017 at 10:01:29PM +0300, Marcel Apfelbaum wrote:
>> On 04/04/2017 11:24 PM, Eduardo Habkost wrote:
>>> cannot_instantiate_with_device_add_yet was introduced by commit
>>> 837d37167dc446af8a91189108b363c04609e296 to replace no_user. It
>>> was supposed to be a temporary measure.
>>>
>>
>>
>> Hi Eduardo,
>>
>>> When it was introduced, we had 54
>>> cannot_instantiate_with_device_add_yet=true lines in the code.
>>> Today (3 years later) this number has not shrinked: we now have
>>> 57 cannot_instantiate_with_device_add_yet=true lines. I think it
>>> is safe to say it is not a temporary measure, and we won't see
>>> the flag go away soon.
>>>
>>> Instead of a long field name that misleads people to believe it
>>> is temporary, replace it a shorter and less misleading field:
>>> user_creatable.
>>
>> I completely agree with you. I never liked "negation" fields
>> and especially the ones ending with "_yet".
>>
>> I also don't understand why "user_creatable" can't be used for white-listing *Q35*.
>> I do understand that on some archs we need a white-list per board,
>> but I don't think x86 needs it.
>>
>>>
>>> Except for code comments, changes were generated using the
>>> following Coccinelle patch:
>>>
>>>   @@
>>>   expression DC;
>>>   @@
>>>   (
>>>   -DC->cannot_instantiate_with_device_add_yet = false;
>>>   +DC->user_creatable = true;
>>
>> Is it necessary? Isn't "creatable = true" the default?
>
> cannot_instantiate_with_device_add_yet is also false by default,
> but if there's code explicitly setting it to false somewhere, it
> is probably necessary for some reason. The script doesn't care
> what's the reason, because this is a 100% mechanical translation
> from the old logic to equivalent logic using the new field.
>

I understand.

> If you are still curious about specific cases: explicit
> cannot_instantiate_with_device_add_yet=false/user_creatable=true
> is necessary at x86_cpu_common_class_init(), because TYPE_CPU has
> cannot_instantiate_with_device_add_yet=true (most CPU types don't
> support device_add), but TYPE_X86_CPU sets it back to false
> (because x86 supports CPU hotplug).
>
>>
>>>   |
>>>   -DC->cannot_instantiate_with_device_add_yet = true;
>>>   +DC->user_creatable = false;
>>>   )
>>>
>>>   @@
>>>   typedef ObjectClass;
>>>   expression dc;
>>>   identifier class, data;
>>>   @@
>>>    static void device_class_init(ObjectClass *class, void *data)
>>>    {
>>>    ...
>>>    dc->hotpluggable = true;
>>>   +dc->user_creatable = true;
>>
>> OK... it seems risky :). Is true that "hotpluggable" => creatable,
>> but the prev rule should work, right?
>
> Note that this part is only changing device_class_init(), and no
> other function. dc->hotpluggable=true appears here by pure
> chance: it's just because this is the spot where the new
> dc->user_creatable=true line is being added.
>
> This explicit line addition is required because there's no
> explicit dc->user_creatable=false line in device_class_init
> because QOM objects are always zeroed on creation)
>

Thanks for the answers.

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>


Thanks,
Marcel

>>
>>>    ...
>>>    }
>>>
>>>   @@
>>>   @@
>>>    struct DeviceClass {
>>>    ...
>>>   -bool cannot_instantiate_with_device_add_yet;
>>>   +bool user_creatable;
>>>    ...
>>>   }
>>>
>>>   @@
>>>   expression DC;
>>>   @@
>>>   (
>>>   -!DC->cannot_instantiate_with_device_add_yet
>>>   +DC->user_creatable
>>>   |
>>>   -DC->cannot_instantiate_with_device_add_yet
>>>   +!DC->user_creatable
>>>   )
>>>
>>
>> Nice script!
>
> Thanks!
>

  reply	other threads:[~2017-04-06  9:32 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 20:24 [Qemu-devel] [PATCH v2 00/21] qdev/sysbus: Set user_creatable=false by default on sysbus Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable Eduardo Habkost
2017-04-05 19:01   ` Marcel Apfelbaum
2017-04-05 19:42     ` Eduardo Habkost
2017-04-06  9:31       ` Marcel Apfelbaum [this message]
2017-04-05 21:25     ` Eduardo Habkost
2017-04-05 21:30       ` Peter Maydell
2017-04-06  9:25   ` Thomas Huth
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 02/21] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE Eduardo Habkost
2017-04-05 21:11   ` John Snow
2017-04-06  6:32   ` Juergen Gross
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 03/21] xen-backend: Remove FIXME comment about user_creatable flag Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 04/21] iommu: Remove FIXME comment about user_creatable=true Eduardo Habkost
2017-04-06  9:34   ` Marcel Apfelbaum
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 05/21] fdc: Remove user_creatable flag from sysbus-fdc & SUNW, fdtwo Eduardo Habkost
2017-04-06  9:35   ` Thomas Huth
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 06/21] pflash_cfi01: Remove user_creatable flag Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 07/21] kvmclock: " Eduardo Habkost
2017-04-06  9:42   ` Thomas Huth
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 08/21] ioapic: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 09/21] kvmvapic: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 10/21] sysbus-ahci: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 11/21] allwinner-ahci: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 12/21] isabus-bridge: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 13/21] unimplemented-device: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 14/21] fw_cfg: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 15/21] esp: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 16/21] generic-sdhci: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 17/21] hpet: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 18/21] sysbus-ohci: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 19/21] virtio-mmio: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 20/21] xen-sysdev: " Eduardo Habkost
2017-04-04 20:24 ` [Qemu-devel] [PATCH v2 21/21] s390-pcibus: No need to set user_creatable=false explicitly Eduardo Habkost
2017-04-05  8:55   ` Cornelia Huck
2017-04-06  9:36 ` [Qemu-devel] [PATCH v2 00/21] qdev/sysbus: Set user_creatable=false by default on sysbus Marcel Apfelbaum

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=64e61eac-825d-0721-07c1-f3935d63cb6a@redhat.com \
    --to=marcel@redhat.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=lersek@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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.