Skip to contentSkip to conversation

qdev/sysbus: Set user_creatable=false by default on sysbus

PATCH Superseded Eduardo Habkost 7 participants 35 messages Apr 4, 2017 – Apr 6, 2017 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

v2 cover qdev/sysbus: Set user_creatable=false by default on sysbus

Changes v1 -> v2
----------------

* Rewrote series name and cover letter completely to not pretend we're fixing the q35 lack-of-sysbus-whitelist bug, and explain the motivation for the series.
* Previous series name was:
"sysbus: Don't allow -device/device_add by default"
* Rewrote description of patch 02/21, too
* (I really hope people read this cover letter before commenting on individual patches.)
* Rewrote FIXME comments to make it clear that we just set user_creatable=true temporarily because we don't know yet if the device should be in the q35 whitelist.
* Set user_creatable=true on xen-backend also
(I didn't notice it was missing because I was building QEMU without xen support)
* New patches:
* "xen-backend: Remove FIXME comment about user_creatable flag"
* "xen-sysdev: Remove user_creatable flag"
* Patch:
"s390: Add FIXME for unexplained user_creatable=false line"
replaced with:
"s390-pcibus: No need to set user_creatable=false explicitly"

Description
-----------

This series refactor the cannot_instantiate_with_device_add code for sysbus. First, the cannot_instantiate_with_device_add field is replaced by !user_creatable.

Then, we change TYPE_SYS_BUS_DEVICE to set user_creatable=false by default, and we set user_creatable=true explicitly only on the devices that are really supposed to be user-creatable on some machines.

Motivation
----------

First of all, this makes the code less fragile: setting user_creatable=false or cannot_instantiate_with_device_add=true on all sysbus devices is incorrect, and makes code that looks at cannot_instantiate_with_device_add/user_creatable easy to break.

This also fixes a regression introduced by commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31, that makes all sysbus devices appear on "-device help" and lack the "no-user" flag on "info qdm"[1].

This will also make it possible for automatic test code (like the device-crash-test.py script I sent a while ago[2]) skip devices that are not supposed to be user-creatable on any machine.

A note about the lack of sysbus whitelist on q35
------------------------------------------------

This series won't make the per-machine whitelist of sysbus devices unnecessary, but just makes the user_creatable field consistent on the sys-bus-device classes. This means q35 and xen still need to be fixed to implemented a sysbus device whitelist.

However, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist.

Full list of user_creatable=true sysbus devices
-----------------------------------------------

In the end of this series, the only remaining sysbus devices with user_creatable=true will be:

* vfio-amd-xgbe (arm)
* vfio-calxeda-xgmac (arm)
* amd-iommu (x86)
* intel-iommu (x86)
* xen-backend (x86)
* spapr-pci-host-bridge (ppc)
* spapr-pci-vfio-host-bridge (ppc)
* eTSEC (ppc)

References/Notes
----------------

[1] For example, before this series, we had 174 sysbus devices
listed on qemu-system-arm -device help:
$ qemu-system-arm -machine none -device help 2>&1 | grep 'bus System' | wc -l 174
$
after this series, we now have:
$ ./arm-softmmu/qemu-system-arm -machine none -device help 2>&1 | grep 'bus System' name "vfio-amd-xgbe", bus System, desc "VFIO AMD XGBE"
name "vfio-calxeda-xgmac", bus System, desc "VFIO Calxeda XGMAC"
$

[2] Subject: [PATCH 0/3] script for crash-testing -device

---
Cc: Alexander Graf <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Peter Maydell <[email protected]>

Eduardo Habkost (21):
qdev: Replace cannot_instantiate_with_device_add_yet with
!user_creatable
sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE
xen-backend: Remove FIXME comment about user_creatable flag
iommu: Remove FIXME comment about user_creatable=true
fdc: Remove user_creatable flag from sysbus-fdc & SUNW,fdtwo
pflash_cfi01: Remove user_creatable flag
kvmclock: Remove user_creatable flag
ioapic: Remove user_creatable flag
kvmvapic: Remove user_creatable flag
sysbus-ahci: Remove user_creatable flag
allwinner-ahci: Remove user_creatable flag
isabus-bridge: Remove user_creatable flag
unimplemented-device: Remove user_creatable flag
fw_cfg: Remove user_creatable flag
esp: Remove user_creatable flag
generic-sdhci: Remove user_creatable flag
hpet: Remove user_creatable flag
sysbus-ohci: Remove user_creatable flag
virtio-mmio: Remove user_creatable flag
xen-sysdev: Remove user_creatable flag
s390-pcibus: No need to set user_creatable=false explicitly

 include/hw/qdev-core.h              | 10 +++++-----
 include/hw/qdev-properties.h        |  4 ++--
 hw/acpi/piix4.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/audio/marvell_88w8618.c          |  2 +-
 hw/audio/pcspk.c                    |  2 +-
 hw/core/or-irq.c                    |  2 +-
 hw/core/qdev.c                      |  1 +
 hw/core/register.c                  |  2 +-
 hw/core/sysbus.c                    | 11 +++++++++++
 hw/dma/i8257.c                      |  2 +-
 hw/dma/sparc32_dma.c                |  2 +-
 hw/gpio/omap_gpio.c                 |  4 ++--
 hw/i2c/omap_i2c.c                   |  2 +-
 hw/i2c/smbus_eeprom.c               |  2 +-
 hw/i2c/smbus_ich9.c                 |  2 +-
 hw/i386/amd_iommu.c                 |  2 ++
 hw/i386/intel_iommu.c               |  2 ++
 hw/i386/pc.c                        |  2 +-
 hw/input/vmmouse.c                  |  2 +-
 hw/intc/apic_common.c               |  2 +-
 hw/intc/etraxfs_pic.c               |  2 +-
 hw/intc/grlib_irqmp.c               |  2 +-
 hw/intc/i8259_common.c              |  2 +-
 hw/intc/nios2_iic.c                 |  2 +-
 hw/intc/omap_intc.c                 |  4 ++--
 hw/isa/lpc_ich9.c                   |  2 +-
 hw/isa/piix4.c                      |  2 +-
 hw/isa/vt82c686.c                   |  2 +-
 hw/mips/gt64xxx_pci.c               |  2 +-
 hw/misc/vmport.c                    |  2 +-
 hw/net/dp8393x.c                    |  2 +-
 hw/net/etraxfs_eth.c                |  2 +-
 hw/net/fsl_etsec/etsec.c            |  2 ++
 hw/net/lance.c                      |  2 +-
 hw/pci-bridge/dec.c                 |  2 +-
 hw/pci-bridge/pci_expander_bridge.c |  2 +-
 hw/pci-host/apb.c                   |  2 +-
 hw/pci-host/bonito.c                |  2 +-
 hw/pci-host/gpex.c                  |  2 +-
 hw/pci-host/grackle.c               |  2 +-
 hw/pci-host/piix.c                  |  6 +++---
 hw/pci-host/ppce500.c               |  2 +-
 hw/pci-host/prep.c                  |  2 +-
 hw/pci-host/q35.c                   |  4 ++--
 hw/pci-host/uninorth.c              |  8 ++++----
 hw/pci-host/versatile.c             |  2 +-
 hw/pci-host/xilinx-pcie.c           |  2 +-
 hw/ppc/ppc4xx_pci.c                 |  2 +-
 hw/ppc/spapr_drc.c                  |  2 +-
 hw/ppc/spapr_pci.c                  |  2 ++
 hw/s390x/s390-pci-bus.c             |  1 -
 hw/sd/milkymist-memcard.c           |  2 +-
 hw/sd/pl181.c                       |  2 +-
 hw/sh4/sh_pci.c                     |  2 +-
 hw/timer/i8254_common.c             |  2 +-
 hw/timer/mc146818rtc.c              |  2 +-
 hw/vfio/amd-xgbe.c                  |  2 ++
 hw/vfio/calxeda-xgmac.c             |  2 ++
 hw/xen/xen_backend.c                |  2 ++
 monitor.c                           |  2 +-
 qdev-monitor.c                      |  6 +++---
 qom/cpu.c                           |  2 +-
 target/i386/cpu.c                   |  2 +-
 64 files changed, 95 insertions(+), 70 deletions(-)
Signature · 1 line
2.11.0.259.g40922b1
#1 lore raw

PATCH v2 1/21 qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

cannot_instantiate_with_device_add_yet was introduced by commit 837d37167dc446af8a91189108b363c04609e296 to replace no_user. It was supposed to be a temporary measure.

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.

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;
  |
  -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;
   ...
   }

  @@
  @@
   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
)

Cc Markus Armbruster <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Thomas Huth <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 include/hw/qdev-core.h              | 10 +++++-----
 include/hw/qdev-properties.h        |  4 ++--
 hw/acpi/piix4.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/audio/marvell_88w8618.c          |  2 +-
 hw/audio/pcspk.c                    |  2 +-
 hw/core/or-irq.c                    |  2 +-
 hw/core/qdev.c                      |  1 +
 hw/core/register.c                  |  2 +-
 hw/dma/i8257.c                      |  2 +-
 hw/dma/sparc32_dma.c                |  2 +-
 hw/gpio/omap_gpio.c                 |  4 ++--
 hw/i2c/omap_i2c.c                   |  2 +-
 hw/i2c/smbus_eeprom.c               |  2 +-
 hw/i2c/smbus_ich9.c                 |  2 +-
 hw/i386/pc.c                        |  2 +-
 hw/input/vmmouse.c                  |  2 +-
 hw/intc/apic_common.c               |  2 +-
 hw/intc/etraxfs_pic.c               |  2 +-
 hw/intc/grlib_irqmp.c               |  2 +-
 hw/intc/i8259_common.c              |  2 +-
 hw/intc/nios2_iic.c                 |  2 +-
 hw/intc/omap_intc.c                 |  4 ++--
 hw/isa/lpc_ich9.c                   |  2 +-
 hw/isa/piix4.c                      |  2 +-
 hw/isa/vt82c686.c                   |  2 +-
 hw/mips/gt64xxx_pci.c               |  2 +-
 hw/misc/vmport.c                    |  2 +-
 hw/net/dp8393x.c                    |  2 +-
 hw/net/etraxfs_eth.c                |  2 +-
 hw/net/lance.c                      |  2 +-
 hw/pci-bridge/dec.c                 |  2 +-
 hw/pci-bridge/pci_expander_bridge.c |  2 +-
 hw/pci-host/apb.c                   |  2 +-
 hw/pci-host/bonito.c                |  2 +-
 hw/pci-host/gpex.c                  |  2 +-
 hw/pci-host/grackle.c               |  2 +-
 hw/pci-host/piix.c                  |  6 +++---
 hw/pci-host/ppce500.c               |  2 +-
 hw/pci-host/prep.c                  |  2 +-
 hw/pci-host/q35.c                   |  4 ++--
 hw/pci-host/uninorth.c              |  8 ++++----
 hw/pci-host/versatile.c             |  2 +-
 hw/pci-host/xilinx-pcie.c           |  2 +-
 hw/ppc/ppc4xx_pci.c                 |  2 +-
 hw/ppc/spapr_drc.c                  |  2 +-
 hw/s390x/s390-pci-bus.c             |  2 +-
 hw/sd/milkymist-memcard.c           |  2 +-
 hw/sd/pl181.c                       |  2 +-
 hw/sh4/sh_pci.c                     |  2 +-
 hw/timer/i8254_common.c             |  2 +-
 hw/timer/mc146818rtc.c              |  2 +-
 monitor.c                           |  2 +-
 qdev-monitor.c                      |  6 +++---
 qom/cpu.c                           |  2 +-
 target/i386/cpu.c                   |  2 +-
 56 files changed, 71 insertions(+), 70 deletions(-)
