From e90f2a8c3e0e677eeea46a9b401c3f98425ffa37 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:44 -0300 Subject: [PATCH 01/22] qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable cannot_instantiate_with_device_add_yet was introduced by commit efec3dd631d94160288392721a5f9c39e50fb2bc 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 shrunk: 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: Alistair Francis Cc: Laszlo Ersek Cc: Marcel Apfelbaum Cc: Markus Armbruster Cc: Peter Maydell Cc: Thomas Huth Acked-by: Alistair Francis Reviewed-by: Thomas Huth Reviewed-by: Marcel Apfelbaum Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-2-ehabkost@redhat.com> [ehabkost: kept "TODO remove once we're there" comment] Reviewed-by: Markus Armbruster Signed-off-by: Eduardo Habkost --- 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 +- include/hw/qdev-core.h | 9 +++++---- include/hw/qdev-properties.h | 4 ++-- monitor.c | 2 +- qdev-monitor.c | 6 +++--- qom/cpu.c | 2 +- target/i386/cpu.c | 2 +- 56 files changed, 71 insertions(+), 69 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a553a7e110..f4fd5907b8 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -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; diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index fe2d5a764c..324626847c 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -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 = { diff --git a/hw/audio/marvell_88w8618.c b/hw/audio/marvell_88w8618.c index 511b004287..4f65f8c199 100644 --- a/hw/audio/marvell_88w8618.c +++ b/hw/audio/marvell_88w8618.c @@ -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 = { diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 798002277b..9b99358d87 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -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 = { diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c index 1485d5b285..f9d76c4641 100644 --- a/hw/core/or-irq.c +++ b/hw/core/or-irq.c @@ -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 = { diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 02b632f6b3..1863db9d0a 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1118,6 +1118,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) diff --git a/hw/core/register.c b/hw/core/register.c index dc335a79a9..da38ef3a54 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -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 = { diff --git a/hw/dma/i8257.c b/hw/dma/i8257.c index 8bd82e8bc8..bd23e893bf 100644 --- a/hw/dma/i8257.c +++ b/hw/dma/i8257.c @@ -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 = { diff --git a/hw/dma/sparc32_dma.c b/hw/dma/sparc32_dma.c index 9d545e412e..9c6bdc6295 100644 --- a/hw/dma/sparc32_dma.c +++ b/hw/dma/sparc32_dma.c @@ -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 = { diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c index dabef4a119..1df394eb12 100644 --- a/hw/gpio/omap_gpio.c +++ b/hw/gpio/omap_gpio.c @@ -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 = { diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c index f7c92ea00c..f6e80bee25 100644 --- a/hw/i2c/omap_i2c.c +++ b/hw/i2c/omap_i2c.c @@ -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; } diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 5b7bd891bc..b13ec0fe7a 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -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 = { diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c index 48fab22625..ea51e09186 100644 --- a/hw/i2c/smbus_ich9.c +++ b/hw/i2c/smbus_ich9.c @@ -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) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e36a375683..95a5537a2c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -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 = { diff --git a/hw/input/vmmouse.c b/hw/input/vmmouse.c index 6d15a887c6..4747da9a8d 100644 --- a/hw/input/vmmouse.c +++ b/hw/input/vmmouse.c @@ -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 = { diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index c3829e31b5..1ef56f8d10 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -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 = { diff --git a/hw/intc/etraxfs_pic.c b/hw/intc/etraxfs_pic.c index 64a6f4b4ba..1bfde2f09e 100644 --- a/hw/intc/etraxfs_pic.c +++ b/hw/intc/etraxfs_pic.c @@ -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; */ } diff --git a/hw/intc/grlib_irqmp.c b/hw/intc/grlib_irqmp.c index ac7e63f38b..94659ee256 100644 --- a/hw/intc/grlib_irqmp.c +++ b/hw/intc/grlib_irqmp.c @@ -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; } diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index d9a5e8b217..c2fd563b5b 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -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 = { diff --git a/hw/intc/nios2_iic.c b/hw/intc/nios2_iic.c index 190b6fdbf3..016426f964 100644 --- a/hw/intc/nios2_iic.c +++ b/hw/intc/nios2_iic.c @@ -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; } diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c index 877be67971..ccdda89dab 100644 --- a/hw/intc/omap_intc.c +++ b/hw/intc/omap_intc.c @@ -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; } diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index a0866c3856..e2215dcf4d 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -805,7 +805,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; diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 5500fcc4d6..f811eba59d 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -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; } diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 41d5254f8e..50dc83df77 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -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 = { diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c index 4811843ab6..e8b2eef688 100644 --- a/hw/mips/gt64xxx_pci.c +++ b/hw/mips/gt64xxx_pci.c @@ -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 = { diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c index be40930b8b..165500223f 100644 --- a/hw/misc/vmport.c +++ b/hw/misc/vmport.c @@ -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 = { diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index efa33ad40a..b53fcaa8bc 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -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 = { diff --git a/hw/net/etraxfs_eth.c b/hw/net/etraxfs_eth.c index efaa49faae..013c8d0a41 100644 --- a/hw/net/etraxfs_eth.c +++ b/hw/net/etraxfs_eth.c @@ -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 = { diff --git a/hw/net/lance.c b/hw/net/lance.c index 573d724bcf..92b0c68274 100644 --- a/hw/net/lance.c +++ b/hw/net/lance.c @@ -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 = { diff --git a/hw/pci-bridge/dec.c b/hw/pci-bridge/dec.c index 840c96198a..cca93620ac 100644 --- a/hw/pci-bridge/dec.c +++ b/hw/pci-bridge/dec.c @@ -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 = { diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 6ac187fa32..ff59abf208 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -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; } diff --git a/hw/pci-host/apb.c b/hw/pci-host/apb.c index 653e711121..edc88f4c65 100644 --- a/hw/pci-host/apb.c +++ b/hw/pci-host/apb.c @@ -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 = { diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c index 1999ece590..85a3bb0dd2 100644 --- a/hw/pci-host/bonito.c +++ b/hw/pci-host/bonito.c @@ -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 = { diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index 66055ee5cc..e2629ce70d 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -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 = { diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c index 2c8acdaaca..2e281f6155 100644 --- a/hw/pci-host/grackle.c +++ b/hw/pci-host/grackle.c @@ -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 = { diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index bf4221d4bf..2d02de12d9 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -685,7 +685,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 = { @@ -739,7 +739,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; } @@ -868,7 +868,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 = { diff --git a/hw/pci-host/ppce500.c b/hw/pci-host/ppce500.c index e502bc0505..becc0eeb76 100644 --- a/hw/pci-host/ppce500.c +++ b/hw/pci-host/ppce500.c @@ -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 = { diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index 260a119a9e..900a6edfcf 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -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 = { diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 344f77b10c..cd5c49616e 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -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 = { diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index df342ac3cb..6cf5e59f86 100644 --- a/hw/pci-host/uninorth.c +++ b/hw/pci-host/uninorth.c @@ -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 = { diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c index 27fde46126..aa1fdf75fd 100644 --- a/hw/pci-host/versatile.c +++ b/hw/pci-host/versatile.c @@ -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 = { diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index 8b71e2d950..a968cea2af 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -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 = { diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c index dc19682970..6953f8b9ac 100644 --- a/hw/ppc/ppc4xx_pci.c +++ b/hw/ppc/ppc4xx_pci.c @@ -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 = { diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index a1cdc875b1..9fa5545991 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -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 = { diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index a8a1bab50a..b60a8f22b0 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -872,7 +872,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; diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c index 1f2f0ed44a..4008c81002 100644 --- a/hw/sd/milkymist-memcard.c +++ b/hw/sd/milkymist-memcard.c @@ -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 = { diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index 82c63a4fb5..55c8098ecd 100644 --- a/hw/sd/pl181.c +++ b/hw/sd/pl181.c @@ -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; } diff --git a/hw/sh4/sh_pci.c b/hw/sh4/sh_pci.c index 1747628f3d..38395c082b 100644 --- a/hw/sh4/sh_pci.c +++ b/hw/sh4/sh_pci.c @@ -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 = { diff --git a/hw/timer/i8254_common.c b/hw/timer/i8254_common.c index e18299a482..976d5200f1 100644 --- a/hw/timer/i8254_common.c +++ b/hw/timer/i8254_common.c @@ -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 = { diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c index 4165450250..93de3e1cc5 100644 --- a/hw/timer/mc146818rtc.c +++ b/hw/timer/mc146818rtc.c @@ -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) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 4bf86b0ad8..e69489ec6c 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -103,16 +103,17 @@ 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. + * behavior would be cruel; clearing this flag will protect them. + * It should never be cleared without a comment explaining why it + * is cleared. * TODO remove once we're there */ - bool cannot_instantiate_with_device_add_yet; + bool user_creatable; bool hotpluggable; /* callbacks */ diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 1d69fa7a8f..d206fc93dd 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -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) \ diff --git a/monitor.c b/monitor.c index 078cba5c86..afbacfe1cb 100644 --- a/monitor.c +++ b/monitor.c @@ -3254,7 +3254,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); } diff --git a/qdev-monitor.c b/qdev-monitor.c index e61d596ef7..3ecbf0bd25 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -114,7 +114,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"); @@ -156,7 +156,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) { @@ -241,7 +241,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"); diff --git a/qom/cpu.c b/qom/cpu.c index f9111a02ba..50698767dd 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -453,7 +453,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 = { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 5e768404a1..a41d595c23 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4075,7 +4075,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 = { From e4f4fb1eca795e36f363b4647724221e774523c1 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:45 -0300 Subject: [PATCH 02/22] sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE 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 Cc: Alex Williamson Cc: Alistair Francis Cc: Beniamino Galvani Cc: Christian Borntraeger Cc: Cornelia Huck Cc: David Gibson Cc: "Edgar E. Iglesias" Cc: Eduardo Habkost Cc: Frank Blaschka Cc: Gabriel L. Somlo Cc: Gerd Hoffmann Cc: Igor Mammedov Cc: Jason Wang Cc: John Snow Cc: Juergen Gross Cc: Kevin Wolf Cc: Laszlo Ersek Cc: Marcel Apfelbaum Cc: Markus Armbruster Cc: Max Reitz Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Peter Maydell Cc: Pierre Morel Cc: Prasad J Pandit Cc: qemu-arm@nongnu.org Cc: qemu-block@nongnu.org Cc: qemu-ppc@nongnu.org Cc: Richard Henderson Cc: Rob Herring Cc: Shannon Zhao Cc: sstabellini@kernel.org Cc: Thomas Huth Cc: Yi Min Zhao Acked-by: John Snow Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-3-ehabkost@redhat.com> Reviewed-by: Markus Armbruster [ehabkost: Small changes at sysbus_device_class_init() comments] Signed-off-by: Eduardo Habkost --- 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(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 2e629b398b..5c28a0b0ad 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -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 = { diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 594d4cf6fe..ef71956433 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -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; } diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index c0f560b289..5d0887f499 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -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 a 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 can handle device_add/-device with + * a few specific sysbus devices. In those cases, the device + * subclass needs to override it and set user_creatable=true. + */ + k->user_creatable = false; } static const TypeInfo sysbus_device_type_info = { diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index f86a40aa30..7b92c8c15a 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -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 = { diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 02f047c8e3..54187a04a4 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3009,6 +3009,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 = { diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 13eca374cd..7665bef999 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -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 = { diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 98ca480792..348c405180 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -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 = { diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 82a49556af..45f6267c93 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -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 = { diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f60826d6e0..7f10cda354 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -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 = { diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 37c4386ae3..f9e4f77def 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -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 = { diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index 348e0eab9d..ad4ac3b4f6 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -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 = { diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c index bcbb585888..e446c1d652 100644 --- a/hw/misc/unimp.c +++ b/hw/misc/unimp.c @@ -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 = { diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index aa2b0d5a85..9da1932970 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -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 = { diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 316fca9bc1..7993aea792 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -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 = { diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index e7567e2e8f..a7cff32bbf 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1994,6 +1994,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; diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index eee831efeb..7bdc1e1b99 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -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 = { diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 6d6a791ee9..dbf61fccb8 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -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 = { diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index a2c18b30c3..4dcbd5bb3d 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -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 = { diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 3ada35e954..18b31022a7 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -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 = { diff --git a/hw/vfio/amd-xgbe.c b/hw/vfio/amd-xgbe.c index 2c60310cf9..fab196cebf 100644 --- a/hw/vfio/amd-xgbe.c +++ b/hw/vfio/amd-xgbe.c @@ -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 = { diff --git a/hw/vfio/calxeda-xgmac.c b/hw/vfio/calxeda-xgmac.c index bb15d588e5..7bb17af7ad 100644 --- a/hw/vfio/calxeda-xgmac.c +++ b/hw/vfio/calxeda-xgmac.c @@ -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 = { diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 5807aa87fe..6491a771ff 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -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 = { diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 2cac47d6c4..2df102a716 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -619,6 +619,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 = { @@ -662,6 +667,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 = { From 950b31dd17fccc42ecddc9528408b00a20c9be3c Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:46 -0300 Subject: [PATCH 03/22] xen-backend: Remove FIXME comment about user_creatable flag 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 , Cc: Peter Maydell , Cc: Thomas Huth Cc: sstabellini@kernel.org Cc: Markus Armbruster , Cc: Marcel Apfelbaum , Cc: Laszlo Ersek Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-4-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 2df102a716..8cc0e1e1e5 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -619,10 +619,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; } From 8ab5700ca07428d62a3e75c2c15aa7dc3e962b44 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:47 -0300 Subject: [PATCH 04/22] iommu: Remove FIXME comment about user_creatable=true 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 Cc: "Michael S. Tsirkin" Reviewed-by: Marcel Apfelbaum Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-5-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/amd_iommu.c | 5 +---- hw/i386/intel_iommu.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 7b92c8c15a..efcc93cbfd 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -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; } diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 54187a04a4..327a46cd19 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3009,10 +3009,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; } From 8ca97a1ff75a824337f5b30877efcbb4af2321e5 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:48 -0300 Subject: [PATCH 05/22] fdc: Remove user_creatable flag from sysbus-fdc & SUNW,fdtwo 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. Cc: John Snow Cc: Kevin Wolf Cc: Marcel Apfelbaum Cc: Max Reitz Cc: qemu-block@nongnu.org Cc: Thomas Huth Acked-by: John Snow Reviewed-by: Thomas Huth Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-6-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/block/fdc.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 5c28a0b0ad..2e629b398b 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -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 = { From c1ce65f710a9e1a4ae311731864743f0f5f2d348 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:49 -0300 Subject: [PATCH 06/22] pflash_cfi01: Remove user_creatable flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Cc: Laszlo Ersek Cc: Philippe Mathieu-Daudé Cc: Marcel Apfelbaum Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-7-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/block/pflash_cfi01.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index ef71956433..594d4cf6fe 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -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; } From 642c1e05460a12c70c87fc350a31e2d318c4bcce Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:50 -0300 Subject: [PATCH 07/22] kvmclock: Remove user_creatable flag 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: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Thomas Huth Acked-by: Marcel Apfelbaum Reviewed-by: Thomas Huth Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-8-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/kvm/clock.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index 7665bef999..13eca374cd 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -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 = { From 6c4672cae7bbae56c49dfa598e75dd02916c4bc5 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:51 -0300 Subject: [PATCH 08/22] ioapic: Remove user_creatable flag 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 Cc: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-9-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/kvm/ioapic.c | 5 ----- hw/intc/ioapic.c | 5 ----- 2 files changed, 10 deletions(-) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 348c405180..98ca480792 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -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 = { diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index f9e4f77def..37c4386ae3 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -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 = { From 040e99686ab22083452deeccdcdfe2e72e5a8c43 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:52 -0300 Subject: [PATCH 09/22] kvmvapic: Remove user_creatable flag 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 Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-10-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/kvmvapic.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 45f6267c93..82a49556af 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -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 = { From a081ab8f7b7b9eb72ead9201b5ece14d09fcc1c4 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:53 -0300 Subject: [PATCH 10/22] sysbus-ahci: Remove user_creatable flag 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 Cc: qemu-block@nongnu.org Cc: Rob Herring Cc: Peter Maydell Cc: Alistair Francis Cc: "Edgar E. Iglesias" Cc: Marcel Apfelbaum Reviewed-by: Alistair Francis Acked-by: John Snow Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-11-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/ide/ahci.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 7f10cda354..2ea1a282ef 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -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 = { From c803129ce51401e56981e771aa93a258fac7c0ea Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:54 -0300 Subject: [PATCH 11/22] allwinner-ahci: Remove user_creatable flag 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. Cc: John Snow Cc: qemu-block@nongnu.org Cc: Beniamino Galvani Cc: Peter Maydell Cc: qemu-arm@nongnu.org Cc: Marcel Apfelbaum Acked-by: John Snow Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-12-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/ide/ahci.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 2ea1a282ef..f60826d6e0 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -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 = { From 0980a1c0e2563701424d88e46b080dc09e85d75f Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:55 -0300 Subject: [PATCH 12/22] isabus-bridge: Remove user_creatable flag 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 Cc: "Michael S. Tsirkin" Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-13-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/isa/isa-bus.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index ad4ac3b4f6..348e0eab9d 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -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 = { From 68aecefcd4b348533b809ba77daa337931231e9a Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:56 -0300 Subject: [PATCH 13/22] unimplemented-device: Remove user_creatable flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Cc: Marcel Apfelbaum Cc: Peter Maydell Cc: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-14-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/misc/unimp.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c index e446c1d652..bcbb585888 100644 --- a/hw/misc/unimp.c +++ b/hw/misc/unimp.c @@ -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 = { From 731fec79aea4d8bba40464a0a266b4c3de816f6a Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:57 -0300 Subject: [PATCH 14/22] fw_cfg: Remove user_creatable flag 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: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Cc: Laszlo Ersek Cc: Gabriel L. Somlo Reviewed-by: Laszlo Ersek Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-15-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/nvram/fw_cfg.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7993aea792..316fca9bc1 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -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 = { From f4afad3878f7b2bfd5182bbde60a6b75a448b6d2 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:58 -0300 Subject: [PATCH 15/22] esp: Remove user_creatable flag 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. Cc: Marcel Apfelbaum Cc: Paolo Bonzini Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-16-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/scsi/esp.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 7bdc1e1b99..eee831efeb 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -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 = { From bdbae0ef01c433892f72ada7cb5df65884d5c875 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:35:59 -0300 Subject: [PATCH 16/22] generic-sdhci: Remove user_creatable flag 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 Cc: "Edgar E. Iglesias" Cc: David Gibson Cc: Alexander Graf Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: Prasad J Pandit Cc: Alistair Francis Reviewed-by: Alistair Francis Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-17-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/sd/sdhci.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index dbf61fccb8..6d6a791ee9 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -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 = { From cae9d4cdd49182997392cc6382780480b97cc9f7 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:00 -0300 Subject: [PATCH 17/22] hpet: Remove user_creatable flag 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: Marcel Apfelbaum Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-18-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/timer/hpet.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 4dcbd5bb3d..a2c18b30c3 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -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 = { From 8f04d26a4eb59708c96cb0c52c3a7c638a656380 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:01 -0300 Subject: [PATCH 18/22] sysbus-ohci: Remove user_creatable flag 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. Cc: Marcel Apfelbaum Cc: Gerd Hoffmann Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-19-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/usb/hcd-ohci.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 18b31022a7..3ada35e954 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -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 = { From ae3ac6cacac02e88899e62db0b2bb5713a6796be Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:02 -0300 Subject: [PATCH 19/22] virtio-mmio: Remove user_creatable flag 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: Laszlo Ersek Cc: Marcel Apfelbaum Cc: Peter Maydell Cc: Shannon Zhao Cc: "Michael S. Tsirkin" Reviewed-by: Laszlo Ersek Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-20-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/virtio/virtio-mmio.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 6491a771ff..5807aa87fe 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -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 = { From 74c505c6fde4bd129d7b41efda16d74f254eb0d5 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:03 -0300 Subject: [PATCH 20/22] xen-sysdev: Remove user_creatable flag 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 , Cc: Peter Maydell , Cc: Thomas Huth Cc: sstabellini@kernel.org Cc: Markus Armbruster , Cc: Marcel Apfelbaum , Cc: Laszlo Ersek Acked-by: Juergen Gross Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-21-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/xen/xen_backend.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 8cc0e1e1e5..3570f37e56 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -664,11 +664,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 = { From 8ae5059df5424def4a149fdc81e944ec5730fddf Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 3 May 2017 17:36:04 -0300 Subject: [PATCH 21/22] s390-pcibus: No need to set user_creatable=false explicitly 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 Cc: Christian Borntraeger Cc: Cornelia Huck Cc: Frank Blaschka Cc: Laszlo Ersek Cc: Marcel Apfelbaum Cc: Markus Armbruster Cc: Peter Maydell Cc: Pierre Morel Cc: Richard Henderson Cc: Thomas Huth Cc: Yi Min Zhao Acked-by: Cornelia Huck Acked-by: Marcel Apfelbaum Signed-off-by: Eduardo Habkost Message-Id: <20170503203604.31462-22-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- hw/s390x/s390-pci-bus.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b60a8f22b0..66a6fbeb8c 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -872,7 +872,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; From 17e8f541263fd771aef58e9818a2060b81904c3f Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 8 May 2017 15:32:05 -0300 Subject: [PATCH 22/22] tests: Add [+-]feature and feature=on|off test cases Add test code to ensure features are enabled/disabled correctly in the command-line. The test case use the "feature-words" and "filtered-features" properties to check if the features were enabled/disabled correctly. Signed-off-by: Eduardo Habkost Message-Id: <20170508183205.10884-1-ehabkost@redhat.com> Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- tests/test-x86-cpuid-compat.c | 111 ++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 79a2e69a28..6c71e46391 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -1,6 +1,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/qmp/qlist.h" +#include "qapi/qmp/qstring.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" @@ -78,6 +79,90 @@ static void add_cpuid_test(const char *name, const char *cmdline, qtest_add_data_func(name, args, test_cpuid_prop); } + +/* Parameters to a add_feature_test() test case */ +typedef struct FeatureTestArgs { + /* cmdline to start QEMU */ + const char *cmdline; + /* + * cpuid-input-eax and cpuid-input-ecx values to look for, + * in "feature-words" and "filtered-features" properties. + */ + uint32_t in_eax, in_ecx; + /* The register name to look for, in the X86CPUFeatureWordInfo array */ + const char *reg; + /* The bit to check in X86CPUFeatureWordInfo.features */ + int bitnr; + /* The expected value for the bit in (X86CPUFeatureWordInfo.features) */ + bool expected_value; +} FeatureTestArgs; + +/* Get the value for a feature word in a X86CPUFeatureWordInfo list */ +static uint32_t get_feature_word(QList *features, uint32_t eax, uint32_t ecx, + const char *reg) +{ + const QListEntry *e; + + for (e = qlist_first(features); e; e = qlist_next(e)) { + QDict *w = qobject_to_qdict(qlist_entry_obj(e)); + const char *rreg = qdict_get_str(w, "cpuid-register"); + uint32_t reax = qdict_get_int(w, "cpuid-input-eax"); + bool has_ecx = qdict_haskey(w, "cpuid-input-ecx"); + uint32_t recx = 0; + + if (has_ecx) { + recx = qdict_get_int(w, "cpuid-input-ecx"); + } + if (eax == reax && (!has_ecx || ecx == recx) && !strcmp(rreg, reg)) { + return qint_get_int(qobject_to_qint(qdict_get(w, "features"))); + } + } + return 0; +} + +static void test_feature_flag(const void *data) +{ + const FeatureTestArgs *args = data; + char *path; + QList *present, *filtered; + uint32_t value; + + qtest_start(args->cmdline); + path = get_cpu0_qom_path(); + present = qobject_to_qlist(qom_get(path, "feature-words")); + filtered = qobject_to_qlist(qom_get(path, "filtered-features")); + value = get_feature_word(present, args->in_eax, args->in_ecx, args->reg); + value |= get_feature_word(filtered, args->in_eax, args->in_ecx, args->reg); + qtest_end(); + + g_assert(!!(value & (1U << args->bitnr)) == args->expected_value); + + QDECREF(present); + QDECREF(filtered); + g_free(path); +} + +/* + * Add test case to ensure that a given feature flag is set in + * either "feature-words" or "filtered-features", when running QEMU + * using cmdline + */ +static FeatureTestArgs *add_feature_test(const char *name, const char *cmdline, + uint32_t eax, uint32_t ecx, + const char *reg, int bitnr, + bool expected_value) +{ + FeatureTestArgs *args = g_new0(FeatureTestArgs, 1); + args->cmdline = cmdline; + args->in_eax = eax; + args->in_ecx = ecx; + args->reg = reg; + args->bitnr = bitnr; + args->expected_value = expected_value; + qtest_add_data_func(name, args, test_feature_flag); + return args; +} + #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS static void test_plus_minus_subprocess(void) { @@ -229,5 +314,31 @@ int main(int argc, char **argv) "-machine pc-i440fx-2.7 -cpu 486,+xstore", "xlevel2", 0); + /* Test feature parsing */ + add_feature_test("x86/cpuid/features/plus", + "-cpu 486,+arat", + 6, 0, "EAX", 2, true); + add_feature_test("x86/cpuid/features/minus", + "-cpu pentium,-mmx", + 1, 0, "EDX", 23, false); + add_feature_test("x86/cpuid/features/on", + "-cpu 486,arat=on", + 6, 0, "EAX", 2, true); + add_feature_test("x86/cpuid/features/off", + "-cpu pentium,mmx=off", + 1, 0, "EDX", 23, false); + add_feature_test("x86/cpuid/features/max-plus-invtsc", + "-cpu max,+invtsc", + 0x80000007, 0, "EDX", 8, true); + add_feature_test("x86/cpuid/features/max-invtsc-on", + "-cpu max,invtsc=on", + 0x80000007, 0, "EDX", 8, true); + add_feature_test("x86/cpuid/features/max-minus-mmx", + "-cpu max,-mmx", + 1, 0, "EDX", 23, false); + add_feature_test("x86/cpuid/features/max-invtsc-on,mmx=off", + "-cpu max,mmx=off", + 1, 0, "EDX", 23, false); + return g_test_run(); }