From patchwork Wed Apr 1 15:03:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 457270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F0663140079 for ; Thu, 2 Apr 2015 02:04:03 +1100 (AEDT) Received: from localhost ([::1]:53166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKBW-0003O0-4e for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2015 11:04:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAq-00028f-0a for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdKAl-0006w1-0V for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAk-0006vh-QD for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t31F3BrO012772 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 Apr 2015 11:03:11 -0400 Received: from blackfin.pond.sub.org (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t31F38bv004595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Apr 2015 11:03:10 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8E256305CAAF; Wed, 1 Apr 2015 17:03:06 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 1 Apr 2015 17:03:06 +0200 Message-Id: <1427900586-5358-6-git-send-email-armbru@redhat.com> In-Reply-To: <1427900586-5358-1-git-send-email-armbru@redhat.com> References: <1427900586-5358-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, Peter Crosthwaite , Michael Walle , Antony Pavlov , pbonzini@redhat.com, "Edgar E. Iglesias" Subject: [Qemu-devel] [PULL 5/5] sysbus: Make devices picking up backends unavailable with -device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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/arm/spitz.c | 2 ++ hw/char/cadence_uart.c | 2 ++ hw/char/digic-uart.c | 2 ++ hw/char/etraxfs_ser.c | 2 ++ hw/char/lm32_juart.c | 2 ++ hw/char/lm32_uart.c | 2 ++ hw/char/milkymist-uart.c | 2 ++ hw/char/pl011.c | 2 ++ hw/char/stm32f2xx_usart.c | 2 ++ hw/char/xilinx_uartlite.c | 2 ++ hw/sd/milkymist-memcard.c | 2 ++ hw/sd/pl181.c | 2 ++ hw/sd/sdhci.c | 2 ++ 13 files changed, 26 insertions(+) diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index da02932..5bf032a 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -1036,6 +1036,8 @@ static void sl_nand_class_init(ObjectClass *klass, void *data) k->init = sl_nand_init; 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; } static const TypeInfo sl_nand_info = { diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 4f38f0c..d145378 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -537,6 +537,8 @@ static void cadence_uart_class_init(ObjectClass *klass, void *data) dc->realize = cadence_uart_realize; dc->vmsd = &vmstate_cadence_uart; dc->reset = cadence_uart_reset; + /* Reason: realize() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo cadence_uart_info = { diff --git a/hw/char/digic-uart.c b/hw/char/digic-uart.c index f272491..6d44576 100644 --- a/hw/char/digic-uart.c +++ b/hw/char/digic-uart.c @@ -177,6 +177,8 @@ static void digic_uart_class_init(ObjectClass *klass, void *data) dc->realize = digic_uart_realize; dc->reset = digic_uart_reset; dc->vmsd = &vmstate_digic_uart; + /* Reason: realize() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo digic_uart_info = { diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c index 3381b86..857c136 100644 --- a/hw/char/etraxfs_ser.c +++ b/hw/char/etraxfs_ser.c @@ -236,6 +236,8 @@ static void etraxfs_ser_class_init(ObjectClass *klass, void *data) k->init = etraxfs_ser_init; dc->reset = etraxfs_ser_reset; + /* Reason: init() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo etraxfs_ser_info = { diff --git a/hw/char/lm32_juart.c b/hw/char/lm32_juart.c index 03285da..62763f2 100644 --- a/hw/char/lm32_juart.c +++ b/hw/char/lm32_juart.c @@ -145,6 +145,8 @@ static void lm32_juart_class_init(ObjectClass *klass, void *data) k->init = lm32_juart_init; dc->reset = juart_reset; dc->vmsd = &vmstate_lm32_juart; + /* Reason: init() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo lm32_juart_info = { diff --git a/hw/char/lm32_uart.c b/hw/char/lm32_uart.c index 39cad49..837a46e 100644 --- a/hw/char/lm32_uart.c +++ b/hw/char/lm32_uart.c @@ -285,6 +285,8 @@ static void lm32_uart_class_init(ObjectClass *klass, void *data) k->init = lm32_uart_init; dc->reset = uart_reset; dc->vmsd = &vmstate_lm32_uart; + /* Reason: init() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo lm32_uart_info = { diff --git a/hw/char/milkymist-uart.c b/hw/char/milkymist-uart.c index b79ea09..9b89b7e 100644 --- a/hw/char/milkymist-uart.c +++ b/hw/char/milkymist-uart.c @@ -235,6 +235,8 @@ static void milkymist_uart_class_init(ObjectClass *klass, void *data) dc->realize = milkymist_uart_realize; dc->reset = milkymist_uart_reset; dc->vmsd = &vmstate_milkymist_uart; + /* Reason: realize() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo milkymist_uart_info = { diff --git a/hw/char/pl011.c b/hw/char/pl011.c index d1cf00f..eac6fac 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -308,6 +308,8 @@ static void pl011_class_init(ObjectClass *oc, void *data) dc->realize = pl011_realize; dc->vmsd = &vmstate_pl011; + /* Reason: realize() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo pl011_arm_info = { diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c index 669c4e3..c9d3a1b 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 = { diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c index cb54684..ef883a8 100644 --- a/hw/char/xilinx_uartlite.c +++ b/hw/char/xilinx_uartlite.c @@ -228,6 +228,8 @@ static void xilinx_uartlite_class_init(ObjectClass *klass, void *data) dc->reset = xilinx_uartlite_reset; dc->realize = xilinx_uartlite_realize; + /* Reason: realize() method uses qemu_char_get_next_serial() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo xilinx_uartlite_info = { diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c index 0cc53d9..2209ef1 100644 --- a/hw/sd/milkymist-memcard.c +++ b/hw/sd/milkymist-memcard.c @@ -297,6 +297,8 @@ static void milkymist_memcard_class_init(ObjectClass *klass, void *data) k->init = milkymist_memcard_init; 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; } static const TypeInfo milkymist_memcard_info = { diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index bf37da6..11fcd47 100644 --- a/hw/sd/pl181.c +++ b/hw/sd/pl181.c @@ -508,6 +508,8 @@ static void pl181_class_init(ObjectClass *klass, void *data) sdc->init = pl181_init; k->vmsd = &vmstate_pl181; k->reset = pl181_reset; + /* Reason: init() method uses drive_get_next() */ + k->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo pl181_info = { diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index ab13505..e63367b 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1297,6 +1297,8 @@ static void sdhci_sysbus_class_init(ObjectClass *klass, void *data) dc->vmsd = &sdhci_vmstate; dc->props = sdhci_properties; dc->realize = sdhci_sysbus_realize; + /* Reason: instance_init() method uses drive_get_next() */ + dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo sdhci_sysbus_info = {