include/hw/qdev-core.h +5 -5
index b44b476765..bc4e6f0486 100644
@@ -103,16 +103,16 @@ typedef struct DeviceClass {
     Property *props;
 
     /*
-     * Shall we hide this device model from -device / device_add?
+     * Can this device be instantiated with -device / device_add?
      * All devices should support instantiation with device_add, and
      * this flag should not exist.  But we're not there, yet.  Some
      * devices fail to instantiate with cryptic error messages.
      * Others instantiate, but don't work.  Exposing users to such
-     * behavior would be cruel; this flag serves to protect them.  It
-     * should never be set without a comment explaining why it is set.
-     * TODO remove once we're there
+     * behavior would be cruel; clearing this flag will protect them.
+     * It should never be cleared without a comment explaining why it
+     * is cleared.
      */
-    bool cannot_instantiate_with_device_add_yet;
+    bool user_creatable;
     /*
      * Does this device model survive object_unref(object_new(TNAME))?
      * All device models should, and this flag shouldn't exist.  Some
include/hw/qdev-properties.h +2 -2
index 7ac315331a..5c6e13b993 100644
@@ -134,12 +134,12 @@ extern PropertyInfo qdev_prop_arraylen;
  *   device_add, so add code like this:
  *   |* Reason: pointer property "NAME-OF-YOUR-PROP" *|
  *   DeviceClass *dc = DEVICE_CLASS(class);
- *   dc->cannot_instantiate_with_device_add_yet = true;
+ *   dc->user_creatable = false;
  *
  * - If the property may safely remain null, document it like this:
  *   |*
  *    * Note: pointer property "interrupt_vector" may remain null, thus
- *    * no need for dc->cannot_instantiate_with_device_add_yet = true;
+ *    * no need for dc->user_creatable = false;
  *    *|
  */
 #define DEFINE_PROP_PTR(_n, _s, _f)             \
hw/acpi/piix4.c +1 -1
index a553a7e110..f4fd5907b8 100644
@@ -700,7 +700,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX4 southbridge, needs to be wired up,
      * e.g. by mips_malta_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable = false;
     hc->plug = piix4_device_plug_cb;
     hc->unplug_request = piix4_device_unplug_request_cb;
hw/arm/spitz.c +1 -1
index fe2d5a764c..324626847c 100644
@@ -1076,7 +1076,7 @@ static void sl_nand_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_sl_nand_info;
     dc->props = sl_nand_properties;
     /* Reason: init() method uses drive_get() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sl_nand_info = {
hw/audio/marvell_88w8618.c +1 -1
index 511b004287..4f65f8c199 100644
@@ -292,7 +292,7 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &mv88w8618_audio_vmsd;
     dc->props = mv88w8618_audio_properties;
     /* Reason: pointer property "wm8750" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo mv88w8618_audio_info = {
hw/audio/pcspk.c +1 -1
index 798002277b..9b99358d87 100644
@@ -223,7 +223,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_spk;
     dc->props = pcspk_properties;
     /* Reason: realize sets global pcspk_state */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pcspk_info = {
hw/core/or-irq.c +1 -1
index 1485d5b285..f9d76c4641 100644
@@ -91,7 +91,7 @@ static void or_irq_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_or_irq;
 
     /* Reason: Needs to be wired up to work, e.g. see stm32f205_soc.c */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo or_irq_type_info = {
hw/core/qdev.c +1 -0
index 1e7fb33246..4132a8bee3 100644
@@ -1159,6 +1159,7 @@ static void device_class_init(ObjectClass *class, void *data)
      * should override it in their class_init()
      */
     dc->hotpluggable = true;
+    dc->user_creatable = true;
 }
 
 void device_reset(DeviceState *dev)
hw/core/register.c +1 -1
index dc335a79a9..da38ef3a54 100644
@@ -288,7 +288,7 @@ static void register_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     /* Reason: needs to be wired up to work */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo register_info = {
hw/dma/i8257.c +1 -1
index 8bd82e8bc8..bd23e893bf 100644
@@ -601,7 +601,7 @@ static void i8257_class_init(ObjectClass *klass, void *data)
     idc->schedule = i8257_dma_schedule;
     idc->register_channel = i8257_dma_register_channel;
     /* Reason: needs to be wired up by isa_bus_dma() to work */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo i8257_info = {
hw/dma/sparc32_dma.c +1 -1
index 9d545e412e..9c6bdc6295 100644
@@ -305,7 +305,7 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_dma;
     dc->props = sparc32_dma_properties;
     /* Reason: pointer property "iommu_opaque" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sparc32_dma_info = {
hw/gpio/omap_gpio.c +2 -2
index dabef4a119..1df394eb12 100644
@@ -773,7 +773,7 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_gpif_reset;
     dc->props = omap_gpio_properties;
     /* Reason: pointer property "clk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo omap_gpio_info = {
@@ -804,7 +804,7 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
     dc->reset = omap2_gpif_reset;
     dc->props = omap2_gpio_properties;
     /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo omap2_gpio_info = {
hw/i2c/omap_i2c.c +1 -1
index f7c92ea00c..f6e80bee25 100644
@@ -491,7 +491,7 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)
     dc->props = omap_i2c_properties;
     dc->reset = omap_i2c_reset;
     /* Reason: pointer properties "iclk", "fclk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap_i2c_realize;
 }
 
hw/i2c/smbus_eeprom.c +1 -1
index 5b7bd891bc..b13ec0fe7a 100644
@@ -123,7 +123,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
     sc->read_data = eeprom_read_data;
     dc->props = smbus_eeprom_properties;
     /* Reason: pointer property "data" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo smbus_eeprom_info = {
hw/i2c/smbus_ich9.c +1 -1
index 48fab22625..ea51e09186 100644
@@ -103,7 +103,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
      * Reason: part of ICH9 southbridge, needs to be wired up by
      * pc_q35_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
hw/i386/pc.c +1 -1
index d24388e05f..610050eb4f 100644
@@ -597,7 +597,7 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
      * wiring: its A20 output line needs to be wired up by
      * port92_init().
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo port92_info = {
hw/input/vmmouse.c +1 -1
index 6d15a887c6..4747da9a8d 100644
@@ -286,7 +286,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_vmmouse;
     dc->props = vmmouse_properties;
     /* Reason: pointer property "ps2_mouse" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo vmmouse_info = {
hw/intc/apic_common.c +1 -1
index c3829e31b5..1ef56f8d10 100644
@@ -501,7 +501,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
      * Reason: APIC and CPU need to be wired up by
      * x86_cpu_apic_create()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo apic_common_type = {
hw/intc/etraxfs_pic.c +1 -1
index 64a6f4b4ba..1bfde2f09e 100644
@@ -173,7 +173,7 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
     dc->props = etraxfs_pic_properties;
     /*
      * Note: pointer property "interrupt_vector" may remain null, thus
-     * no need for dc->cannot_instantiate_with_device_add_yet = true;
+     * no need for dc->user_creatable = false;
      */
 }
 
hw/intc/grlib_irqmp.c +1 -1
index ac7e63f38b..94659ee256 100644
@@ -360,7 +360,7 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
     dc->reset = grlib_irqmp_reset;
     dc->props = grlib_irqmp_properties;
     /* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = grlib_irqmp_realize;
 }
 
hw/intc/i8259_common.c +1 -1
index d9a5e8b217..c2fd563b5b 100644
@@ -144,7 +144,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
      * wiring of the slave to the master is hard-coded in device model
      * code.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pic_common_type = {
hw/intc/nios2_iic.c +1 -1
index 190b6fdbf3..016426f964 100644
@@ -80,7 +80,7 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = altera_iic_realize;
 }
 
hw/intc/omap_intc.c +2 -2
index 877be67971..ccdda89dab 100644
@@ -401,7 +401,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_inth_reset;
     dc->props = omap_intc_properties;
     /* Reason: pointer property "clk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap_intc_realize;
 }
 
@@ -656,7 +656,7 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_inth_reset;
     dc->props = omap2_intc_properties;
     /* Reason: pointer property "iclk", "fclk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap2_intc_realize;
 }
 
hw/isa/lpc_ich9.c +1 -1
index 59930dd9d0..cdc854a822 100644
@@ -810,7 +810,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
      * Reason: part of ICH9 southbridge, needs to be wired up by
      * pc_q35_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     hc->plug = ich9_pm_device_plug_cb;
     hc->unplug_request = ich9_pm_device_unplug_request_cb;
     hc->unplug = ich9_pm_device_unplug_cb;
hw/isa/piix4.c +1 -1
index 5500fcc4d6..f811eba59d 100644
@@ -123,7 +123,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX4 southbridge, needs to be wired up,
      * e.g. by mips_malta_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable = false;
 }
 
hw/isa/vt82c686.c +1 -1
index 41d5254f8e..50dc83df77 100644
@@ -494,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
      * Reason: part of VIA VT82C686 southbridge, needs to be wired up,
      * e.g. by mips_fulong2e_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo via_info = {
hw/mips/gt64xxx_pci.c +1 -1
index 4811843ab6..e8b2eef688 100644
@@ -1224,7 +1224,7 @@ static void gt64120_pci_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo gt64120_pci_info = {
hw/misc/vmport.c +1 -1
index be40930b8b..165500223f 100644
@@ -163,7 +163,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
 
     dc->realize = vmport_realizefn;
     /* Reason: realize sets global port_state */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo vmport_info = {
hw/net/dp8393x.c +1 -1
index efa33ad40a..b53fcaa8bc 100644
@@ -934,7 +934,7 @@ static void dp8393x_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_dp8393x;
     dc->props = dp8393x_properties;
     /* Reason: dma_mr property can't be set */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo dp8393x_info = {
hw/net/etraxfs_eth.c +1 -1
index efaa49faae..013c8d0a41 100644
@@ -630,7 +630,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
     k->init = fs_eth_init;
     dc->props = etraxfs_eth_properties;
     /* Reason: pointer properties "dma_out", "dma_in" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo etraxfs_eth_info = {
hw/net/lance.c +1 -1
index 573d724bcf..92b0c68274 100644
@@ -165,7 +165,7 @@ static void lance_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_lance;
     dc->props = lance_properties;
     /* Reason: pointer property "dma" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo lance_info = {
hw/pci-bridge/dec.c +1 -1
index 840c96198a..cca93620ac 100644
@@ -128,7 +128,7 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo dec_21154_pci_host_info = {
hw/pci-bridge/pci_expander_bridge.c +1 -1
index 6ac187fa32..ff59abf208 100644
@@ -150,7 +150,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data)
 
     dc->fw_name = "pci";
     /* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
     hc->root_bus_path = pxb_host_root_bus_path;
 }
hw/pci-host/apb.c +1 -1
index 653e711121..edc88f4c65 100644
@@ -810,7 +810,7 @@ static void pbm_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pbm_pci_host_info = {
hw/pci-host/bonito.c +1 -1
index 1999ece590..85a3bb0dd2 100644
@@ -825,7 +825,7 @@ static void bonito_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo bonito_info = {
hw/pci-host/gpex.c +1 -1
index 66055ee5cc..e2629ce70d 100644
@@ -136,7 +136,7 @@ static void gpex_root_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo gpex_root_info = {
hw/pci-host/grackle.c +1 -1
index 2c8acdaaca..2e281f6155 100644
@@ -134,7 +134,7 @@ static void grackle_pci_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo grackle_pci_info = {
hw/pci-host/piix.c +3 -3
index f9218aa952..81f3a9e211 100644
@@ -691,7 +691,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX3 southbridge, needs to be wired up by
      * pc_piix.c's pc_init1()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo piix3_pci_type_info = {
@@ -745,7 +745,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable   = false;
 }
 
@@ -874,7 +874,7 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     dc->fw_name = "pci";
     dc->props = i440fx_props;
     /* Reason: needs to be wired up by pc_init1 */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo i440fx_pcihost_info = {
hw/pci-host/ppce500.c +1 -1
index e502bc0505..becc0eeb76 100644
@@ -508,7 +508,7 @@ static void e500_host_bridge_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo e500_host_bridge_info = {
hw/pci-host/prep.c +1 -1
index 260a119a9e..900a6edfcf 100644
@@ -364,7 +364,7 @@ static void raven_class_init(ObjectClass *klass, void *data)
      * Reason: PCI-facing part of the host bridge, not usable without
      * the host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo raven_info = {
hw/pci-host/q35.c +2 -2
index 344f77b10c..cd5c49616e 100644
@@ -156,7 +156,7 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
     dc->realize = q35_host_realize;
     dc->props = mch_props;
     /* Reason: needs to be wired up by pc_q35_init */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
@@ -549,7 +549,7 @@ static void mch_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo mch_info = {
hw/pci-host/uninorth.c +4 -4
index df342ac3cb..6cf5e59f86 100644
@@ -366,7 +366,7 @@ static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_main_pci_host_info = {
@@ -390,7 +390,7 @@ static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo u3_agp_pci_host_info = {
@@ -414,7 +414,7 @@ static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_agp_pci_host_info = {
@@ -438,7 +438,7 @@ static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_internal_pci_host_info = {
hw/pci-host/versatile.c +1 -1
index 467cbb9cb8..cc51fc87a3 100644
@@ -479,7 +479,7 @@ static void versatile_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo versatile_pci_host_info = {
hw/pci-host/xilinx-pcie.c +1 -1
index 8b71e2d950..a968cea2af 100644
@@ -309,7 +309,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo xilinx_pcie_root_info = {
hw/ppc/ppc4xx_pci.c +1 -1
index dc19682970..6953f8b9ac 100644
@@ -351,7 +351,7 @@ static void ppc4xx_host_bridge_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo ppc4xx_host_bridge_info = {
hw/ppc/spapr_drc.c +1 -1
index a1cdc875b1..9fa5545991 100644
@@ -675,7 +675,7 @@ static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
     /*
      * Reason: it crashes FIXME find and document the real reason
      */
-    dk->cannot_instantiate_with_device_add_yet = true;
+    dk->user_creatable = false;
 }
 
 static const TypeInfo spapr_dr_connector_info = {
hw/s390x/s390-pci-bus.c +1 -1
index 69b0291e8a..1ec30c45ce 100644
@@ -867,7 +867,7 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->reset = s390_pcihost_reset;
     k->init = s390_pcihost_init;
     hc->plug = s390_pcihost_hot_plug;
hw/sd/milkymist-memcard.c +1 -1
index 1f2f0ed44a..4008c81002 100644
@@ -299,7 +299,7 @@ static void milkymist_memcard_class_init(ObjectClass *klass, void *data)
     dc->reset = milkymist_memcard_reset;
     dc->vmsd = &vmstate_milkymist_memcard;
     /* Reason: init() method uses drive_get_next() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo milkymist_memcard_info = {
hw/sd/pl181.c +1 -1
index 82c63a4fb5..55c8098ecd 100644
@@ -515,7 +515,7 @@ static void pl181_class_init(ObjectClass *klass, void *data)
     k->vmsd = &vmstate_pl181;
     k->reset = pl181_reset;
     /* Reason: init() method uses drive_get_next() */
-    k->cannot_instantiate_with_device_add_yet = true;
+    k->user_creatable = false;
     k->realize = pl181_realize;
 }
 
hw/sh4/sh_pci.c +1 -1
index 1747628f3d..38395c082b 100644
@@ -171,7 +171,7 @@ static void sh_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sh_pci_host_info = {
hw/timer/i8254_common.c +1 -1
index e18299a482..976d5200f1 100644
@@ -287,7 +287,7 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
      * wired to the HPET, and because of that, some wiring is always
      * done by board code.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pit_common_type = {
hw/timer/mc146818rtc.c +1 -1
index 4165450250..93de3e1cc5 100644
@@ -973,7 +973,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_rtc;
     dc->props = mc146818rtc_properties;
     /* Reason: needs to be wired up by rtc_init() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static void rtc_finalize(Object *obj)
monitor.c +1 -1
index be282ecb80..e06edec2bd 100644
@@ -3156,7 +3156,7 @@ void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
                                              TYPE_DEVICE);
         name = object_class_get_name(OBJECT_CLASS(dc));
 
-        if (!dc->cannot_instantiate_with_device_add_yet
+        if (dc->user_creatable
             && !strncmp(name, str, len)) {
             readline_add_completion(rs, name);
         }
qdev-monitor.c +3 -3
index 5f2fcdfc45..e4c180c6bc 100644
@@ -113,7 +113,7 @@ static void qdev_print_devinfo(DeviceClass *dc)
     if (dc->desc) {
         error_printf(", desc \"%s\"", dc->desc);
     }
-    if (dc->cannot_instantiate_with_device_add_yet) {
+    if (!dc->user_creatable) {
         error_printf(", no-user");
     }
     error_printf("\n");
@@ -155,7 +155,7 @@ static void qdev_print_devinfos(bool show_no_user)
                  ? !test_bit(i, dc->categories)
                  : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
                 || (!show_no_user
-                    && dc->cannot_instantiate_with_device_add_yet)) {
+                    && !dc->user_creatable)) {
                 continue;
             }
             if (!cat_printed) {
@@ -240,7 +240,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
     }
 
     dc = DEVICE_CLASS(oc);
-    if (dc->cannot_instantiate_with_device_add_yet ||
+    if (!dc->user_creatable ||
         (qdev_hotplug && !dc->hotpluggable)) {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
                    "pluggable device type");
qom/cpu.c +1 -1
index f02e9c0fae..73ae140d7e 100644
@@ -449,7 +449,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
      * Reason: CPUs still need special care by board code: wiring up
      * IRQs, adding reset handlers, halting non-first CPUs, ...
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo cpu_type_info = {
target/i386/cpu.c +1 -1
index 13c0985f11..4b3bfb3802 100644
@@ -4066,7 +4066,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->cpu_exec_enter = x86_cpu_exec_enter;
     cc->cpu_exec_exit = x86_cpu_exec_exit;
 
-    dc->cannot_instantiate_with_device_add_yet = false;
+    dc->user_creatable = true;
 }
 
 static const TypeInfo x86_cpu_type_info = {
Signature · 1 line
2.11.0.259.g40922b1
#11 lore raw

PATCH v2 3/21 xen-backend: Remove FIXME comment about user_creatable flag

In reply to Eduardo Habkost

xen-backend can be plugged/unplugged dynamically when using the Xen accelerator, so keep the user_creatable flag on the device class and remove the FIXME comment.

Cc Juergen Gross <[email protected]>,
Cc Peter Maydell <[email protected]>,
Cc Thomas Huth <[email protected]>
Cc Markus Armbruster <[email protected]>,
Cc Marcel Apfelbaum <[email protected]>,
Cc Laszlo Ersek <[email protected]>

---
Changes series v1 -> v2:
* (New patch added to series)

---
 hw/xen/xen_backend.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
hw/xen/xen_backend.c +1 -4
index b39dce4cab..56df27992f 100644
@@ -618,10 +618,7 @@ static void xendev_class_init(ObjectClass *klass, void *data)
 
     dc->props = xendev_properties;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
+    /* xen-backend devices can be plugged/unplugged dynamically */
     dc->user_creatable = true;
 }
 
Signature · 1 line
2.11.0.259.g40922b1
#12 lore raw

PATCH v2 4/21 iommu: Remove FIXME comment about user_creatable=true

In reply to Eduardo Habkost

amd-iommu and intel-iommu are really meant to be used with -device, so they need user_creatable=true. Remove the FIXME comment.

Cc Marcel Apfelbaum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/i386/amd_iommu.c   | 5 +----
 hw/i386/intel_iommu.c | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)
hw/i386/amd_iommu.c +1 -4
index 7b92c8c15a..efcc93cbfd 100644
@@ -1186,10 +1186,7 @@ static void amdvi_class_init(ObjectClass *klass, void* data)
     dc->vmsd = &vmstate_amdvi;
     dc->hotpluggable = false;
     dc_class->realize = amdvi_realize;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
+    /* Supported by the pc-q35-* machine types */
     dc->user_creatable = true;
 }
 
hw/i386/intel_iommu.c +1 -4
index d71d52c328..b14db306ef 100644
@@ -2601,10 +2601,7 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     x86_class->realize = vtd_realize;
     x86_class->int_remap = vtd_int_remap;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
+    /* Supported by the pc-q35-* machine types */
     dc->user_creatable = true;
 }
 
Signature · 1 line
2.11.0.259.g40922b1
#8 lore raw

PATCH v2 2/21 sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE

In reply to Eduardo Habkost

commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all sysbus devices appear on "-device help" and lack the "no-user" flag in "info qdm".

To fix this, we can set user_creatable=false by default on TYPE_SYS_BUS_DEVICE, but this requires setting user_creatable=true explicitly on the sysbus devices that actually work with -device.

Fortunately today we have just a few has_dynamic_sysbus=1
machines: virt, pc-q35-*, ppce500, and spapr.

virt, ppce500, and spapr have extra checks to ensure just a few device types can be instantiated:

* virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
* ppce500 supports only TYPE_ETSEC_COMMON.
* spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.

This patch sets user_creatable=true explicitly on those 4 device classes.

Now, the more complex cases:

pc-q35-*: q35 has no sysbus device whitelist yet (which is a separate bug). We are in the process of fixing it and building a sysbus whitelist on q35, but in the meantime we can fix the "-device help" and "info qdm" bugs mentioned above. Also, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist.

xen: We also have a hack at xen_set_dynamic_sysbus(), that sets has_dynamic_sysbus=true at runtime when using the Xen accelerator. This hack is only used to allow xen-backend devices to be dynamically plugged/unplugged.

This means today we can use -device with the following 22 device types, that are the ones compiled into the qemu-system-x86_64 and qemu-system-i386 binaries:

* allwinner-ahci
* amd-iommu
* cfi.pflash01
* esp
* fw_cfg_io
* fw_cfg_mem
* generic-sdhci
* hpet
* intel-iommu
* ioapic
* isabus-bridge
* kvmclock
* kvm-ioapic
* kvmvapic
* SUNW,fdtwo
* sysbus-ahci
* sysbus-fdc
* sysbus-ohci
* unimplemented-device
* virtio-mmio
* xen-backend
* xen-sysdev

This patch adds user_creatable=true explicitly to those devices, temporarily, just to keep 100% compatibility with existing behavior of q35. Subsequent patches will remove user_creatable=true from the devices that are really not meant to user-creatable on any machine, and remove the FIXME comment from the ones that are really supposed to be user-creatable. This is being done in separate patches because we still don't have an obvious list of devices that will be whitelisted by q35, and I would like to get each device reviewed individually.

Cc Alexander Graf <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Alistair Francis <[email protected]>
Cc Beniamino Galvani <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Cornelia Huck <[email protected]>
Cc David Gibson <[email protected]>
Cc "Edgar E. Iglesias" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Frank Blaschka <[email protected]>
Cc Gabriel L. Somlo <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jason Wang <[email protected]>
Cc John Snow <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Max Reitz <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Prasad J Pandit <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Rob Herring <[email protected]>
Cc Shannon Zhao <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Yi Min Zhao <[email protected]>

---
Changes v1 -> v2:
* Rewrite commit message: don't pretend we are actually fixing the q35 issue. We're just fixing "info qdm" and "-device help". Making it easier to fix q35 is just a nice side-effect.
* Rewrite FIXME comments to make it clear that we just have user_creatable=true because we don't know yet if the device should be in the q35 whitelist

---
 hw/block/fdc.c           | 10 ++++++++++
 hw/block/pflash_cfi01.c  |  5 +++++
 hw/core/sysbus.c         | 11 +++++++++++
 hw/i386/amd_iommu.c      |  5 +++++
 hw/i386/intel_iommu.c    |  5 +++++
 hw/i386/kvm/clock.c      |  5 +++++
 hw/i386/kvm/ioapic.c     |  5 +++++
 hw/i386/kvmvapic.c       |  5 +++++
 hw/ide/ahci.c            | 10 ++++++++++
 hw/intc/ioapic.c         |  5 +++++
 hw/isa/isa-bus.c         |  5 +++++
 hw/misc/unimp.c          |  5 +++++
 hw/net/fsl_etsec/etsec.c |  2 ++
 hw/nvram/fw_cfg.c        | 10 ++++++++++
 hw/ppc/spapr_pci.c       |  2 ++
 hw/scsi/esp.c            |  5 +++++
 hw/sd/sdhci.c            |  5 +++++
 hw/timer/hpet.c          |  5 +++++
 hw/usb/hcd-ohci.c        |  5 +++++
 hw/vfio/amd-xgbe.c       |  2 ++
 hw/vfio/calxeda-xgmac.c  |  2 ++
 hw/virtio/virtio-mmio.c  |  5 +++++
 hw/xen/xen_backend.c     | 10 ++++++++++
 23 files changed, 129 insertions(+)
hw/block/fdc.c +10 -0
index a328693d15..3d05565628 100644
@@ -2880,6 +2880,11 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sysbus_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_fdc_info = {
@@ -2906,6 +2911,11 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sun4m_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sun4m_fdc_info = {
hw/block/pflash_cfi01.c +5 -0
index 594d4cf6fe..ef71956433 100644
@@ -927,6 +927,11 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
     dc->props = pflash_cfi01_properties;
     dc->vmsd = &vmstate_pflash;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 
hw/core/sysbus.c +11 -0
index c0f560b289..6a2eec8dd0 100644
@@ -326,6 +326,17 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = sysbus_device_init;
     k->bus_type = TYPE_SYSTEM_BUS;
+    /*
+     * device_add plugs devices into suitable bus.  For "real" buses,
+     * that actually connects the device.  For sysbus, the connections
+     * need to be made separately, and device_add can't do that.  The
+     * device would be left unconnected, and will probably not work
+     *
+     * However, a few machines and a few devices can handle a few sysbus
+     * devices. In this case, the device subclass needs to override
+     * it and set user_creatable=true.
+     */
+    k->user_creatable = false;
 }
 
 static const TypeInfo sysbus_device_type_info = {
hw/i386/amd_iommu.c +5 -0
index f86a40aa30..7b92c8c15a 100644
@@ -1186,6 +1186,11 @@ static void amdvi_class_init(ObjectClass *klass, void* data)
     dc->vmsd = &vmstate_amdvi;
     dc->hotpluggable = false;
     dc_class->realize = amdvi_realize;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo amdvi = {
hw/i386/intel_iommu.c +5 -0
index 22d8226e43..d71d52c328 100644
@@ -2601,6 +2601,11 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     x86_class->realize = vtd_realize;
     x86_class->int_remap = vtd_int_remap;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vtd_info = {
hw/i386/kvm/clock.c +5 -0
index 13eca374cd..7665bef999 100644
@@ -286,6 +286,11 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
     dc->realize = kvmclock_realize;
     dc->vmsd = &kvmclock_vmsd;
     dc->props = kvmclock_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo kvmclock_info = {
hw/i386/kvm/ioapic.c +5 -0
index 98ca480792..348c405180 100644
@@ -167,6 +167,11 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = kvm_ioapic_put;
     dc->reset    = kvm_ioapic_reset;
     dc->props    = kvm_ioapic_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo kvm_ioapic_info = {
hw/i386/kvmvapic.c +5 -0
index 82a49556af..45f6267c93 100644
@@ -856,6 +856,11 @@ static void vapic_class_init(ObjectClass *klass, void *data)
     dc->reset   = vapic_reset;
     dc->vmsd    = &vmstate_vapic;
     dc->realize = vapic_realize;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vapic_type = {
hw/ide/ahci.c +10 -0
index f60826d6e0..7f10cda354 100644
@@ -1721,6 +1721,11 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
     dc->props = sysbus_ahci_properties;
     dc->reset = sysbus_ahci_reset;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_ahci_info = {
@@ -1815,6 +1820,11 @@ static void allwinner_ahci_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_allwinner_ahci;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo allwinner_ahci_info = {
hw/intc/ioapic.c +5 -0
index 37c4386ae3..f9e4f77def 100644
@@ -448,6 +448,11 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = ioapic_update_kvm_routes;
     dc->reset = ioapic_reset_common;
     dc->props = ioapic_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo ioapic_info = {
hw/isa/isa-bus.c +5 -0
index 348e0eab9d..ad4ac3b4f6 100644
@@ -221,6 +221,11 @@ static void isabus_bridge_class_init(ObjectClass *klass, void *data)
 
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "isa";
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo isabus_bridge_info = {
hw/misc/unimp.c +5 -0
index bcbb585888..e446c1d652 100644
@@ -90,6 +90,11 @@ static void unimp_class_init(ObjectClass *klass, void *data)
 
     dc->realize = unimp_realize;
     dc->props = unimp_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo unimp_info = {
hw/net/fsl_etsec/etsec.c +2 -0
index aa2b0d5a85..9da1932970 100644
@@ -416,6 +416,8 @@ static void etsec_class_init(ObjectClass *klass, void *data)
     dc->realize = etsec_realize;
     dc->reset = etsec_reset;
     dc->props = etsec_properties;
+    /* Supported by ppce500 machine */
+    dc->user_creatable = true;
 }
 
 static TypeInfo etsec_info = {
hw/nvram/fw_cfg.c +10 -0
index 316fca9bc1..7993aea792 100644
@@ -1101,6 +1101,11 @@ static void fw_cfg_io_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_io_realize;
     dc->props = fw_cfg_io_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_io_info = {
@@ -1167,6 +1172,11 @@ static void fw_cfg_mem_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_mem_realize;
     dc->props = fw_cfg_mem_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_mem_info = {
hw/ppc/spapr_pci.c +2 -0
index 98c52e411f..cae2b31230 100644
@@ -1990,6 +1990,8 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data)
     dc->props = spapr_phb_properties;
     dc->reset = spapr_phb_reset;
     dc->vmsd = &vmstate_spapr_pci;
+    /* Supported by TYPE_SPAPR_MACHINE */
+    dc->user_creatable = true;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     hp->plug = spapr_phb_hot_plug_child;
     hp->unplug = spapr_phb_hot_unplug_child;
hw/scsi/esp.c +5 -0
index eee831efeb..7bdc1e1b99 100644
@@ -728,6 +728,11 @@ static void sysbus_esp_class_init(ObjectClass *klass, void *data)
     dc->reset = sysbus_esp_hard_reset;
     dc->vmsd = &vmstate_sysbus_esp_scsi;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_esp_info = {
hw/sd/sdhci.c +5 -0
index 6d6a791ee9..dbf61fccb8 100644
@@ -1360,6 +1360,11 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->props = sdhci_sysbus_properties;
     dc->realize = sdhci_sysbus_realize;
     dc->reset = sdhci_poweron_reset;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sdhci_sysbus_info = {
hw/timer/hpet.c +5 -0
index a2c18b30c3..4dcbd5bb3d 100644
@@ -771,6 +771,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     dc->reset = hpet_reset;
     dc->vmsd = &vmstate_hpet;
     dc->props = hpet_device_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo hpet_device_info = {
hw/usb/hcd-ohci.c +5 -0
index 3ada35e954..18b31022a7 100644
@@ -2159,6 +2159,11 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->desc = "OHCI USB Controller";
     dc->props = ohci_sysbus_properties;
     dc->reset = usb_ohci_reset_sysbus;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo ohci_sysbus_info = {
hw/vfio/amd-xgbe.c +2 -0
index 2c60310cf9..fab196cebf 100644
@@ -38,6 +38,8 @@ static void vfio_amd_xgbe_class_init(ObjectClass *klass, void *data)
     dc->realize = amd_xgbe_realize;
     dc->desc = "VFIO AMD XGBE";
     dc->vmsd = &vfio_platform_amd_xgbe_vmstate;
+    /* Supported by TYPE_VIRT_MACHINE */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vfio_amd_xgbe_dev_info = {
hw/vfio/calxeda-xgmac.c +2 -0
index bb15d588e5..7bb17af7ad 100644
@@ -38,6 +38,8 @@ static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)
     dc->realize = calxeda_xgmac_realize;
     dc->desc = "VFIO Calxeda XGMAC";
     dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;
+    /* Supported by TYPE_VIRT_MACHINE */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vfio_calxeda_xgmac_dev_info = {
hw/virtio/virtio-mmio.c +5 -0
index 5807aa87fe..6491a771ff 100644
@@ -450,6 +450,11 @@ static void virtio_mmio_class_init(ObjectClass *klass, void *data)
     dc->reset = virtio_mmio_reset;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     dc->props = virtio_mmio_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo virtio_mmio_info = {
hw/xen/xen_backend.c +10 -0
index 6c21c37d68..b39dce4cab 100644
@@ -618,6 +618,11 @@ static void xendev_class_init(ObjectClass *klass, void *data)
 
     dc->props = xendev_properties;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo xendev_type_info = {
@@ -661,6 +666,11 @@ static void xen_sysdev_class_init(ObjectClass *klass, void *data)
     k->init = xen_sysdev_init;
     dc->props = xen_sysdev_properties;
     dc->bus_type = TYPE_XENSYSBUS;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo xensysdev_info = {
Signature · 1 line
2.11.0.259.g40922b1
#14 lore raw

PATCH v2 5/21 fdc: Remove user_creatable flag from sysbus-fdc & SUNW, fdtwo

In reply to Eduardo Habkost

sysbus-fdc and SUNW,fdtwo devices need IRQs to be wired and mmio to be mapped, and can't be used with -device. Unset user_creatable on their device classes.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/block/fdc.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/block/fdc.c +0 -10
index 3d05565628..a328693d15 100644
@@ -2880,11 +2880,6 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sysbus_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_fdc_info = {
@@ -2911,11 +2906,6 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sun4m_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sun4m_fdc_info = {
Signature · 1 line
2.11.0.259.g40922b1
#16 lore raw

PATCH v2 6/21 pflash_cfi01: Remove user_creatable flag

In reply to Eduardo Habkost

TYPE_CFI_PFLASH01 devices need to be mapped by pflash_cfi01_register() (or equivalent) and can't be used with -device. Remove user_creatable from the device class.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/block/pflash_cfi01.c | 5 -----
 1 file changed, 5 deletions(-)
hw/block/pflash_cfi01.c +0 -5
index ef71956433..594d4cf6fe 100644
@@ -927,11 +927,6 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
     dc->props = pflash_cfi01_properties;
     dc->vmsd = &vmstate_pflash;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 
Signature · 1 line
2.11.0.259.g40922b1
#17 lore raw

PATCH v2 7/21 kvmclock: Remove user_creatable flag

In reply to Eduardo Habkost

kvmclock should be used by guests only when the appropriate CPUID feature flags are set on the VCPU, and it is automatically created by kvmclock_create() when those feature flags are set. This means creating a kvmclock device using -device is useless. Remove user_creatable from its device class.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/i386/kvm/clock.c | 5 -----
 1 file changed, 5 deletions(-)
hw/i386/kvm/clock.c +0 -5
index 7665bef999..13eca374cd 100644
@@ -286,11 +286,6 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
     dc->realize = kvmclock_realize;
     dc->vmsd = &kvmclock_vmsd;
     dc->props = kvmclock_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo kvmclock_info = {
Signature · 1 line
2.11.0.259.g40922b1
#19 lore raw

PATCH v2 8/21 ioapic: Remove user_creatable flag

In reply to Eduardo Habkost

An ioapic device is already created by the q35 initialization code, and using "-device ioapic" or "-device kvm-ioapic" will always fail with "Only 1 ioapics allowed". Remove the user_creatable flag from the ioapic device classes.

Cc Igor Mammedov <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Eduardo Habkost <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/i386/kvm/ioapic.c | 5 -----
 hw/intc/ioapic.c     | 5 -----
 2 files changed, 10 deletions(-)
hw/i386/kvm/ioapic.c +0 -5
index 348c405180..98ca480792 100644
@@ -167,11 +167,6 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = kvm_ioapic_put;
     dc->reset    = kvm_ioapic_reset;
     dc->props    = kvm_ioapic_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo kvm_ioapic_info = {
hw/intc/ioapic.c +0 -5
index f9e4f77def..37c4386ae3 100644
@@ -448,11 +448,6 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = ioapic_update_kvm_routes;
     dc->reset = ioapic_reset_common;
     dc->props = ioapic_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo ioapic_info = {
Signature · 1 line
2.11.0.259.g40922b1
#20 lore raw

PATCH v2 9/21 kvmvapic: Remove user_creatable flag

In reply to Eduardo Habkost

The kvmvapic device is only usable when created by apic_common_realize(), not using -device. Remove the user_creatable flag from the device class.

Cc Igor Mammedov <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/i386/kvmvapic.c | 5 -----
 1 file changed, 5 deletions(-)
hw/i386/kvmvapic.c +0 -5
index 45f6267c93..82a49556af 100644
@@ -856,11 +856,6 @@ static void vapic_class_init(ObjectClass *klass, void *data)
     dc->reset   = vapic_reset;
     dc->vmsd    = &vmstate_vapic;
     dc->realize = vapic_realize;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo vapic_type = {
Signature · 1 line
2.11.0.259.g40922b1
#23 lore raw

PATCH v2 12/21 isabus-bridge: Remove user_creatable flag

In reply to Eduardo Habkost

isabus-bridge needs to be created by isa_bus_new(), and won't work with -device, as it won't create the TYPE_ISA_BUS bus itself. Remove the user_creatable flag from the device class.

Cc Marcel Apfelbaum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/isa/isa-bus.c | 5 -----
 1 file changed, 5 deletions(-)
hw/isa/isa-bus.c +0 -5
index ad4ac3b4f6..348e0eab9d 100644
@@ -221,11 +221,6 @@ static void isabus_bridge_class_init(ObjectClass *klass, void *data)
 
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "isa";
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo isabus_bridge_info = {
Signature · 1 line
2.11.0.259.g40922b1
#21 lore raw

PATCH v2 10/21 sysbus-ahci: Remove user_creatable flag

In reply to Eduardo Habkost

The sysbus-ahci devices are supposed to be created and wired by code from other devices, like calxeda_init() and xlnx_zynqmp_realize(), and won't work with -device. Remove the user_creatable flag from the device class.

Cc John Snow <[email protected]>
Cc Rob Herring <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Alistair Francis <[email protected]>
Cc "Edgar E. Iglesias" <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/ide/ahci.c | 5 -----
 1 file changed, 5 deletions(-)
hw/ide/ahci.c +0 -5
index 7f10cda354..2ea1a282ef 100644
@@ -1721,11 +1721,6 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
     dc->props = sysbus_ahci_properties;
     dc->reset = sysbus_ahci_reset;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_ahci_info = {
Signature · 1 line
2.11.0.259.g40922b1
#22 lore raw

PATCH v2 11/21 allwinner-ahci: Remove user_creatable flag

In reply to Eduardo Habkost

allwinner-ahci needs its IRQ to be connected and mmio to be mapped (this is done by the alwinner-a10 device realize method), and won't work with -device. Remove the user_creatable flag from the device class.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/ide/ahci.c | 5 -----
 1 file changed, 5 deletions(-)
hw/ide/ahci.c +0 -5
index 2ea1a282ef..f60826d6e0 100644
@@ -1815,11 +1815,6 @@ static void allwinner_ahci_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_allwinner_ahci;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo allwinner_ahci_info = {
Signature · 1 line
2.11.0.259.g40922b1
#24 lore raw

PATCH v2 13/21 unimplemented-device: Remove user_creatable flag

In reply to Eduardo Habkost

unimplemented-device needs to be created and mapped using create_unimplemented_device() (or equivalent code), and won't work with -device. Remove the user_creatable flag from the device class.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/misc/unimp.c | 5 -----
 1 file changed, 5 deletions(-)
hw/misc/unimp.c +0 -5
index e446c1d652..bcbb585888 100644
@@ -90,11 +90,6 @@ static void unimp_class_init(ObjectClass *klass, void *data)
 
     dc->realize = unimp_realize;
     dc->props = unimp_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo unimp_info = {
Signature · 1 line
2.11.0.259.g40922b1
#25 lore raw

PATCH v2 14/21 fw_cfg: Remove user_creatable flag

In reply to Eduardo Habkost

fw_cfg won't work with -device, as:
* fw_cfg_init1() won't get called for the device;
* The device won't appear at /machine/fw_cfg, and won't work with the -fw_cfg command-line option.

Remove the user_creatable flag from the device class.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Gabriel L. Somlo <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/nvram/fw_cfg.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/nvram/fw_cfg.c +0 -10
index 7993aea792..316fca9bc1 100644
@@ -1101,11 +1101,6 @@ static void fw_cfg_io_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_io_realize;
     dc->props = fw_cfg_io_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_io_info = {
@@ -1172,11 +1167,6 @@ static void fw_cfg_mem_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_mem_realize;
     dc->props = fw_cfg_mem_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_mem_info = {
Signature · 1 line
2.11.0.259.g40922b1
#26 lore raw

PATCH v2 15/21 esp: Remove user_creatable flag

In reply to Eduardo Habkost

esp devices aren't going to work with -device, as they need IRQs to be connected and mmio to be mapped (this is done by esp_init()). Remove the user_creatable flag from the device class.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/scsi/esp.c | 5 -----
 1 file changed, 5 deletions(-)
hw/scsi/esp.c +0 -5
index 7bdc1e1b99..eee831efeb 100644
@@ -728,11 +728,6 @@ static void sysbus_esp_class_init(ObjectClass *klass, void *data)
     dc->reset = sysbus_esp_hard_reset;
     dc->vmsd = &vmstate_sysbus_esp_scsi;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_esp_info = {
Signature · 1 line
2.11.0.259.g40922b1
#27 lore raw

PATCH v2 16/21 generic-sdhci: Remove user_creatable flag

In reply to Eduardo Habkost

generic-sdhci needs to be wired by other devices' code, so it can't be used with -device. Remove the user_creatable flag from the device class.

Cc Peter Maydell <[email protected]>
Cc "Edgar E. Iglesias" <[email protected]>
Cc David Gibson <[email protected]>
Cc Alexander Graf <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Prasad J Pandit <[email protected]>
Cc Alistair Francis <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/sd/sdhci.c | 5 -----
 1 file changed, 5 deletions(-)
hw/sd/sdhci.c +0 -5
index dbf61fccb8..6d6a791ee9 100644
@@ -1360,11 +1360,6 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->props = sdhci_sysbus_properties;
     dc->realize = sdhci_sysbus_realize;
     dc->reset = sdhci_poweron_reset;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sdhci_sysbus_info = {
Signature · 1 line
2.11.0.259.g40922b1
#28 lore raw

PATCH v2 17/21 hpet: Remove user_creatable flag

In reply to Eduardo Habkost

hpet needs to be mapped and wired by the board code and won't work with -device. Remove the user_creatable flag from the device class.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/timer/hpet.c | 5 -----
 1 file changed, 5 deletions(-)
hw/timer/hpet.c +0 -5
index 4dcbd5bb3d..a2c18b30c3 100644
@@ -771,11 +771,6 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     dc->reset = hpet_reset;
     dc->vmsd = &vmstate_hpet;
     dc->props = hpet_device_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo hpet_device_info = {
Signature · 1 line
2.11.0.259.g40922b1
#29 lore raw

PATCH v2 18/21 sysbus-ohci: Remove user_creatable flag

In reply to Eduardo Habkost

sysbus-ohci needs to be mapped and wired by device or board code, and won't work with -device. Remove the user_creatable flag from the device class.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/usb/hcd-ohci.c | 5 -----
 1 file changed, 5 deletions(-)
hw/usb/hcd-ohci.c +0 -5
index 18b31022a7..3ada35e954 100644
@@ -2159,11 +2159,6 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->desc = "OHCI USB Controller";
     dc->props = ohci_sysbus_properties;
     dc->reset = usb_ohci_reset_sysbus;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo ohci_sysbus_info = {
Signature · 1 line
2.11.0.259.g40922b1
#30 lore raw

PATCH v2 19/21 virtio-mmio: Remove user_creatable flag

In reply to Eduardo Habkost

virtio-mmio needs to be wired and mapped by other device or board code, and won't work with -device. Remove the user_creatable flag from the device class.

Cc Peter Maydell <[email protected]>
Cc Shannon Zhao <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/virtio/virtio-mmio.c | 5 -----
 1 file changed, 5 deletions(-)
hw/virtio/virtio-mmio.c +0 -5
index 6491a771ff..5807aa87fe 100644
@@ -450,11 +450,6 @@ static void virtio_mmio_class_init(ObjectClass *klass, void *data)
     dc->reset = virtio_mmio_reset;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     dc->props = virtio_mmio_properties;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo virtio_mmio_info = {
Signature · 1 line
2.11.0.259.g40922b1
#31 lore raw

PATCH v2 20/21 xen-sysdev: Remove user_creatable flag

In reply to Eduardo Habkost

TYPE_XENSYSDEV is only used internally by xen_be_init(), and is not supposed to be plugged/unplugged dynamically. Remove the user_creatable flag from the device class.

Cc Juergen Gross <[email protected]>,
Cc Peter Maydell <[email protected]>,
Cc Thomas Huth <[email protected]>
Cc Markus Armbruster <[email protected]>,
Cc Marcel Apfelbaum <[email protected]>,
Cc Laszlo Ersek <[email protected]>

---
Changes series v1 -> v2:
* (New patch added to series)

---
 hw/xen/xen_backend.c | 5 -----
 1 file changed, 5 deletions(-)
hw/xen/xen_backend.c +0 -5
index 56df27992f..e48c5f48fc 100644
@@ -663,11 +663,6 @@ static void xen_sysdev_class_init(ObjectClass *klass, void *data)
     k->init = xen_sysdev_init;
     dc->props = xen_sysdev_properties;
     dc->bus_type = TYPE_XENSYSBUS;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo xensysdev_info = {
Signature · 1 line
2.11.0.259.g40922b1
#32 lore raw

PATCH v2 21/21 s390-pcibus: No need to set user_creatable=false explicitly

In reply to Eduardo Habkost

TYPE_S390_PCI_HOST_BRIDGE is a subclass of TYPE_PCI_HOST_BRIDGE, which is a subclass of TYPE_SYS_BUS_DEVICE. TYPE_SYS_BUS_DEVICE already sets user_creatable=false, so we don't require an explicit user_creatable=false assignment in s390_pcihost_class_init().

Cc Alexander Graf <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Cornelia Huck <[email protected]>
Cc Frank Blaschka <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Yi Min Zhao <[email protected]>

---
Changes series v1 -> v2:
* Previous patch was:
"s390: Add FIXME for unexplained user_creatable=false line", but now we know we can remove the explicit user_creatable=false assignment

---
 hw/s390x/s390-pci-bus.c | 1 -
 1 file changed, 1 deletion(-)
hw/s390x/s390-pci-bus.c +0 -1
index 1ec30c45ce..973893df07 100644
@@ -867,7 +867,6 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    dc->user_creatable = false;
     dc->reset = s390_pcihost_reset;
     k->init = s390_pcihost_init;
     hc->plug = s390_pcihost_hot_plug;
Signature · 1 line
2.11.0.259.g40922b1
Acked-by on v2 21/21
#33 lore raw

Re: [Qemu-devel] [PATCH v2 21/21] s390-pcibus: No need to set user_creatable=false explicitly

Quoted 34 lines · On Tue, 4 Apr 2017 17:24:29 -0300 Eduardo Habkost <[email protected]> wrote:

TYPE_S390_PCI_HOST_BRIDGE is a subclass of TYPE_PCI_HOST_BRIDGE, which is a subclass of TYPE_SYS_BUS_DEVICE. TYPE_SYS_BUS_DEVICE already sets user_creatable=false, so we don't require an explicit user_creatable=false assignment in s390_pcihost_class_init().

Cc Alexander Graf <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Cornelia Huck <[email protected]>
Cc Frank Blaschka <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Yi Min Zhao <[email protected]>

---
Changes series v1 -> v2:
* Previous patch was:
"s390: Add FIXME for unexplained user_creatable=false line", but now we know we can remove the explicit user_creatable=false assignment

---
 hw/s390x/s390-pci-bus.c | 1 -
 1 file changed, 1 deletion(-)
hw/s390x/s390-pci-bus.c +0 -0
index 1ec30c45ce..973893df07 100644

hw/s390x/s390-pci-bus.c static void s390_pcihost_class_init(ObjectClass *klass, void *data) · line 872

Quoted 7 lines
hw/s390x/s390-pci-bus.c +0 -1
@@ -867,7 +867,6 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    dc->user_creatable = false;
     dc->reset = s390_pcihost_reset;
     k->init = s390_pcihost_init;
     hc->plug = s390_pcihost_hot_plug;
#2 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

In reply to Eduardo Habkost
Quoted 4 lines · Eduardo Habkost

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,

Quoted 10 lines

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.

Quoted 10 lines

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?

Quoted 7 lines
  |
  -DC->cannot_instantiate_with_device_add_yet = true;
  +DC->user_creatable = false;
  )

  @@
  typedef ObjectClass;
Quoted 8 lines
  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?

Quoted 12 lines
   ...
   }
  @@
  @@
   struct DeviceClass {
   ...
  -bool cannot_instantiate_with_device_add_yet;
  +bool user_creatable;
   ...
  }
Quoted 11 lines

@@
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,
Marcel

Quoted 906 lines
Cc Markus Armbruster <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Thomas Huth <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 include/hw/qdev-core.h              | 10 +++++-----
 include/hw/qdev-properties.h        |  4 ++--
 hw/acpi/piix4.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/audio/marvell_88w8618.c          |  2 +-
 hw/audio/pcspk.c                    |  2 +-
 hw/core/or-irq.c                    |  2 +-
 hw/core/qdev.c                      |  1 +
 hw/core/register.c                  |  2 +-
 hw/dma/i8257.c                      |  2 +-
 hw/dma/sparc32_dma.c                |  2 +-
 hw/gpio/omap_gpio.c                 |  4 ++--
 hw/i2c/omap_i2c.c                   |  2 +-
 hw/i2c/smbus_eeprom.c               |  2 +-
 hw/i2c/smbus_ich9.c                 |  2 +-
 hw/i386/pc.c                        |  2 +-
 hw/input/vmmouse.c                  |  2 +-
 hw/intc/apic_common.c               |  2 +-
 hw/intc/etraxfs_pic.c               |  2 +-
 hw/intc/grlib_irqmp.c               |  2 +-
 hw/intc/i8259_common.c              |  2 +-
 hw/intc/nios2_iic.c                 |  2 +-
 hw/intc/omap_intc.c                 |  4 ++--
 hw/isa/lpc_ich9.c                   |  2 +-
 hw/isa/piix4.c                      |  2 +-
 hw/isa/vt82c686.c                   |  2 +-
 hw/mips/gt64xxx_pci.c               |  2 +-
 hw/misc/vmport.c                    |  2 +-
 hw/net/dp8393x.c                    |  2 +-
 hw/net/etraxfs_eth.c                |  2 +-
 hw/net/lance.c                      |  2 +-
 hw/pci-bridge/dec.c                 |  2 +-
 hw/pci-bridge/pci_expander_bridge.c |  2 +-
 hw/pci-host/apb.c                   |  2 +-
 hw/pci-host/bonito.c                |  2 +-
 hw/pci-host/gpex.c                  |  2 +-
 hw/pci-host/grackle.c               |  2 +-
 hw/pci-host/piix.c                  |  6 +++---
 hw/pci-host/ppce500.c               |  2 +-
 hw/pci-host/prep.c                  |  2 +-
 hw/pci-host/q35.c                   |  4 ++--
 hw/pci-host/uninorth.c              |  8 ++++----
 hw/pci-host/versatile.c             |  2 +-
 hw/pci-host/xilinx-pcie.c           |  2 +-
 hw/ppc/ppc4xx_pci.c                 |  2 +-
 hw/ppc/spapr_drc.c                  |  2 +-
 hw/s390x/s390-pci-bus.c             |  2 +-
 hw/sd/milkymist-memcard.c           |  2 +-
 hw/sd/pl181.c                       |  2 +-
 hw/sh4/sh_pci.c                     |  2 +-
 hw/timer/i8254_common.c             |  2 +-
 hw/timer/mc146818rtc.c              |  2 +-
 monitor.c                           |  2 +-
 qdev-monitor.c                      |  6 +++---
 qom/cpu.c                           |  2 +-
 target/i386/cpu.c                   |  2 +-
 56 files changed, 71 insertions(+), 70 deletions(-)
include/hw/qdev-core.h +5 -5
index b44b476765..bc4e6f0486 100644
@@ -103,16 +103,16 @@ typedef struct DeviceClass {
     Property *props;
 
     /*
-     * Shall we hide this device model from -device / device_add?
+     * Can this device be instantiated with -device / device_add?
      * All devices should support instantiation with device_add, and
      * this flag should not exist.  But we're not there, yet.  Some
      * devices fail to instantiate with cryptic error messages.
      * Others instantiate, but don't work.  Exposing users to such
-     * behavior would be cruel; this flag serves to protect them.  It
-     * should never be set without a comment explaining why it is set.
-     * TODO remove once we're there
+     * behavior would be cruel; clearing this flag will protect them.
+     * It should never be cleared without a comment explaining why it
+     * is cleared.
      */
-    bool cannot_instantiate_with_device_add_yet;
+    bool user_creatable;
     /*
      * Does this device model survive object_unref(object_new(TNAME))?
      * All device models should, and this flag shouldn't exist.  Some
include/hw/qdev-properties.h +2 -2
index 7ac315331a..5c6e13b993 100644
@@ -134,12 +134,12 @@ extern PropertyInfo qdev_prop_arraylen;
  *   device_add, so add code like this:
  *   |* Reason: pointer property "NAME-OF-YOUR-PROP" *|
  *   DeviceClass *dc = DEVICE_CLASS(class);
- *   dc->cannot_instantiate_with_device_add_yet = true;
+ *   dc->user_creatable = false;
  *
  * - If the property may safely remain null, document it like this:
  *   |*
  *    * Note: pointer property "interrupt_vector" may remain null, thus
- *    * no need for dc->cannot_instantiate_with_device_add_yet = true;
+ *    * no need for dc->user_creatable = false;
  *    *|
  */
 #define DEFINE_PROP_PTR(_n, _s, _f)             \
hw/acpi/piix4.c +1 -1
index a553a7e110..f4fd5907b8 100644
@@ -700,7 +700,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX4 southbridge, needs to be wired up,
      * e.g. by mips_malta_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable = false;
     hc->plug = piix4_device_plug_cb;
     hc->unplug_request = piix4_device_unplug_request_cb;
hw/arm/spitz.c +1 -1
index fe2d5a764c..324626847c 100644
@@ -1076,7 +1076,7 @@ static void sl_nand_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_sl_nand_info;
     dc->props = sl_nand_properties;
     /* Reason: init() method uses drive_get() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sl_nand_info = {
hw/audio/marvell_88w8618.c +1 -1
index 511b004287..4f65f8c199 100644
@@ -292,7 +292,7 @@ static void mv88w8618_audio_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &mv88w8618_audio_vmsd;
     dc->props = mv88w8618_audio_properties;
     /* Reason: pointer property "wm8750" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo mv88w8618_audio_info = {
hw/audio/pcspk.c +1 -1
index 798002277b..9b99358d87 100644
@@ -223,7 +223,7 @@ static void pcspk_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_spk;
     dc->props = pcspk_properties;
     /* Reason: realize sets global pcspk_state */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pcspk_info = {
hw/core/or-irq.c +1 -1
index 1485d5b285..f9d76c4641 100644
@@ -91,7 +91,7 @@ static void or_irq_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_or_irq;
 
     /* Reason: Needs to be wired up to work, e.g. see stm32f205_soc.c */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo or_irq_type_info = {
hw/core/qdev.c +1 -0
index 1e7fb33246..4132a8bee3 100644
@@ -1159,6 +1159,7 @@ static void device_class_init(ObjectClass *class, void *data)
      * should override it in their class_init()
      */
     dc->hotpluggable = true;
+    dc->user_creatable = true;
 }
 
 void device_reset(DeviceState *dev)
hw/core/register.c +1 -1
index dc335a79a9..da38ef3a54 100644
@@ -288,7 +288,7 @@ static void register_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     /* Reason: needs to be wired up to work */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo register_info = {
hw/dma/i8257.c +1 -1
index 8bd82e8bc8..bd23e893bf 100644
@@ -601,7 +601,7 @@ static void i8257_class_init(ObjectClass *klass, void *data)
     idc->schedule = i8257_dma_schedule;
     idc->register_channel = i8257_dma_register_channel;
     /* Reason: needs to be wired up by isa_bus_dma() to work */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo i8257_info = {
hw/dma/sparc32_dma.c +1 -1
index 9d545e412e..9c6bdc6295 100644
@@ -305,7 +305,7 @@ static void sparc32_dma_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_dma;
     dc->props = sparc32_dma_properties;
     /* Reason: pointer property "iommu_opaque" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sparc32_dma_info = {
hw/gpio/omap_gpio.c +2 -2
index dabef4a119..1df394eb12 100644
@@ -773,7 +773,7 @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_gpif_reset;
     dc->props = omap_gpio_properties;
     /* Reason: pointer property "clk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo omap_gpio_info = {
@@ -804,7 +804,7 @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
     dc->reset = omap2_gpif_reset;
     dc->props = omap2_gpio_properties;
     /* Reason: pointer properties "iclk", "fclk0", ..., "fclk5" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo omap2_gpio_info = {
hw/i2c/omap_i2c.c +1 -1
index f7c92ea00c..f6e80bee25 100644
@@ -491,7 +491,7 @@ static void omap_i2c_class_init(ObjectClass *klass, void *data)
     dc->props = omap_i2c_properties;
     dc->reset = omap_i2c_reset;
     /* Reason: pointer properties "iclk", "fclk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap_i2c_realize;
 }
 
hw/i2c/smbus_eeprom.c +1 -1
index 5b7bd891bc..b13ec0fe7a 100644
@@ -123,7 +123,7 @@ static void smbus_eeprom_class_initfn(ObjectClass *klass, void *data)
     sc->read_data = eeprom_read_data;
     dc->props = smbus_eeprom_properties;
     /* Reason: pointer property "data" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo smbus_eeprom_info = {
hw/i2c/smbus_ich9.c +1 -1
index 48fab22625..ea51e09186 100644
@@ -103,7 +103,7 @@ static void ich9_smb_class_init(ObjectClass *klass, void *data)
      * Reason: part of ICH9 southbridge, needs to be wired up by
      * pc_q35_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base)
hw/i386/pc.c +1 -1
index d24388e05f..610050eb4f 100644
@@ -597,7 +597,7 @@ static void port92_class_initfn(ObjectClass *klass, void *data)
      * wiring: its A20 output line needs to be wired up by
      * port92_init().
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo port92_info = {
hw/input/vmmouse.c +1 -1
index 6d15a887c6..4747da9a8d 100644
@@ -286,7 +286,7 @@ static void vmmouse_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_vmmouse;
     dc->props = vmmouse_properties;
     /* Reason: pointer property "ps2_mouse" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo vmmouse_info = {
hw/intc/apic_common.c +1 -1
index c3829e31b5..1ef56f8d10 100644
@@ -501,7 +501,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
      * Reason: APIC and CPU need to be wired up by
      * x86_cpu_apic_create()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo apic_common_type = {
hw/intc/etraxfs_pic.c +1 -1
index 64a6f4b4ba..1bfde2f09e 100644
@@ -173,7 +173,7 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
     dc->props = etraxfs_pic_properties;
     /*
      * Note: pointer property "interrupt_vector" may remain null, thus
-     * no need for dc->cannot_instantiate_with_device_add_yet = true;
+     * no need for dc->user_creatable = false;
      */
 }
 
hw/intc/grlib_irqmp.c +1 -1
index ac7e63f38b..94659ee256 100644
@@ -360,7 +360,7 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
     dc->reset = grlib_irqmp_reset;
     dc->props = grlib_irqmp_properties;
     /* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = grlib_irqmp_realize;
 }
 
hw/intc/i8259_common.c +1 -1
index d9a5e8b217..c2fd563b5b 100644
@@ -144,7 +144,7 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
      * wiring of the slave to the master is hard-coded in device model
      * code.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pic_common_type = {
hw/intc/nios2_iic.c +1 -1
index 190b6fdbf3..016426f964 100644
@@ -80,7 +80,7 @@ static void altera_iic_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     /* Reason: needs to be wired up, e.g. by nios2_10m50_ghrd_init() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = altera_iic_realize;
 }
 
hw/intc/omap_intc.c +2 -2
index 877be67971..ccdda89dab 100644
@@ -401,7 +401,7 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_inth_reset;
     dc->props = omap_intc_properties;
     /* Reason: pointer property "clk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap_intc_realize;
 }
 
@@ -656,7 +656,7 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
     dc->reset = omap_inth_reset;
     dc->props = omap2_intc_properties;
     /* Reason: pointer property "iclk", "fclk" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->realize = omap2_intc_realize;
 }
 
hw/isa/lpc_ich9.c +1 -1
index 59930dd9d0..cdc854a822 100644
@@ -810,7 +810,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
      * Reason: part of ICH9 southbridge, needs to be wired up by
      * pc_q35_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     hc->plug = ich9_pm_device_plug_cb;
     hc->unplug_request = ich9_pm_device_unplug_request_cb;
     hc->unplug = ich9_pm_device_unplug_cb;
hw/isa/piix4.c +1 -1
index 5500fcc4d6..f811eba59d 100644
@@ -123,7 +123,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX4 southbridge, needs to be wired up,
      * e.g. by mips_malta_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable = false;
 }
 
hw/isa/vt82c686.c +1 -1
index 41d5254f8e..50dc83df77 100644
@@ -494,7 +494,7 @@ static void via_class_init(ObjectClass *klass, void *data)
      * Reason: part of VIA VT82C686 southbridge, needs to be wired up,
      * e.g. by mips_fulong2e_init()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo via_info = {
hw/mips/gt64xxx_pci.c +1 -1
index 4811843ab6..e8b2eef688 100644
@@ -1224,7 +1224,7 @@ static void gt64120_pci_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo gt64120_pci_info = {
hw/misc/vmport.c +1 -1
index be40930b8b..165500223f 100644
@@ -163,7 +163,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data)
 
     dc->realize = vmport_realizefn;
     /* Reason: realize sets global port_state */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo vmport_info = {
hw/net/dp8393x.c +1 -1
index efa33ad40a..b53fcaa8bc 100644
@@ -934,7 +934,7 @@ static void dp8393x_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_dp8393x;
     dc->props = dp8393x_properties;
     /* Reason: dma_mr property can't be set */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo dp8393x_info = {
hw/net/etraxfs_eth.c +1 -1
index efaa49faae..013c8d0a41 100644
@@ -630,7 +630,7 @@ static void etraxfs_eth_class_init(ObjectClass *klass, void *data)
     k->init = fs_eth_init;
     dc->props = etraxfs_eth_properties;
     /* Reason: pointer properties "dma_out", "dma_in" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo etraxfs_eth_info = {
hw/net/lance.c +1 -1
index 573d724bcf..92b0c68274 100644
@@ -165,7 +165,7 @@ static void lance_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_lance;
     dc->props = lance_properties;
     /* Reason: pointer property "dma" */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo lance_info = {
hw/pci-bridge/dec.c +1 -1
index 840c96198a..cca93620ac 100644
@@ -128,7 +128,7 @@ static void dec_21154_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo dec_21154_pci_host_info = {
hw/pci-bridge/pci_expander_bridge.c +1 -1
index 6ac187fa32..ff59abf208 100644
@@ -150,7 +150,7 @@ static void pxb_host_class_init(ObjectClass *class, void *data)
 
     dc->fw_name = "pci";
     /* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
     hc->root_bus_path = pxb_host_root_bus_path;
 }
hw/pci-host/apb.c +1 -1
index 653e711121..edc88f4c65 100644
@@ -810,7 +810,7 @@ static void pbm_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pbm_pci_host_info = {
hw/pci-host/bonito.c +1 -1
index 1999ece590..85a3bb0dd2 100644
@@ -825,7 +825,7 @@ static void bonito_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo bonito_info = {
hw/pci-host/gpex.c +1 -1
index 66055ee5cc..e2629ce70d 100644
@@ -136,7 +136,7 @@ static void gpex_root_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo gpex_root_info = {
hw/pci-host/grackle.c +1 -1
index 2c8acdaaca..2e281f6155 100644
@@ -134,7 +134,7 @@ static void grackle_pci_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo grackle_pci_info = {
hw/pci-host/piix.c +3 -3
index f9218aa952..81f3a9e211 100644
@@ -691,7 +691,7 @@ static void pci_piix3_class_init(ObjectClass *klass, void *data)
      * Reason: part of PIIX3 southbridge, needs to be wired up by
      * pc_piix.c's pc_init1()
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo piix3_pci_type_info = {
@@ -745,7 +745,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->hotpluggable   = false;
 }
 
@@ -874,7 +874,7 @@ static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
     dc->fw_name = "pci";
     dc->props = i440fx_props;
     /* Reason: needs to be wired up by pc_init1 */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo i440fx_pcihost_info = {
hw/pci-host/ppce500.c +1 -1
index e502bc0505..becc0eeb76 100644
@@ -508,7 +508,7 @@ static void e500_host_bridge_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo e500_host_bridge_info = {
hw/pci-host/prep.c +1 -1
index 260a119a9e..900a6edfcf 100644
@@ -364,7 +364,7 @@ static void raven_class_init(ObjectClass *klass, void *data)
      * Reason: PCI-facing part of the host bridge, not usable without
      * the host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo raven_info = {
hw/pci-host/q35.c +2 -2
index 344f77b10c..cd5c49616e 100644
@@ -156,7 +156,7 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
     dc->realize = q35_host_realize;
     dc->props = mch_props;
     /* Reason: needs to be wired up by pc_q35_init */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "pci";
 }
@@ -549,7 +549,7 @@ static void mch_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo mch_info = {
hw/pci-host/uninorth.c +4 -4
index df342ac3cb..6cf5e59f86 100644
@@ -366,7 +366,7 @@ static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_main_pci_host_info = {
@@ -390,7 +390,7 @@ static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo u3_agp_pci_host_info = {
@@ -414,7 +414,7 @@ static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_agp_pci_host_info = {
@@ -438,7 +438,7 @@ static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo unin_internal_pci_host_info = {
hw/pci-host/versatile.c +1 -1
index 467cbb9cb8..cc51fc87a3 100644
@@ -479,7 +479,7 @@ static void versatile_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo versatile_pci_host_info = {
hw/pci-host/xilinx-pcie.c +1 -1
index 8b71e2d950..a968cea2af 100644
@@ -309,7 +309,7 @@ static void xilinx_pcie_root_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo xilinx_pcie_root_info = {
hw/ppc/ppc4xx_pci.c +1 -1
index dc19682970..6953f8b9ac 100644
@@ -351,7 +351,7 @@ static void ppc4xx_host_bridge_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo ppc4xx_host_bridge_info = {
hw/ppc/spapr_drc.c +1 -1
index a1cdc875b1..9fa5545991 100644
@@ -675,7 +675,7 @@ static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
     /*
      * Reason: it crashes FIXME find and document the real reason
      */
-    dk->cannot_instantiate_with_device_add_yet = true;
+    dk->user_creatable = false;
 }
 
 static const TypeInfo spapr_dr_connector_info = {
hw/s390x/s390-pci-bus.c +1 -1
index 69b0291e8a..1ec30c45ce 100644
@@ -867,7 +867,7 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
 
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
     dc->reset = s390_pcihost_reset;
     k->init = s390_pcihost_init;
     hc->plug = s390_pcihost_hot_plug;
hw/sd/milkymist-memcard.c +1 -1
index 1f2f0ed44a..4008c81002 100644
@@ -299,7 +299,7 @@ static void milkymist_memcard_class_init(ObjectClass *klass, void *data)
     dc->reset = milkymist_memcard_reset;
     dc->vmsd = &vmstate_milkymist_memcard;
     /* Reason: init() method uses drive_get_next() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo milkymist_memcard_info = {
hw/sd/pl181.c +1 -1
index 82c63a4fb5..55c8098ecd 100644
@@ -515,7 +515,7 @@ static void pl181_class_init(ObjectClass *klass, void *data)
     k->vmsd = &vmstate_pl181;
     k->reset = pl181_reset;
     /* Reason: init() method uses drive_get_next() */
-    k->cannot_instantiate_with_device_add_yet = true;
+    k->user_creatable = false;
     k->realize = pl181_realize;
 }
 
hw/sh4/sh_pci.c +1 -1
index 1747628f3d..38395c082b 100644
@@ -171,7 +171,7 @@ static void sh_pci_host_class_init(ObjectClass *klass, void *data)
      * PCI-facing part of the host bridge, not usable without the
      * host-facing part, which can't be device_add'ed, yet.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo sh_pci_host_info = {
hw/timer/i8254_common.c +1 -1
index e18299a482..976d5200f1 100644
@@ -287,7 +287,7 @@ static void pit_common_class_init(ObjectClass *klass, void *data)
      * wired to the HPET, and because of that, some wiring is always
      * done by board code.
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo pit_common_type = {
hw/timer/mc146818rtc.c +1 -1
index 4165450250..93de3e1cc5 100644
@@ -973,7 +973,7 @@ static void rtc_class_initfn(ObjectClass *klass, void *data)
     dc->vmsd = &vmstate_rtc;
     dc->props = mc146818rtc_properties;
     /* Reason: needs to be wired up by rtc_init() */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static void rtc_finalize(Object *obj)
monitor.c +1 -1
index be282ecb80..e06edec2bd 100644
@@ -3156,7 +3156,7 @@ void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
                                              TYPE_DEVICE);
         name = object_class_get_name(OBJECT_CLASS(dc));
 
-        if (!dc->cannot_instantiate_with_device_add_yet
+        if (dc->user_creatable
             && !strncmp(name, str, len)) {
             readline_add_completion(rs, name);
         }
qdev-monitor.c +3 -3
index 5f2fcdfc45..e4c180c6bc 100644
@@ -113,7 +113,7 @@ static void qdev_print_devinfo(DeviceClass *dc)
     if (dc->desc) {
         error_printf(", desc \"%s\"", dc->desc);
     }
-    if (dc->cannot_instantiate_with_device_add_yet) {
+    if (!dc->user_creatable) {
         error_printf(", no-user");
     }
     error_printf("\n");
@@ -155,7 +155,7 @@ static void qdev_print_devinfos(bool show_no_user)
                  ? !test_bit(i, dc->categories)
                  : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
                 || (!show_no_user
-                    && dc->cannot_instantiate_with_device_add_yet)) {
+                    && !dc->user_creatable)) {
                 continue;
             }
             if (!cat_printed) {
@@ -240,7 +240,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
     }
 
     dc = DEVICE_CLASS(oc);
-    if (dc->cannot_instantiate_with_device_add_yet ||
+    if (!dc->user_creatable ||
         (qdev_hotplug && !dc->hotpluggable)) {
         error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
                    "pluggable device type");
qom/cpu.c +1 -1
index f02e9c0fae..73ae140d7e 100644
@@ -449,7 +449,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
      * Reason: CPUs still need special care by board code: wiring up
      * IRQs, adding reset handlers, halting non-first CPUs, ...
      */
-    dc->cannot_instantiate_with_device_add_yet = true;
+    dc->user_creatable = false;
 }
 
 static const TypeInfo cpu_type_info = {
target/i386/cpu.c +1 -1
index 13c0985f11..4b3bfb3802 100644
@@ -4066,7 +4066,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->cpu_exec_enter = x86_cpu_exec_enter;
     cc->cpu_exec_exit = x86_cpu_exec_exit;
 
-    dc->cannot_instantiate_with_device_add_yet = false;
+    dc->user_creatable = true;
 }
 
 static const TypeInfo x86_cpu_type_info = {
#3 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

Quoted 31 lines · Marcel Apfelbaum
Quoted 4 lines · Eduardo Habkost

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,

Quoted 10 lines

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.

Quoted 4 lines

Except for code comments, changes were generated using the following Coccinelle patch:

Quoted 8 lines
Quoted 6 lines
  @@
  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.

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).

Quoted 17 lines
Quoted 16 lines
  |
  -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;
Quoted 2 lines

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)

Quoted 25 lines
Quoted 13 lines
   ...
   }
  @@
  @@
   struct DeviceClass {
   ...
  -bool cannot_instantiate_with_device_add_yet;
  +bool user_creatable;
   ...
  }
Quoted 11 lines

@@
expression DC;
@@
(
-!DC->cannot_instantiate_with_device_add_yet
+DC->user_creatable
|
-DC->cannot_instantiate_with_device_add_yet
+!DC->user_creatable
)

Quoted 1 line

Nice script!

Thanks!

Signature · 1 line
Eduardo
#9 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH v2 02/21] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE

In reply to Eduardo Habkost
Quoted 136 lines · Eduardo Habkost

commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all sysbus devices appear on "-device help" and lack the "no-user" flag in "info qdm".

To fix this, we can set user_creatable=false by default on TYPE_SYS_BUS_DEVICE, but this requires setting user_creatable=true explicitly on the sysbus devices that actually work with -device.

Fortunately today we have just a few has_dynamic_sysbus=1
machines: virt, pc-q35-*, ppce500, and spapr.

virt, ppce500, and spapr have extra checks to ensure just a few device types can be instantiated:

* virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
* ppce500 supports only TYPE_ETSEC_COMMON.
* spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.

This patch sets user_creatable=true explicitly on those 4 device classes.

Now, the more complex cases:

pc-q35-*: q35 has no sysbus device whitelist yet (which is a separate bug). We are in the process of fixing it and building a sysbus whitelist on q35, but in the meantime we can fix the "-device help" and "info qdm" bugs mentioned above. Also, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist.

xen: We also have a hack at xen_set_dynamic_sysbus(), that sets has_dynamic_sysbus=true at runtime when using the Xen accelerator. This hack is only used to allow xen-backend devices to be dynamically plugged/unplugged.

This means today we can use -device with the following 22 device types, that are the ones compiled into the qemu-system-x86_64 and qemu-system-i386 binaries:

* allwinner-ahci
* amd-iommu
* cfi.pflash01
* esp
* fw_cfg_io
* fw_cfg_mem
* generic-sdhci
* hpet
* intel-iommu
* ioapic
* isabus-bridge
* kvmclock
* kvm-ioapic
* kvmvapic
* SUNW,fdtwo
* sysbus-ahci
* sysbus-fdc
* sysbus-ohci
* unimplemented-device
* virtio-mmio
* xen-backend
* xen-sysdev

This patch adds user_creatable=true explicitly to those devices, temporarily, just to keep 100% compatibility with existing behavior of q35. Subsequent patches will remove user_creatable=true from the devices that are really not meant to user-creatable on any machine, and remove the FIXME comment from the ones that are really supposed to be user-creatable. This is being done in separate patches because we still don't have an obvious list of devices that will be whitelisted by q35, and I would like to get each device reviewed individually.

Cc Alexander Graf <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Alistair Francis <[email protected]>
Cc Beniamino Galvani <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Cornelia Huck <[email protected]>
Cc David Gibson <[email protected]>
Cc "Edgar E. Iglesias" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Frank Blaschka <[email protected]>
Cc Gabriel L. Somlo <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jason Wang <[email protected]>
Cc John Snow <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Max Reitz <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Prasad J Pandit <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Rob Herring <[email protected]>
Cc Shannon Zhao <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Yi Min Zhao <[email protected]>

---
Changes v1 -> v2:
* Rewrite commit message: don't pretend we are actually fixing the q35 issue. We're just fixing "info qdm" and "-device help". Making it easier to fix q35 is just a nice side-effect.
* Rewrite FIXME comments to make it clear that we just have user_creatable=true because we don't know yet if the device should be in the q35 whitelist

---
 hw/block/fdc.c           | 10 ++++++++++
 hw/block/pflash_cfi01.c  |  5 +++++
 hw/core/sysbus.c         | 11 +++++++++++
 hw/i386/amd_iommu.c      |  5 +++++
 hw/i386/intel_iommu.c    |  5 +++++
 hw/i386/kvm/clock.c      |  5 +++++
 hw/i386/kvm/ioapic.c     |  5 +++++
 hw/i386/kvmvapic.c       |  5 +++++
 hw/ide/ahci.c            | 10 ++++++++++
 hw/intc/ioapic.c         |  5 +++++
 hw/isa/isa-bus.c         |  5 +++++
 hw/misc/unimp.c          |  5 +++++
 hw/net/fsl_etsec/etsec.c |  2 ++
 hw/nvram/fw_cfg.c        | 10 ++++++++++
 hw/ppc/spapr_pci.c       |  2 ++
 hw/scsi/esp.c            |  5 +++++
Quoted 9 lines
 hw/sd/sdhci.c            |  5 +++++
 hw/timer/hpet.c          |  5 +++++
 hw/usb/hcd-ohci.c        |  5 +++++
 hw/vfio/amd-xgbe.c       |  2 ++
 hw/vfio/calxeda-xgmac.c  |  2 ++
 hw/virtio/virtio-mmio.c  |  5 +++++
 hw/xen/xen_backend.c     | 10 ++++++++++
 23 files changed, 129 insertions(+)

ACK patches 2, 5, 10, 11. AFAIUI all of the sysbus variants of FDC/AHCI devices are there for SoCs and aren't of any use by themselves.

Quoted 411 lines
hw/block/fdc.c +10 -0
index a328693d15..3d05565628 100644
@@ -2880,6 +2880,11 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sysbus_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_fdc_info = {
@@ -2906,6 +2911,11 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sun4m_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sun4m_fdc_info = {
hw/block/pflash_cfi01.c +5 -0
index 594d4cf6fe..ef71956433 100644
@@ -927,6 +927,11 @@ static void pflash_cfi01_class_init(ObjectClass *klass, void *data)
     dc->props = pflash_cfi01_properties;
     dc->vmsd = &vmstate_pflash;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 
hw/core/sysbus.c +11 -0
index c0f560b289..6a2eec8dd0 100644
@@ -326,6 +326,17 @@ static void sysbus_device_class_init(ObjectClass *klass, void *data)
     DeviceClass *k = DEVICE_CLASS(klass);
     k->init = sysbus_device_init;
     k->bus_type = TYPE_SYSTEM_BUS;
+    /*
+     * device_add plugs devices into suitable bus.  For "real" buses,
+     * that actually connects the device.  For sysbus, the connections
+     * need to be made separately, and device_add can't do that.  The
+     * device would be left unconnected, and will probably not work
+     *
+     * However, a few machines and a few devices can handle a few sysbus
+     * devices. In this case, the device subclass needs to override
+     * it and set user_creatable=true.
+     */
+    k->user_creatable = false;
 }
 
 static const TypeInfo sysbus_device_type_info = {
hw/i386/amd_iommu.c +5 -0
index f86a40aa30..7b92c8c15a 100644
@@ -1186,6 +1186,11 @@ static void amdvi_class_init(ObjectClass *klass, void* data)
     dc->vmsd = &vmstate_amdvi;
     dc->hotpluggable = false;
     dc_class->realize = amdvi_realize;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo amdvi = {
hw/i386/intel_iommu.c +5 -0
index 22d8226e43..d71d52c328 100644
@@ -2601,6 +2601,11 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     x86_class->realize = vtd_realize;
     x86_class->int_remap = vtd_int_remap;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vtd_info = {
hw/i386/kvm/clock.c +5 -0
index 13eca374cd..7665bef999 100644
@@ -286,6 +286,11 @@ static void kvmclock_class_init(ObjectClass *klass, void *data)
     dc->realize = kvmclock_realize;
     dc->vmsd = &kvmclock_vmsd;
     dc->props = kvmclock_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo kvmclock_info = {
hw/i386/kvm/ioapic.c +5 -0
index 98ca480792..348c405180 100644
@@ -167,6 +167,11 @@ static void kvm_ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = kvm_ioapic_put;
     dc->reset    = kvm_ioapic_reset;
     dc->props    = kvm_ioapic_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo kvm_ioapic_info = {
hw/i386/kvmvapic.c +5 -0
index 82a49556af..45f6267c93 100644
@@ -856,6 +856,11 @@ static void vapic_class_init(ObjectClass *klass, void *data)
     dc->reset   = vapic_reset;
     dc->vmsd    = &vmstate_vapic;
     dc->realize = vapic_realize;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vapic_type = {
hw/ide/ahci.c +10 -0
index f60826d6e0..7f10cda354 100644
@@ -1721,6 +1721,11 @@ static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
     dc->props = sysbus_ahci_properties;
     dc->reset = sysbus_ahci_reset;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_ahci_info = {
@@ -1815,6 +1820,11 @@ static void allwinner_ahci_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_allwinner_ahci;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo allwinner_ahci_info = {
hw/intc/ioapic.c +5 -0
index 37c4386ae3..f9e4f77def 100644
@@ -448,6 +448,11 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
     k->post_load = ioapic_update_kvm_routes;
     dc->reset = ioapic_reset_common;
     dc->props = ioapic_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo ioapic_info = {
hw/isa/isa-bus.c +5 -0
index 348e0eab9d..ad4ac3b4f6 100644
@@ -221,6 +221,11 @@ static void isabus_bridge_class_init(ObjectClass *klass, void *data)
 
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->fw_name = "isa";
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo isabus_bridge_info = {
hw/misc/unimp.c +5 -0
index bcbb585888..e446c1d652 100644
@@ -90,6 +90,11 @@ static void unimp_class_init(ObjectClass *klass, void *data)
 
     dc->realize = unimp_realize;
     dc->props = unimp_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo unimp_info = {
hw/net/fsl_etsec/etsec.c +2 -0
index aa2b0d5a85..9da1932970 100644
@@ -416,6 +416,8 @@ static void etsec_class_init(ObjectClass *klass, void *data)
     dc->realize = etsec_realize;
     dc->reset = etsec_reset;
     dc->props = etsec_properties;
+    /* Supported by ppce500 machine */
+    dc->user_creatable = true;
 }
 
 static TypeInfo etsec_info = {
hw/nvram/fw_cfg.c +10 -0
index 316fca9bc1..7993aea792 100644
@@ -1101,6 +1101,11 @@ static void fw_cfg_io_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_io_realize;
     dc->props = fw_cfg_io_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_io_info = {
@@ -1167,6 +1172,11 @@ static void fw_cfg_mem_class_init(ObjectClass *klass, void *data)
 
     dc->realize = fw_cfg_mem_realize;
     dc->props = fw_cfg_mem_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo fw_cfg_mem_info = {
hw/ppc/spapr_pci.c +2 -0
index 98c52e411f..cae2b31230 100644
@@ -1990,6 +1990,8 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data)
     dc->props = spapr_phb_properties;
     dc->reset = spapr_phb_reset;
     dc->vmsd = &vmstate_spapr_pci;
+    /* Supported by TYPE_SPAPR_MACHINE */
+    dc->user_creatable = true;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     hp->plug = spapr_phb_hot_plug_child;
     hp->unplug = spapr_phb_hot_unplug_child;
hw/scsi/esp.c +5 -0
index eee831efeb..7bdc1e1b99 100644
@@ -728,6 +728,11 @@ static void sysbus_esp_class_init(ObjectClass *klass, void *data)
     dc->reset = sysbus_esp_hard_reset;
     dc->vmsd = &vmstate_sysbus_esp_scsi;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_esp_info = {
hw/sd/sdhci.c +5 -0
index 6d6a791ee9..dbf61fccb8 100644
@@ -1360,6 +1360,11 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->props = sdhci_sysbus_properties;
     dc->realize = sdhci_sysbus_realize;
     dc->reset = sdhci_poweron_reset;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo sdhci_sysbus_info = {
hw/timer/hpet.c +5 -0
index a2c18b30c3..4dcbd5bb3d 100644
@@ -771,6 +771,11 @@ static void hpet_device_class_init(ObjectClass *klass, void *data)
     dc->reset = hpet_reset;
     dc->vmsd = &vmstate_hpet;
     dc->props = hpet_device_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo hpet_device_info = {
hw/usb/hcd-ohci.c +5 -0
index 3ada35e954..18b31022a7 100644
@@ -2159,6 +2159,11 @@ static void ohci_sysbus_class_init(ObjectClass *klass, void *data)
     dc->desc = "OHCI USB Controller";
     dc->props = ohci_sysbus_properties;
     dc->reset = usb_ohci_reset_sysbus;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo ohci_sysbus_info = {
hw/vfio/amd-xgbe.c +2 -0
index 2c60310cf9..fab196cebf 100644
@@ -38,6 +38,8 @@ static void vfio_amd_xgbe_class_init(ObjectClass *klass, void *data)
     dc->realize = amd_xgbe_realize;
     dc->desc = "VFIO AMD XGBE";
     dc->vmsd = &vfio_platform_amd_xgbe_vmstate;
+    /* Supported by TYPE_VIRT_MACHINE */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vfio_amd_xgbe_dev_info = {
hw/vfio/calxeda-xgmac.c +2 -0
index bb15d588e5..7bb17af7ad 100644
@@ -38,6 +38,8 @@ static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)
     dc->realize = calxeda_xgmac_realize;
     dc->desc = "VFIO Calxeda XGMAC";
     dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;
+    /* Supported by TYPE_VIRT_MACHINE */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo vfio_calxeda_xgmac_dev_info = {
hw/virtio/virtio-mmio.c +5 -0
index 5807aa87fe..6491a771ff 100644
@@ -450,6 +450,11 @@ static void virtio_mmio_class_init(ObjectClass *klass, void *data)
     dc->reset = virtio_mmio_reset;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     dc->props = virtio_mmio_properties;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo virtio_mmio_info = {
hw/xen/xen_backend.c +10 -0
index 6c21c37d68..b39dce4cab 100644
@@ -618,6 +618,11 @@ static void xendev_class_init(ObjectClass *klass, void *data)
 
     dc->props = xendev_properties;
     set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo xendev_type_info = {
@@ -661,6 +666,11 @@ static void xen_sysdev_class_init(ObjectClass *klass, void *data)
     k->init = xen_sysdev_init;
     dc->props = xen_sysdev_properties;
     dc->bus_type = TYPE_XENSYSBUS;
+    /*
+     * FIXME: Set only because we are not sure yet if this device
+     * will be outside the q35 sysbus whitelist.
+     */
+    dc->user_creatable = true;
 }
 
 static const TypeInfo xensysdev_info = {
#5 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

In reply to Marcel Apfelbaum

Forgot to answer this part on my previous message:

On Wed, Apr 05, 2017 at 10:01:29PM +0300, Marcel Apfelbaum wrote:
[...]

Quoted 11 lines
Quoted 10 lines

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.

Quoted 6 lines

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.

It's true that q35 wouldn't break if it simply used user_creatable after applying this series. But it will break if one day we link code that registers a user-creatable non-x86 device inside the qemu-system-x86_64 binary (even if by accident), or if we add a new user-creatable sysbus device for other x86 machines (e.g. isapc, xenfv, xenpv, pc-i440fx).

Maybe those situations are unlikely, but if we introduce common infrastructure to let machine-types define their sysbus whitelists[1], we get the ability to define the q35 whitelist for free.

[1] See "[RFC 0/4] Replace has_dynamic_sysbus with device type whitelist"

Signature · 1 line
Eduardo
#6 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

Quoted 6 lines · Eduardo Habkost

It's true that q35 wouldn't break if it simply used user_creatable after applying this series. But it will break if one day we link code that registers a user-creatable non-x86 device inside the qemu-system-x86_64 binary (even if by accident), or if we add a new user-creatable sysbus device for other x86 machines (e.g. isapc, xenfv, xenpv, pc-i440fx).

I would some day like us to be able to move towards multiple-architectures-one-qemu-binary, so yes, we should not assume that no non-x86 devices or CPUs could ever be linked in.

thanks
-- PMM

Acked-by on v2 2/21
#10 lore raw

Re: [Qemu-devel] [PATCH v2 02/21] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE

In reply to Eduardo Habkost
Quoted 136 lines · Eduardo Habkost

commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31 unset cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all sysbus devices appear on "-device help" and lack the "no-user" flag in "info qdm".

To fix this, we can set user_creatable=false by default on TYPE_SYS_BUS_DEVICE, but this requires setting user_creatable=true explicitly on the sysbus devices that actually work with -device.

Fortunately today we have just a few has_dynamic_sysbus=1
machines: virt, pc-q35-*, ppce500, and spapr.

virt, ppce500, and spapr have extra checks to ensure just a few device types can be instantiated:

* virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
* ppce500 supports only TYPE_ETSEC_COMMON.
* spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.

This patch sets user_creatable=true explicitly on those 4 device classes.

Now, the more complex cases:

pc-q35-*: q35 has no sysbus device whitelist yet (which is a separate bug). We are in the process of fixing it and building a sysbus whitelist on q35, but in the meantime we can fix the "-device help" and "info qdm" bugs mentioned above. Also, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist.

xen: We also have a hack at xen_set_dynamic_sysbus(), that sets has_dynamic_sysbus=true at runtime when using the Xen accelerator. This hack is only used to allow xen-backend devices to be dynamically plugged/unplugged.

This means today we can use -device with the following 22 device types, that are the ones compiled into the qemu-system-x86_64 and qemu-system-i386 binaries:

* allwinner-ahci
* amd-iommu
* cfi.pflash01
* esp
* fw_cfg_io
* fw_cfg_mem
* generic-sdhci
* hpet
* intel-iommu
* ioapic
* isabus-bridge
* kvmclock
* kvm-ioapic
* kvmvapic
* SUNW,fdtwo
* sysbus-ahci
* sysbus-fdc
* sysbus-ohci
* unimplemented-device
* virtio-mmio
* xen-backend
* xen-sysdev

This patch adds user_creatable=true explicitly to those devices, temporarily, just to keep 100% compatibility with existing behavior of q35. Subsequent patches will remove user_creatable=true from the devices that are really not meant to user-creatable on any machine, and remove the FIXME comment from the ones that are really supposed to be user-creatable. This is being done in separate patches because we still don't have an obvious list of devices that will be whitelisted by q35, and I would like to get each device reviewed individually.

Cc Alexander Graf <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Alistair Francis <[email protected]>
Cc Beniamino Galvani <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Cornelia Huck <[email protected]>
Cc David Gibson <[email protected]>
Cc "Edgar E. Iglesias" <[email protected]>
Cc Eduardo Habkost <[email protected]>
Cc Frank Blaschka <[email protected]>
Cc Gabriel L. Somlo <[email protected]>
Cc Gerd Hoffmann <[email protected]>
Cc Igor Mammedov <[email protected]>
Cc Jason Wang <[email protected]>
Cc John Snow <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Kevin Wolf <[email protected]>
Cc Laszlo Ersek <[email protected]>
Cc Marcel Apfelbaum <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Max Reitz <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Pierre Morel <[email protected]>
Cc Prasad J Pandit <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Rob Herring <[email protected]>
Cc Shannon Zhao <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Yi Min Zhao <[email protected]>

---
Changes v1 -> v2:
* Rewrite commit message: don't pretend we are actually fixing the q35 issue. We're just fixing "info qdm" and "-device help". Making it easier to fix q35 is just a nice side-effect.
* Rewrite FIXME comments to make it clear that we just have user_creatable=true because we don't know yet if the device should be in the q35 whitelist

---
 hw/block/fdc.c           | 10 ++++++++++
 hw/block/pflash_cfi01.c  |  5 +++++
 hw/core/sysbus.c         | 11 +++++++++++
 hw/i386/amd_iommu.c      |  5 +++++
 hw/i386/intel_iommu.c    |  5 +++++
 hw/i386/kvm/clock.c      |  5 +++++
 hw/i386/kvm/ioapic.c     |  5 +++++
 hw/i386/kvmvapic.c       |  5 +++++
 hw/ide/ahci.c            | 10 ++++++++++
 hw/intc/ioapic.c         |  5 +++++
 hw/isa/isa-bus.c         |  5 +++++
 hw/misc/unimp.c          |  5 +++++
 hw/net/fsl_etsec/etsec.c |  2 ++
 hw/nvram/fw_cfg.c        | 10 ++++++++++
 hw/ppc/spapr_pci.c       |  2 ++
 hw/scsi/esp.c            |  5 +++++
Quoted 8 lines
 hw/sd/sdhci.c            |  5 +++++
 hw/timer/hpet.c          |  5 +++++
 hw/usb/hcd-ohci.c        |  5 +++++
 hw/vfio/amd-xgbe.c       |  2 ++
 hw/vfio/calxeda-xgmac.c  |  2 ++
 hw/virtio/virtio-mmio.c  |  5 +++++
 hw/xen/xen_backend.c     | 10 ++++++++++
 23 files changed, 129 insertions(+)

Patches 2 (Xen related stuff), 3 and 20:

Juergen

Reviewed-by on v2 1/21
#7 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

In reply to Eduardo Habkost
Quoted 3 lines · Eduardo Habkost

cannot_instantiate_with_device_add_yet was introduced by commit 837d37167dc446af8a91189108b363c04609e296 to replace no_user. It was supposed to be a temporary measure.

I think you rather meant commit efec3dd631d94160288392721a5f9c39e50fb2bc ("qdev: Replace no_user by cannot_instantiate_with_device_add_yet") ?

Quoted 6 lines

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.

I fully agree.

Quoted 3 lines

Instead of a long field name that misleads people to believe it is temporary, replace it a shorter and less misleading field:
user_creatable.

Sounds much better, indeed. Thanks for tackling this!

[...]

monitor.c void device_add_completion(ReadLineState *rs, int nb_args, const char *str) · line 3160

Quoted 12 lines

static void rtc_finalize(Object *obj)

monitor.c +1 -1
index be282ecb80..e06edec2bd 100644
@@ -3156,7 +3156,7 @@ void device_add_completion(ReadLineState *rs, int nb_args, const char *str)
                                              TYPE_DEVICE);
         name = object_class_get_name(OBJECT_CLASS(dc));
 
-        if (!dc->cannot_instantiate_with_device_add_yet
+        if (dc->user_creatable
             && !strncmp(name, str, len)) {

Cosmetics: You could put the strcmp now into the previous line, too.

Quoted 16 lines
monitor.c +0 -0
             readline_add_completion(rs, name);
         }
qdev-monitor.c +1 -1
index 5f2fcdfc45..e4c180c6bc 100644
@@ -113,7 +113,7 @@ static void qdev_print_devinfo(DeviceClass *dc)
     if (dc->desc) {
         error_printf(", desc \"%s\"", dc->desc);
     }
-    if (dc->cannot_instantiate_with_device_add_yet) {
+    if (!dc->user_creatable) {
         error_printf(", no-user");
     }
     error_printf("\n");

qdev-monitor.c static void qdev_print_devinfos(bool show_no_user) · line 158

Quoted 5 lines
qdev-monitor.c +1 -1
@@ -155,7 +155,7 @@ static void qdev_print_devinfos(bool show_no_user)
                  ? !test_bit(i, dc->categories)
                  : !bitmap_empty(dc->categories, DEVICE_CATEGORY_MAX))
                 || (!show_no_user
-                    && dc->cannot_instantiate_with_device_add_yet)) {
+                    && !dc->user_creatable)) {

Cosmetics: That line could now also be moved at the end of the previous line.

qdev-monitor.c static DeviceClass *qdev_get_device_class(const char **driver, Error **errp) · line 244

Quoted 10 lines
qdev-monitor.c +1 -1
                 continue;
             }
             if (!cat_printed) {
@@ -240,7 +240,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
     }
 
     dc = DEVICE_CLASS(oc);
-    if (dc->cannot_instantiate_with_device_add_yet ||
+    if (!dc->user_creatable ||
         (qdev_hotplug && !dc->hotpluggable)) {

dito

Anyway, patch looks fine to me, so:

Reviewed-by
#4 lore raw

Re: [Qemu-devel] [PATCH v2 01/21] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable

In reply to Eduardo Habkost
Quoted 39 lines · Eduardo Habkost
Quoted 38 lines · Marcel Apfelbaum
Quoted 4 lines · Eduardo Habkost

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,

Quoted 10 lines

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.

Quoted 10 lines

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;
Quoted 8 lines
Quoted 1 line

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.

Quoted 27 lines

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).

Quoted 17 lines
Quoted 16 lines
  |
  -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;
Quoted 2 lines

OK... it seems risky :). Is true that "hotpluggable" => creatable, but the prev rule should work, right?

Quoted 9 lines

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.

Thanks,
Marcel

Quoted 29 lines
Quoted 25 lines
Quoted 13 lines
   ...
   }
  @@
  @@
   struct DeviceClass {
   ...
  -bool cannot_instantiate_with_device_add_yet;
  +bool user_creatable;
   ...
  }
Quoted 11 lines

@@
expression DC;
@@
(
-!DC->cannot_instantiate_with_device_add_yet
+DC->user_creatable
|
-DC->cannot_instantiate_with_device_add_yet
+!DC->user_creatable
)

Quoted 1 line

Nice script!

Thanks!

Reviewed-by on v2 4/21
#13 lore raw

Re: [Qemu-devel] [PATCH v2 04/21] iommu: Remove FIXME comment about user_creatable=true

In reply to Eduardo Habkost
Quoted 38 lines · Eduardo Habkost

amd-iommu and intel-iommu are really meant to be used with -device, so they need user_creatable=true. Remove the FIXME comment.

Cc Marcel Apfelbaum <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>

---
Changes v1 -> v2:
* (none)

---
 hw/i386/amd_iommu.c   | 5 +----
 hw/i386/intel_iommu.c | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)
hw/i386/amd_iommu.c +1 -4
index 7b92c8c15a..efcc93cbfd 100644
@@ -1186,10 +1186,7 @@ static void amdvi_class_init(ObjectClass *klass, void* data)
     dc->vmsd = &vmstate_amdvi;
     dc->hotpluggable = false;
     dc_class->realize = amdvi_realize;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
+    /* Supported by the pc-q35-* machine types */
     dc->user_creatable = true;
 }
 
hw/i386/intel_iommu.c +0 -0
index d71d52c328..b14db306ef 100644
@@ -2601,10 +2601,7 @@ static void vtd_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;

hw/i386/intel_iommu.c static void vtd_class_init(ObjectClass *klass, void *data) · line 2607

Quoted 10 lines
hw/i386/intel_iommu.c +1 -4
     x86_class->realize = vtd_realize;
     x86_class->int_remap = vtd_int_remap;
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
+    /* Supported by the pc-q35-* machine types */
     dc->user_creatable = true;
 }
 

Thanks,
Marcel

Reviewed-by on v2 5/21
#15 lore raw

Re: [Qemu-devel] [PATCH v2 05/21] fdc: Remove user_creatable flag from sysbus-fdc & SUNW, fdtwo

In reply to Eduardo Habkost
Quoted 36 lines · Eduardo Habkost

sysbus-fdc and SUNW,fdtwo devices need IRQs to be wired and mmio to be mapped, and can't be used with -device. Unset user_creatable on their device classes.

---
Changes v1 -> v2:
* Commit message rewrite only

---
 hw/block/fdc.c | 10 ----------
 1 file changed, 10 deletions(-)
hw/block/fdc.c +0 -5
index 3d05565628..a328693d15 100644
@@ -2880,11 +2880,6 @@ static void sysbus_fdc_class_init(ObjectClass *klass, void *data)
 
     dc->props = sysbus_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sysbus_fdc_info = {
@@ -2911,11 +2906,6 @@ static void sun4m_fdc_class_init(ObjectClass *klass, void *data)
 

hw/block/fdc.c static void sun4m_fdc_class_init(ObjectClass *klass, void *data) · line 2911

Quoted 10 lines
hw/block/fdc.c +0 -5
     dc->props = sun4m_fdc_properties;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    /*
-     * FIXME: Set only because we are not sure yet if this device
-     * will be outside the q35 sysbus whitelist.
-     */
-    dc->user_creatable = true;
 }
 
 static const TypeInfo sun4m_fdc_info = {
Acked-by on the v2 series
#34 lore raw
In reply to Eduardo Habkost
Quoted 97 lines · Eduardo Habkost

Changes v1 -> v2
----------------

* Rewrote series name and cover letter completely to not pretend we're fixing the q35 lack-of-sysbus-whitelist bug, and explain the motivation for the series.
* Previous series name was:
"sysbus: Don't allow -device/device_add by default"
* Rewrote description of patch 02/21, too
* (I really hope people read this cover letter before commenting on individual patches.)
* Rewrote FIXME comments to make it clear that we just set user_creatable=true temporarily because we don't know yet if the device should be in the q35 whitelist.
* Set user_creatable=true on xen-backend also
(I didn't notice it was missing because I was building QEMU without xen support)
* New patches:
* "xen-backend: Remove FIXME comment about user_creatable flag"
* "xen-sysdev: Remove user_creatable flag"
* Patch:
"s390: Add FIXME for unexplained user_creatable=false line"
replaced with:
"s390-pcibus: No need to set user_creatable=false explicitly"

Description
-----------

This series refactor the cannot_instantiate_with_device_add code for sysbus. First, the cannot_instantiate_with_device_add field is replaced by !user_creatable.

Then, we change TYPE_SYS_BUS_DEVICE to set user_creatable=false by default, and we set user_creatable=true explicitly only on the devices that are really supposed to be user-creatable on some machines.

Motivation
----------

First of all, this makes the code less fragile: setting user_creatable=false or cannot_instantiate_with_device_add=true on all sysbus devices is incorrect, and makes code that looks at cannot_instantiate_with_device_add/user_creatable easy to break.

This also fixes a regression introduced by commit 33cd52b5d7b9adfd009e95f07e6c64dd88ae2a31, that makes all sysbus devices appear on "-device help" and lack the "no-user" flag on "info qdm"[1].

This will also make it possible for automatic test code (like the device-crash-test.py script I sent a while ago[2]) skip devices that are not supposed to be user-creatable on any machine.

A note about the lack of sysbus whitelist on q35
------------------------------------------------

This series won't make the per-machine whitelist of sysbus devices unnecessary, but just makes the user_creatable field consistent on the sys-bus-device classes. This means q35 and xen still need to be fixed to implemented a sysbus device whitelist.

However, despite not being strictly necessary for fixing the q35 bug, reducing the list of user_creatable=true devices will help us be more confident when building the q35 whitelist.

Full list of user_creatable=true sysbus devices
-----------------------------------------------

In the end of this series, the only remaining sysbus devices with user_creatable=true will be:

* vfio-amd-xgbe (arm)
* vfio-calxeda-xgmac (arm)
* amd-iommu (x86)
* intel-iommu (x86)
* xen-backend (x86)
* spapr-pci-host-bridge (ppc)
* spapr-pci-vfio-host-bridge (ppc)
* eTSEC (ppc)

References/Notes
----------------

[1] For example, before this series, we had 174 sysbus devices
listed on qemu-system-arm -device help:
$ qemu-system-arm -machine none -device help 2>&1 | grep 'bus System' | wc -l 174
$
after this series, we now have:
$ ./arm-softmmu/qemu-system-arm -machine none -device help 2>&1 | grep 'bus System' name "vfio-amd-xgbe", bus System, desc "VFIO AMD XGBE"
name "vfio-calxeda-xgmac", bus System, desc "VFIO Calxeda XGMAC"
$

[2] Subject: [PATCH 0/3] script for crash-testing -device

Quoted 8 lines

---
Cc: Alexander Graf <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: Marcel Apfelbaum <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Peter Maydell <[email protected]>

Series

Thanks,
Marcel

Quoted 90 lines

Eduardo Habkost (21):
qdev: Replace cannot_instantiate_with_device_add_yet with
!user_creatable
sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE
xen-backend: Remove FIXME comment about user_creatable flag
iommu: Remove FIXME comment about user_creatable=true
fdc: Remove user_creatable flag from sysbus-fdc & SUNW,fdtwo
pflash_cfi01: Remove user_creatable flag
kvmclock: Remove user_creatable flag
ioapic: Remove user_creatable flag
kvmvapic: Remove user_creatable flag
sysbus-ahci: Remove user_creatable flag
allwinner-ahci: Remove user_creatable flag
isabus-bridge: Remove user_creatable flag
unimplemented-device: Remove user_creatable flag
fw_cfg: Remove user_creatable flag
esp: Remove user_creatable flag
generic-sdhci: Remove user_creatable flag
hpet: Remove user_creatable flag
sysbus-ohci: Remove user_creatable flag
virtio-mmio: Remove user_creatable flag
xen-sysdev: Remove user_creatable flag
s390-pcibus: No need to set user_creatable=false explicitly

 include/hw/qdev-core.h              | 10 +++++-----
 include/hw/qdev-properties.h        |  4 ++--
 hw/acpi/piix4.c                     |  2 +-
 hw/arm/spitz.c                      |  2 +-
 hw/audio/marvell_88w8618.c          |  2 +-
 hw/audio/pcspk.c                    |  2 +-
 hw/core/or-irq.c                    |  2 +-
 hw/core/qdev.c                      |  1 +
 hw/core/register.c                  |  2 +-
 hw/core/sysbus.c                    | 11 +++++++++++
 hw/dma/i8257.c                      |  2 +-
 hw/dma/sparc32_dma.c                |  2 +-
 hw/gpio/omap_gpio.c                 |  4 ++--
 hw/i2c/omap_i2c.c                   |  2 +-
 hw/i2c/smbus_eeprom.c               |  2 +-
 hw/i2c/smbus_ich9.c                 |  2 +-
 hw/i386/amd_iommu.c                 |  2 ++
 hw/i386/intel_iommu.c               |  2 ++
 hw/i386/pc.c                        |  2 +-
 hw/input/vmmouse.c                  |  2 +-
 hw/intc/apic_common.c               |  2 +-
 hw/intc/etraxfs_pic.c               |  2 +-
 hw/intc/grlib_irqmp.c               |  2 +-
 hw/intc/i8259_common.c              |  2 +-
 hw/intc/nios2_iic.c                 |  2 +-
 hw/intc/omap_intc.c                 |  4 ++--
 hw/isa/lpc_ich9.c                   |  2 +-
 hw/isa/piix4.c                      |  2 +-
 hw/isa/vt82c686.c                   |  2 +-
 hw/mips/gt64xxx_pci.c               |  2 +-
 hw/misc/vmport.c                    |  2 +-
 hw/net/dp8393x.c                    |  2 +-
 hw/net/etraxfs_eth.c                |  2 +-
 hw/net/fsl_etsec/etsec.c            |  2 ++
 hw/net/lance.c                      |  2 +-
 hw/pci-bridge/dec.c                 |  2 +-
 hw/pci-bridge/pci_expander_bridge.c |  2 +-
 hw/pci-host/apb.c                   |  2 +-
 hw/pci-host/bonito.c                |  2 +-
 hw/pci-host/gpex.c                  |  2 +-
 hw/pci-host/grackle.c               |  2 +-
 hw/pci-host/piix.c                  |  6 +++---
 hw/pci-host/ppce500.c               |  2 +-
 hw/pci-host/prep.c                  |  2 +-
 hw/pci-host/q35.c                   |  4 ++--
 hw/pci-host/uninorth.c              |  8 ++++----
 hw/pci-host/versatile.c             |  2 +-
 hw/pci-host/xilinx-pcie.c           |  2 +-
 hw/ppc/ppc4xx_pci.c                 |  2 +-
 hw/ppc/spapr_drc.c                  |  2 +-
 hw/ppc/spapr_pci.c                  |  2 ++
 hw/s390x/s390-pci-bus.c             |  1 -
 hw/sd/milkymist-memcard.c           |  2 +-
 hw/sd/pl181.c                       |  2 +-
 hw/sh4/sh_pci.c                     |  2 +-
 hw/timer/i8254_common.c             |  2 +-
 hw/timer/mc146818rtc.c              |  2 +-
 hw/vfio/amd-xgbe.c                  |  2 ++
 hw/vfio/calxeda-xgmac.c             |  2 ++
 hw/xen/xen_backend.c                |  2 ++
 monitor.c                           |  2 +-
 qdev-monitor.c                      |  6 +++---
 qom/cpu.c                           |  2 +-
 target/i386/cpu.c                   |  2 +-
 64 files changed, 95 insertions(+), 70 deletions(-)
Reviewed-by on v2 7/21
#18 lore raw

Re: [Qemu-devel] [PATCH v2 07/21] kvmclock: Remove user_creatable flag

In reply to Eduardo Habkost
Quoted 5 lines · Eduardo Habkost

kvmclock should be used by guests only when the appropriate CPUID feature flags are set on the VCPU, and it is automatically created by kvmclock_create() when those feature flags are set. This means creating a kvmclock device using -device is useless. Remove user_creatable from its device class.

Actually, I think this device should not be a sysbus device at all, should it? It does not have any IO, GPIO or IRQ lines, so sysbus does not make sense here, it should be of type TYPE_DEVICE instead.

Anyway, that's another topic. For your patch: