Commit b1ecd51b authored by Eduardo Habkost's avatar Eduardo Habkost Committed by Stefano Stabellini
Browse files

xen-platform: Replace assert() with appropriate error reporting



Commit dbb7405d 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: default avatarEduardo Habkost <ehabkost@redhat.com>
Reviewed-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
parent 4098d49d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "trace.h"
#include "exec/address-spaces.h"
#include "sysemu/block-backend.h"
#include "qemu/error-report.h"

#include <xenguest.h>

@@ -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;