[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate
From: |
Stefano Stabellini |
Subject: |
Re: [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting |
Date: |
Tue, 20 Oct 2015 11:01:16 +0100 |
User-agent: |
Alpine 2.02 (DEB 1266 2009-07-14) |
On Mon, 19 Oct 2015, Paolo Bonzini wrote:
> On 19/10/2015 20:39, Eduardo Habkost wrote:
> > 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
> > qemu-system-x86_64: -device xen-platform: Device initialization failed
> > $
> >
> > Signed-off-by: Eduardo Habkost <address@hidden>
> > ---
> > 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 8682c42..5667f29 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 <xenguest.h>
> >
> > @@ -388,7 +389,10 @@ static int xen_platform_initfn(PCIDevice *dev)
> > uint8_t *pci_conf;
> >
> > /* Device will crash on reset if xen is not initialized */
> > - assert(xen_enabled());
> > + if (!xen_enabled()) {
> > + error_report("xen-platform device requires the Xen accelerator");
>
> You can use PCIDeviceClass's realize (see Stefano's
> http://thread.gmane.org/gmane.comp.emulators.qemu/369998) to achieve
> better error propagation.
Eduardo, if you are happy with that, I'll wait for your respin :-)
>
> > + return -1;
> > + }
> >
> > pci_conf = dev->config;
> >
> >
>