From d71b22bb6ae281e66dfa17733105468f830a8c6a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 25 Mar 2015 09:29:20 +0100 Subject: hw: Mark devices picking up char backends actively FIXME MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Character devices defined with -serial and -parallel are for board initialization to wire up. Board code examines serial_hds[] and parallel_hds[] to find them, and creates devices with their qdev chardev properties set accordingly. Except a few devices go on a fishing expedition for a suitable backend instead of exposing a chardev property for board code to set: they use serial_hds[] (often via qemu_char_get_next_serial()) or parallel_hds[] in their realize() or init() method to connect to a backend. Picking up backends that way works when the devices are created by board code. But it's inappropriate for -device or device_add. Not only is it inconsistent with how the other characrer device models work (they connect to a backend explicitly identified by a "chardev" property), it breaks when the backend has been picked up by the board or a previous -device / device_add already. Example: $ qemu-system-ppc64 -M bamboo -S -device i82378 -device pc87312 -device pc87312 qemu-system-ppc64: -device pc87312: Property 'isa-parallel.chardev' can't take value 'parallel0', it's in use Mark them with suitable FIXME comments. Cc: Li Guang Cc: Peter Crosthwaite Cc: Antony Pavlov Cc: "Edgar E. Iglesias" Cc: Michael Walle Cc: Peter Crosthwaite Cc: "Andreas Färber" Signed-off-by: Markus Armbruster --- hw/char/stm32f2xx_usart.c | 1 + 1 file changed, 1 insertion(+) (limited to 'hw/char/stm32f2xx_usart.c') diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 260b053044..669c4e3b6f 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -198,6 +198,7 @@ static void stm32f2xx_usart_init(Object *obj) TYPE_STM32F2XX_USART, 0x2000); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); + /* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ s->chr = qemu_char_get_next_serial(); if (s->chr) { -- cgit v1.2.3 From 9f9bdf43cac28251f8cb33b77fed5e19225375c4 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 23 Mar 2015 19:34:40 +0100 Subject: sysbus: Make devices picking up backends unavailable with -device Device models aren't supposed to go on fishing expeditions for backends. They should expose suitable properties for the user to set. For onboard devices, board code sets them. A number of sysbus devices pick up block backends in their init() / instance_init() methods with drive_get_next() instead: sl-nand, milkymist-memcard, pl181, generic-sdhci. Likewise, a number of sysbus devices pick up character backends in their init() / realize() methods with qemu_char_get_next_serial(): cadence_uart, digic-uart, etraxfs,serial, lm32-juart, lm32-uart, milkymist-uart, pl011, stm32f2xx-usart, xlnx.xps-uartlite. All these mistakes are already marked FIXME. See the commit that added these FIXMEs for a more detailed explanation of what's wrong. Fortunately, only machines ppce500 and pseries-* support -device with sysbus devices, and none of the devices above is supported with these machines. Set cannot_instantiate_with_device_add_yet to preserve our luck. Cc: Andrzej Zaborowski Cc: Peter Crosthwaite Cc: Antony Pavlov Cc: "Edgar E. Iglesias" Cc: Michael Walle Signed-off-by: Markus Armbruster --- hw/char/stm32f2xx_usart.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'hw/char/stm32f2xx_usart.c') diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 669c4e3b6f..c9d3a1be77 100644 --- a/hw/char/stm32f2xx_usart.c +++ b/hw/char/stm32f2xx_usart.c @@ -212,6 +212,8 @@ static void stm32f2xx_usart_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->reset = stm32f2xx_usart_reset; + /* Reason: instance_init() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo stm32f2xx_usart_info = { -- cgit v1.2.3