From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZovbU-00027m-7s for qemu-devel@nongnu.org; Wed, 21 Oct 2015 11:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZovbT-0006uG-8z for qemu-devel@nongnu.org; Wed, 21 Oct 2015 11:47:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZovbT-0006tv-4R for qemu-devel@nongnu.org; Wed, 21 Oct 2015 11:47:03 -0400 From: Eduardo Habkost Date: Wed, 21 Oct 2015 13:46:50 -0200 Message-Id: <1445442410-13041-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1445442410-13041-1-git-send-email-ehabkost@redhat.com> References: <1445442410-13041-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefano Stabellini Cc: Paolo Bonzini , qemu-devel@nongnu.org Commit dbb7405d8caad0814ceddd568cb49f163a847561 made it possible to trigger an assert using "-device xen-platform". Replace it with appropriate error reporting. Before: $ qemu-system-x86_64 -device xen-platform qemu-system-x86_64: hw/i386/xen/xen_platform.c:391: xen_platform_initfn: Assertion `xen_enabled()' failed. Aborted (core dumped) $ After: $ qemu-system-x86_64 -device xen-platform qemu-system-x86_64: -device xen-platform: xen-platform device requires the Xen accelerator $ Signed-off-by: Eduardo Habkost --- Changes v1 -> v2:* * Use error_setg() instead of error_report() * Suggested-by: Paolo Bonzini --- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 3dc68cb..de83f4e 100644 --- a/hw/i386/xen/xen_platform.c +++ b/hw/i386/xen/xen_platform.c @@ -33,6 +33,7 @@ #include "trace.h" #include "exec/address-spaces.h" #include "sysemu/block-backend.h" +#include "qemu/error-report.h" #include @@ -388,7 +389,10 @@ static void xen_platform_realize(PCIDevice *dev, Error **errp) uint8_t *pci_conf; /* Device will crash on reset if xen is not initialized */ - assert(xen_enabled()); + if (!xen_enabled()) { + error_setg(errp, "xen-platform device requires the Xen accelerator"); + return; + } pci_conf = dev->config; -- 2.1.0