From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAq-0002A0-Ui for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdKAq-0006xk-1U for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAp-0006xP-M9 for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:19 -0400 From: Markus Armbruster Date: Wed, 1 Apr 2015 17:03:04 +0200 Message-Id: <1427900586-5358-4-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> Subject: [Qemu-devel] [PULL 3/5] hw: Mark device misusing nd_table[] FIXME List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Li Guang , peter.maydell@linaro.org NICs defined with -net nic are for board initialization to wire up. Board code examines nd_table[] to find them, and creates devices with their qdev NIC properties set accordingly. Except "allwinner-a10" goes on a fishing expedition for NIC configuration instead of exposing the usual NIC properties for board code to set: it uses nd_table[0] in its instance_init() method. Picking up the first -net nic option's configuration that way works when the device is created by board code. But it's inappropriate for -device and device_add. Not only is it inconsistent with how the other block device models work (they get their configuration from properties "mac", "vlan", "netdev"), it breaks when nd_table[0] has been picked up by the board or a previous -device / device_add already. Example: $ qemu-system-arm -S -M cubieboard -device allwinner-a10 qemu-system-arm: -device allwinner-a10: Property 'allwinner-emac.netdev' can't take value 'hub0port0', it's in use Aborted (core dumped) It also breaks in other entertaining ways: $ qemu-system-arm -M highbank -device allwinner-a10 qemu-system-arm: -device allwinner-a10: Unsupported NIC model: xgmac $ qemu-system-arm -M highbank -net nic,model=allwinner-emac -device allwinner-a10 qemu-system-arm: Unsupported NIC model: allwinner-emac Mark the mistake with a FIXME comment. Cc: Li Guang Signed-off-by: Markus Armbruster --- hw/arm/allwinner-a10.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 86965a7..ff249af 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -34,6 +34,7 @@ static void aw_a10_init(Object *obj) object_initialize(&s->emac, sizeof(s->emac), TYPE_AW_EMAC); qdev_set_parent_bus(DEVICE(&s->emac), sysbus_get_default()); + /* FIXME use qdev NIC properties instead of nd_table[] */ if (nd_table[0].used) { qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC); qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]); -- 1.9.3