From: Eduardo Habkost Date: Wed, 21 Oct 2015 15:46:50 +0000 (-0200) Subject: xen-platform: Replace assert() with appropriate error reporting X-Git-Tag: v2.5.0-rc0~47^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b1ecd51bdbb0fc0a7026662b03e7e7df9d129ca0;p=qemu-xen-unstable.git xen-platform: Replace assert() with appropriate error reporting 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 Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c index 3dc68cb0fe..de83f4e3ee 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;