All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: "Akihiko Odaki" <akihiko.odaki@daynix.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v2] qdev: Report an error for machine without HotplugHandler
Date: Thu, 21 Dec 2023 07:34:53 +0100	[thread overview]
Message-ID: <871qbg9i7m.fsf@pond.sub.org> (raw)
In-Reply-To: <ZYMaS8v8sIWhteFm@intel.com> (Zhao Liu's message of "Thu, 21 Dec 2023 00:46:03 +0800")

Zhao Liu <zhao1.liu@intel.com> writes:

> Hi Markus,
>
> On Wed, Dec 20, 2023 at 08:53:21AM +0100, Markus Armbruster wrote:
>> Date: Wed, 20 Dec 2023 08:53:21 +0100
>> From: Markus Armbruster <armbru@redhat.com>
>> Subject: Re: [PATCH v2] qdev: Report an error for machine without
>>  HotplugHandler
>> 
>> Having hotpluggable = true when the device cannot be hot-plugged is
>> *wrong*.  You might be able to paper over the wrongness so the code
>> works anyway, but nothing good can come out of lying to developers
>> trying to understand how the code works.
>> 
>> Three ideas to avoid the lying:
>> 
>> 1. default hotpluggable to bus_type != NULL.
>> 
>> 2. assert(dc->bus_type || !dc->hotpluggable) in a suitable spot.
>> 
>> 3. Change the meaning of hotpluggable, and rename it to reflect its new
>> meaning.  Requires a careful reading of its uses.  I wouldn't go there.
>> 
>
> What about 4 (or maybe 3.1) - droping this hotpluggable flag and just use a
> helper (like qbus) to check if device is hotpluggable?
>
> This removes the confusion of that flag and also reduces the number of
> configuration items for DeviceState that require developer attention.
> A simple helper is as follows:
>
> static inline bool qdev_is_hotpluggable(DeviceState *dev)
> {
>     /*
>      * Many Machines don't implement qdev_hotplug_allowed().
>      *
>      * TODO: Once all of them complete missing qdev_hotplug_allowed(),
>      *       use qdev_hotplug_allowed() here.
>      */
>     bool hotpluggable = !!qdev_get_machine_hotplug_handler(dev);
>
>     if (!hotpluggable && dev->parent_bus) {
>         hotpluggable = qbus_is_hotpluggable(dev->parent_bus);
>     }
>
>     return hotpluggable;
> }

Worth exploring, I think.



  reply	other threads:[~2023-12-21  6:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-10  5:34 [PATCH v2] qdev: Report an error for machine without HotplugHandler Akihiko Odaki
2023-12-11  6:51 ` Markus Armbruster
2023-12-13  9:50   ` Akihiko Odaki
2023-12-18 14:02     ` Markus Armbruster
2023-12-19 12:08       ` Akihiko Odaki
2023-12-20  7:53         ` Markus Armbruster
2023-12-20 16:46           ` Zhao Liu
2023-12-21  6:34             ` Markus Armbruster [this message]
2023-12-21  6:36             ` Akihiko Odaki
2023-12-21  8:49               ` Markus Armbruster
2023-12-21  9:36                 ` Akihiko Odaki
2024-02-18  5:47           ` Akihiko Odaki

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=871qbg9i7m.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=berrange@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.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.