From nobody Thu Nov 6 14:21:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542190996137684.3204456652765; Wed, 14 Nov 2018 02:23:16 -0800 (PST) Received: from localhost ([::1]:59332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMsKG-0008Bz-NV for importer@patchew.org; Wed, 14 Nov 2018 05:23:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMsJN-0007iF-Sd for qemu-devel@nongnu.org; Wed, 14 Nov 2018 05:22:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMsJK-0001Fd-AF for qemu-devel@nongnu.org; Wed, 14 Nov 2018 05:22:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMsJK-0001F3-0T; Wed, 14 Nov 2018 05:22:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D533C05000F; Wed, 14 Nov 2018 10:22:13 +0000 (UTC) Received: from localhost (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDA6460BF6; Wed, 14 Nov 2018 10:22:06 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 14 Nov 2018 11:16:10 +0100 Message-Id: <20181114101610.26854-2-cohuck@redhat.com> In-Reply-To: <20181114101610.26854-1-cohuck@redhat.com> References: <20181114101610.26854-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 14 Nov 2018 10:22:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-3.1 1/1] s390x/pci: properly fail if the zPCI device cannot be created 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: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Right now, errors during realize()/pre_plug/plug of the zPCI device would result in QEMU crashing instead of failing nicely when creating a zPCI device for a PCI device. Reviewed-by: Thomas Huth Reviewed-by: Collin Walling Signed-off-by: David Hildenbrand Message-Id: <20181113121710.18490-1-david@redhat.com> Signed-off-by: Cornelia Huck --- hw/s390x/s390-pci-bus.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index e42e1b80d6..060ff062bc 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -780,17 +780,31 @@ static void s390_pci_msix_free(S390PCIBusDevice *pbde= v) } =20 static S390PCIBusDevice *s390_pci_device_new(S390pciState *s, - const char *target) + const char *target, Error **e= rrp) { - DeviceState *dev =3D NULL; + Error *local_err =3D NULL; + DeviceState *dev; =20 dev =3D qdev_try_create(BUS(s->bus), TYPE_S390_PCI_DEVICE); if (!dev) { + error_setg(errp, "zPCI device could not be created"); return NULL; } =20 - qdev_prop_set_string(dev, "target", target); - qdev_init_nofail(dev); + object_property_set_str(OBJECT(dev), target, "target", &local_err); + if (local_err) { + object_unparent(OBJECT(dev)); + error_propagate_prepend(errp, local_err, + "zPCI device could not be created: "); + return NULL; + } + object_property_set_bool(OBJECT(dev), true, "realized", &local_err); + if (local_err) { + object_unparent(OBJECT(dev)); + error_propagate_prepend(errp, local_err, + "zPCI device could not be created: "); + return NULL; + } =20 return S390_PCI_DEVICE(dev); } @@ -865,9 +879,8 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotpl= ug_dev, =20 pbdev =3D s390_pci_find_dev_by_target(s, dev->id); if (!pbdev) { - pbdev =3D s390_pci_device_new(s, dev->id); + pbdev =3D s390_pci_device_new(s, dev->id, errp); if (!pbdev) { - error_setg(errp, "create zpci device failed"); return; } } --=20 2.17.2