Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MbTgr-0004W7-9S for qemu-devel@nongnu.org; Thu, 13 Aug 2009 02:21:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MbTgl-0004TZ-GC for qemu-devel@nongnu.org; Thu, 13 Aug 2009 02:21:31 -0400 Received: from [199.232.76.173] (port=48249 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbTgl-0004TD-1v for qemu-devel@nongnu.org; Thu, 13 Aug 2009 02:21:27 -0400 Received: from mx2.redhat.com ([66.187.237.31]:58122) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MbTgk-0004gx-2K for qemu-devel@nongnu.org; Thu, 13 Aug 2009 02:21:26 -0400 Subject: Re: [Qemu-devel] [PATCH] qdev: add return value to init() callbacks. References: <1250092766-23986-1-git-send-email-kraxel@redhat.com> <200908122028.41012.paul@codesourcery.com> <4A831C47.3070309@redhat.com> From: Markus Armbruster Date: Thu, 13 Aug 2009 08:17:20 +0200 In-Reply-To: <4A831C47.3070309@redhat.com> (Gerd Hoffmann's message of "Wed\, 12 Aug 2009 21\:47\:19 +0200") Message-ID: <873a7w2q6n.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: Paul Brook , qemu-devel@nongnu.org Gerd Hoffmann writes: > On 08/12/09 21:28, Paul Brook wrote: >>> We have already one case in-tree where this is needed: >>> Try -device virtio-blk-pci (without drive= specified) and watch qemu >>> segfault. >> >> No. Failure of the init routine should be fatal. i.e. virtio_blk_init_pci >> should call hw_error. > > No. That policy doesn't belong there. > >> If you want to allow graceful failure (which is pointless for commandline >> options, but may be desirable for hotplug devices) > > Exactly. And for that reason we must pass up the error to the > caller. The caller can then decide what to do with it. For devices > added via command line options we probably want to exit(1). For > hotplugging we probably would not. exit(1) on typo in the monitor is not nice. One problem with passing up error codes is diagnostics: when we reach the point where we can decide on policy, we've lost the context for precise diagnostics. net.c tackles that problem by passing the destination for diagnostics down, to let code report errors with config_error() while remaining unaware of policy. >> they you need to also add >> some way of reporting why device creation failure. fprintf(stderr) is just >> plain wrong. > > Indeed. When hotplugging via monitor the error message should appear > on the monitor, not stderr. It is already an item on my todo list. Issue also exists elsewhere. Try monitor command "pci_add auto model=?". > I'd prefer to address that in a separate patch though, the patch is > already big and invasive enough as-is. It's easy to review for its size precisely because it does just one simple thing. Let's keep it that way.