From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdgbG-0006bG-BL for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:18:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tdgb9-00070I-Rv for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:18:46 -0500 Received: from mx3-phx2.redhat.com ([209.132.183.24]:59004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tdgb9-00070C-KB for qemu-devel@nongnu.org; Wed, 28 Nov 2012 07:18:39 -0500 Date: Wed, 28 Nov 2012 07:18:38 -0500 (EST) From: Alon Levy Message-ID: <1693523574.39001274.1354105118990.JavaMail.root@redhat.com> In-Reply-To: <50B5FD52.40209@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] hw/qdev-monitor: report error for -device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: armbru@redhat.com, Luiz Capitulino , qemu-devel@nongnu.org, afaerber@suse.de > Il 28/11/2012 12:54, Luiz Capitulino ha scritto: > > On Wed, 28 Nov 2012 10:54:33 +0200 > > Alon Levy wrote: > > > >> Instead of aborting immediately after at DEVICE_CLASS(obj) > >> > >> Signed-off-by: Alon Levy > >> --- > >> hw/qdev-monitor.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c > >> index 479eecd..3b70cdb 100644 > >> --- a/hw/qdev-monitor.c > >> +++ b/hw/qdev-monitor.c > >> @@ -426,6 +426,11 @@ DeviceState *qdev_device_add(QemuOpts *opts) > >> return NULL; > >> } > >> > >> + if (!object_class_dynamic_cast(obj, "device")) { > >> + qerror_report(QERR_INVALID_PARAMETER_TYPE, "driver", > >> "device type"); > >> + return NULL; > >> + } > > > > Gives me the impression that something is wrong before this, but > > it's > > better to ask a QOM guy (CC'ing them). > > I would reuse the same error message as for "if (!obj)", and also use > TYPE_DEVICE instead of the hardcoded string, but the patch is ok. > > > How do you reproduce it btw? > > $ x86_64-softmmu/qemu-system-x86_64 -device SCSI > Object 0x7f56872248b0 is not an instance of type device > Aborted > > However, we also need an object_class_is_abstract method to fix this > similar failure: > > $ x86_64-softmmu/qemu-system-x86_64 -device pci-device > ** > ERROR:/home/pbonzini/work/upstream/qemu/qom/object.c:306:object_initialize_with_type: > assertion failed: (type->abstract == false) > Aborted > > All in all, it makes sense to me that we delay this post-1.3. I agree, I'll keep it until then. > > Paolo > > >> + > >> k = DEVICE_CLASS(obj); > >> > >> /* find bus */ > > > > >