From patchwork Tue Apr 10 12:17:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 133084 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1244814ljb; Tue, 10 Apr 2018 05:29:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Cv6Y+YlfjaDyhHKgdgMC9rb4eS6IhfplfIVxBfKKKOaTG9E0qDG50vlYDSJUB+VT4v5yo X-Received: by 10.237.54.161 with SMTP id f30mr325395qtb.128.1523363357115; Tue, 10 Apr 2018 05:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523363357; cv=none; d=google.com; s=arc-20160816; b=nwacBmkcBn2w0wvbwgl4mpwY6E14X1LwlfbKm6VHFtSIFJ25YAQIzzYW0ZGRkdj3XD 4lz39ZfeKti198uAAyzkvpF6ZGGyxohXew/30VwuSo87kdkQxwOkC5EKXyE46x/SapEv KtiV96IMJ5gO3L0TOGlRp/5lurTzxClzD/j71uj3NSYiDpUjfmJAtYmPYH4THOly+3si NXykmIVZRaKkyGKWeJKzK+kCnad/fpG2veq+vsgayBY67qCJQw0ip0RUBV+87oPBseM8 z7VivhmRqvIA3Zo6ANzkXJJB03XRisOBZOTEgrak80UHs/AeUgOSzMdCLoKJQzO3Cdrp 0DNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=rsUziFq3xEXqjlK0Aqz55NFs1p8gkJkqLUABO+2T0vs=; b=npS3lNYdjjbTXeApDNuN82WqSxaMe3P0dw1fZHfXR11JAaa9QBE/PFK4CHZjNa6jmm jXy7Rb/NCDVUMNYOC4ZIfPJvrm8lArCEGBMFZqjnMkMnOy3L8/BI+vdX1wlSxrIAXDEO 3EzhOnb65OEcs6uJOB0snMWmkX3YqLJspPOx0qgI3P0YQUjTprPg6cnOgnUkKEDSQoud WArdeFh3+FfoL6iihNE8Zs6LBAltBKmQ4qYx14525442NM0rmqWcgMiMdvcGnf5AmptU Cf+gJ11rM9zDQv0qGyRb0PJELxNjOEghojuuEVMqHNzlhBg1Kb8NqFgE3F0UnuUkJ4wB w+Sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 12si827250qkj.2.2018.04.10.05.29.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 10 Apr 2018 05:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sOi-0000Zz-HP for patch@linaro.org; Tue, 10 Apr 2018 08:29:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5sDY-0007zI-5S for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5sDS-0000jr-1G for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:44 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:40760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5sDR-0000er-Pw for qemu-devel@nongnu.org; Tue, 10 Apr 2018 08:17:37 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1f5sDK-0007bi-Vj for qemu-devel@nongnu.org; Tue, 10 Apr 2018 13:17:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 13:17:18 +0100 Message-Id: <20180410121724.8549-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180410121724.8549-1-peter.maydell@linaro.org> References: <20180410121724.8549-1-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 06/12] hw/arm/allwinner-a10: Do not use nd_table in instance_init function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth The instance_init function of a device can be called at any time, even if the device is not going to be used (i.e. not going to be realized). So a instance_init function must not do things that could cause QEMU to exit, like calling qemu_check_nic_model(&nd_table[0], ...) for example. But this is what the instance_init function of the allwinner-a10 device is currently doing - and this causes QEMU to quit unexpectedly when you run the 'device-list-properties' QMP command for example: $ echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ " 'arguments':{'typename':'allwinner-a10'}}" \ | arm-softmmu/qemu-system-arm -M mps2-an505,accel=qtest -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} Unsupported NIC model: lan9118 ... and QEMU quits after printing the last line (which should not happen just because of running 'device-list-properties' here). And with the cubieboard, this even causes QEMU to abort(): $ echo "{'execute':'qmp_capabilities'}"\ "{'execute':'device-list-properties',"\ " 'arguments':{'typename':'allwinner-a10'}}" \ | arm-softmmu/qemu-system-arm -M cubieboard,accel=qtest -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 11, "major": 2}, "package": "build-all"}, "capabilities": []}} {"return": {}} Unexpected error in error_set_from_qdev_prop_error() at hw/core/qdev-properties.c:1095: Property 'allwinner-emac.netdev' can't take value 'hub0port0', it's in use Aborted (core dumped) To fix the problem we've got to move the offending code to the realize function instead. Signed-off-by: Thomas Huth Message-id: 1522862420-7484-1-git-send-email-thuth@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/allwinner-a10.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.16.2 diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index 43a3f01f45..5dbbacb7e8 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -38,11 +38,6 @@ 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]); - } object_initialize(&s->sata, sizeof(s->sata), TYPE_ALLWINNER_AHCI); qdev_set_parent_bus(DEVICE(&s->sata), sysbus_get_default()); @@ -91,6 +86,11 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) sysbus_connect_irq(sysbusdev, 4, s->irq[67]); sysbus_connect_irq(sysbusdev, 5, s->irq[68]); + /* 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]); + } object_property_set_bool(OBJECT(&s->emac), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); @@ -118,7 +118,7 @@ static void aw_a10_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); dc->realize = aw_a10_realize; - /* Reason: Uses serial_hds in realize and nd_table in instance_init */ + /* Reason: Uses serial_hds and nd_table in realize function */ dc->user_creatable = false; }