From efec3dd631d94160288392721a5f9c39e50fb2bc Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 28 Nov 2013 17:26:54 +0100 Subject: qdev: Replace no_user by cannot_instantiate_with_device_add_yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In an ideal world, machines can be built by wiring devices together with configuration, not code. Unfortunately, that's not the world we live in right now. We still have quite a few devices that need to be wired up by code. If you try to device_add such a device, it'll fail in sometimes mysterious ways. If you're lucky, you get an unmysterious immediate crash. To protect users from such badness, DeviceClass member no_user used to make device models unavailable with -device / device_add, but that regressed in commit 18b6dad. The device model is still omitted from help, but is available anyway. Attempts to fix the regression have been rejected with the argument that the purpose of no_user isn't clear, and it's prone to misuse. This commit clarifies no_user's purpose. Anthony suggested to rename it cannot_instantiate_with_device_add_yet_due_to_internal_bugs, which I shorten somewhat to keep checkpatch happy. While there, make it bool. Every use of cannot_instantiate_with_device_add_yet gets a FIXME comment asking for rationale. The next few commits will clean them all up, either by providing a rationale, or by getting rid of the use. With that done, the regression fix is hopefully acceptable. Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Signed-off-by: Andreas Färber --- hw/misc/arm_l2x0.c | 2 +- hw/misc/vmport.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'hw/misc') diff --git a/hw/misc/arm_l2x0.c b/hw/misc/arm_l2x0.c index 8e192cdf83..ceea99dd0e 100644 --- a/hw/misc/arm_l2x0.c +++ b/hw/misc/arm_l2x0.c @@ -179,7 +179,7 @@ static void l2x0_class_init(ObjectClass *klass, void *data) k->init = l2x0_priv_init; dc->vmsd = &vmstate_l2x0; - dc->no_user = 1; + dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */ dc->props = l2x0_properties; dc->reset = l2x0_priv_reset; } diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c index 0b5a5644e4..94ae6aeaae 100644 --- a/hw/misc/vmport.c +++ b/hw/misc/vmport.c @@ -162,7 +162,7 @@ static void vmport_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = vmport_realizefn; - dc->no_user = 1; + dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */ } static const TypeInfo vmport_info = { -- cgit v1.2.1 From 837d37167dc446af8a91189108b363c04609e296 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 28 Nov 2013 17:26:55 +0100 Subject: sysbus: Set cannot_instantiate_with_device_add_yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 could not possibly work. Quite a few, but not all sysbus devices already set cannot_instantiate_with_device_add_yet in their class init function. Set it in their abstract base's class init function sysbus_device_class_init(), and remove the now redundant assignments from device class init functions. Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Signed-off-by: Andreas Färber --- hw/misc/arm_l2x0.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/misc') diff --git a/hw/misc/arm_l2x0.c b/hw/misc/arm_l2x0.c index ceea99dd0e..9e220c9a56 100644 --- a/hw/misc/arm_l2x0.c +++ b/hw/misc/arm_l2x0.c @@ -179,7 +179,6 @@ static void l2x0_class_init(ObjectClass *klass, void *data) k->init = l2x0_priv_init; dc->vmsd = &vmstate_l2x0; - dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */ dc->props = l2x0_properties; dc->reset = l2x0_priv_reset; } -- cgit v1.2.1 From f3b176402fa92149320dcd5479916ccb39cfa0a8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 28 Nov 2013 17:27:02 +0100 Subject: isa: Clean up use of cannot_instantiate_with_device_add_yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drop it when there's no obvious reason why device_add could not work. Else keep and document why. * isa-fdc: drop * i8042: drop, even though its I/O base is hardcoded (because you could conceivably still add one to a board that has none), and even though PC board code wires up the A20 line (because that wiring is optional) * port92: keep because it needs additional wiring by port92_init() * mc146818rtc: keep because it needs to be wired up by rtc_init() * m48t59_isa: keep because needs to be wired up by m48t59_init_isa() * isa-pit, kvm-pit: keep (in their abstract base pic-common) because the PIT needs additional wiring by board code, depending on HPET presence * pcspk: keep because of pointer property pit, and because realize sets global pcspk_state * vmmouse: keep because of pointer property ps2_mouse * vmport: keep because realize sets global port_state * isa-i8259, kvm-i8259: keep (in their abstract base pic-common), because the PICs' IRQ input lines are set up by board code, and the wiring of the slave to the master is hard-coded in device model code Signed-off-by: Markus Armbruster Signed-off-by: Andreas Färber --- hw/misc/vmport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/misc') diff --git a/hw/misc/vmport.c b/hw/misc/vmport.c index 94ae6aeaae..cd5716a46d 100644 --- a/hw/misc/vmport.c +++ b/hw/misc/vmport.c @@ -162,7 +162,8 @@ static void vmport_class_initfn(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = vmport_realizefn; - dc->cannot_instantiate_with_device_add_yet = true; /* FIXME explain why */ + /* Reason: realize sets global port_state */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo vmport_info = { -- cgit v1.2.1