qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/5] qdev: add user_creatable_requires_machine_allowance c


From: Damien Hedde
Subject: Re: [PATCH v2 1/5] qdev: add user_creatable_requires_machine_allowance class flag
Date: Thu, 21 Apr 2022 18:46:05 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0



On 4/21/22 17:59, Peter Maydell wrote:
On Thu, 31 Mar 2022 at 13:19, Damien Hedde <damien.hedde@greensocs.com> wrote:

This flag will be used in device_add to check if
the device needs special allowance from the machine
model.

It will replace the current check based only on the
device being a TYPE_SYB_BUS_DEVICE.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---

v2:
  + change the flag name and put it just below user_creatable
---
  include/hw/qdev-core.h | 9 +++++++++
  hw/core/qdev.c         | 1 +
  hw/core/sysbus.c       | 1 +
  3 files changed, 11 insertions(+)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 92c3d65208..6a040fcd3b 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -122,6 +122,15 @@ struct DeviceClass {
       * TODO remove once we're there
       */
      bool user_creatable;
+    /*
+     * Some devices can be user created under certain conditions (eg:
+     * specific machine support for sysbus devices), but it is
+     * preferable to prevent global allowance for the reasons
+     * described above.
+     * This flag is an additional constraint over user_creatable:
+     * user_creatable still needs to be set to true.
+     */
+    bool user_creatable_requires_machine_allowance;

"allowance" doesn't have the meaning you seem to be trying to give it here.
(It means "the amount of something you're allowed to have", like
a baggage allowance, or "an amount of money you're given for something",
like a travel allowance.)


Do you mean "user creatable only if the machine permits it" ?
Yes.


More generally, the pluggable-sysbus stuff is an awful hack
that I wish we didn't have to have. I'm not sure I want to see
us expanding the use of it to other device types...

I not really trying to trigger code when adding devices. I'm just trying to use the related per-machine allow-list as a way to prevent the user to add such devices (specifically cpu group/cluster) on any random machine which would most probably not "work".

Thanks,
Damien



reply via email to

[Prev in Thread] Current Thread [Next in Thread]