From nobody Thu Apr 25 10:44:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547132115628883.5731185614025; Thu, 10 Jan 2019 06:55:15 -0800 (PST) Received: from localhost ([127.0.0.1]:41762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbji-00068I-LH for importer@patchew.org; Thu, 10 Jan 2019 09:55:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbMH-0004Vr-BM for qemu-devel@nongnu.org; Thu, 10 Jan 2019 09:31:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbMA-0006Bb-Eo for qemu-devel@nongnu.org; Thu, 10 Jan 2019 09:30:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ghbM7-00068N-CN for qemu-devel@nongnu.org; Thu, 10 Jan 2019 09:30:48 -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 A68967AEAC; Thu, 10 Jan 2019 14:30:44 +0000 (UTC) Received: from localhost (ovpn-116-5.gru2.redhat.com [10.97.116.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F5E560BE7; Thu, 10 Jan 2019 14:30:43 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 12:29:54 -0200 Message-Id: <20190110142955.23254-10-ehabkost@redhat.com> In-Reply-To: <20190110142955.23254-1-ehabkost@redhat.com> References: <20190110142955.23254-1-ehabkost@redhat.com> MIME-Version: 1.0 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.25]); Thu, 10 Jan 2019 14:30:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 09/10] qdev: fix -device scsi-hd, help regression 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Since commit ea9ce8934, device_post_init() applies globals directly from machines and accelerator classes. There are cases, such as -device scsi-hd,help, where the machine is setup but there in no accelerator. Let's skip accelerator globals in this case. Fixes SEGV: #0 0x0000555558ea04ff in object_get_class (obj=3D0x0) at /home/elmarco/sr= c/qemu/build/../qom/object.c:857 #1 0x000055555854c797 in object_apply_compat_props (obj=3D0x616000078980)= at /home/elmarco/src/qemu/build/../hw/core/qdev.c:978 #2 0x000055555854c797 in object_apply_compat_props (obj=3D0x616000078980)= at /home/elmarco/src/qemu/build/../hw/core/qdev.c:973 #3 0x000055555854c959 in device_post_init (obj=3D0x616000078980) at /home= /elmarco/src/qemu/build/../hw/core/qdev.c:989 #4 0x0000555558e9e250 in object_post_init_with_type (ti=3D= , obj=3D0x616000078980) at /home/elmarco/src/qemu/build/../qom/object.c:365 #5 0x0000555558e9e250 in object_initialize_with_type (data=3D0x6160000789= 80, size=3D616, type=3D) at /home/elmarco/src/qemu/build/../= qom/object.c:425 #6 0x0000555558e9e571 in object_new_with_type (type=3D0x613000031900) at = /home/elmarco/src/qemu/build/../qom/object.c:588 #7 0x000055555830c048 in qmp_device_list_properties (typename=3Dtypename@= entry=3D0x60200000c2d0 "scsi-hd", errp=3Derrp@entry=3D0x7fffffffc540) at /h= ome/elmarco/src/qemu/qmp.c:519 #8 0x00005555582c4027 in qdev_device_help (opts=3D) at /ho= me/elmarco/src/qemu/qdev-monitor.c:283 #9 0x0000555559378fa2 in qemu_opts_foreach (list=3D, func= =3Dfunc@entry=3D0x5555582cfca0 , opaque=3Dopaque@entry=3D= 0x0, errp=3Derrp@entry=3D0x0) at /home/elmarco/src/qemu/util/qemu-option.c:= 1171 https://bugzilla.redhat.com/show_bug.cgi?id=3D1664364 Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20190109102311.7635-1-marcandre.lureau@redhat.com> Reviewed-by: Cornelia Huck Reviewed-by: Luk=C3=A1=C5=A1 Doktor Reviewed-by: Igor Mammedov Signed-off-by: Eduardo Habkost --- hw/core/qdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 3769a2bccb..47bddacb4f 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -975,10 +975,13 @@ void object_apply_compat_props(Object *obj) if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) { MachineState *m =3D MACHINE(qdev_get_machine()); MachineClass *mc =3D MACHINE_GET_CLASS(m); - AccelClass *ac =3D ACCEL_GET_CLASS(m->accelerator); =20 - if (ac->compat_props) { - object_apply_global_props(obj, ac->compat_props, &error_abort); + if (m->accelerator) { + AccelClass *ac =3D ACCEL_GET_CLASS(m->accelerator); + + if (ac->compat_props) { + object_apply_global_props(obj, ac->compat_props, &error_ab= ort); + } } object_apply_global_props(obj, mc->compat_props, &error_abort); } --=20 2.18.0.rc1.1.g3f1ff2140