* [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting
@ 2015-10-19 18:39 Eduardo Habkost
2015-10-19 19:42 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Eduardo Habkost @ 2015-10-19 18:39 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Paolo Bonzini, qemu-devel
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 <ehabkost@redhat.com>
---
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");
+ return -1;
+ }
pci_conf = dev->config;
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting
2015-10-19 18:39 [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
@ 2015-10-19 19:42 ` Paolo Bonzini
2015-10-20 10:01 ` Stefano Stabellini
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-10-19 19:42 UTC (permalink / raw)
To: Eduardo Habkost, Stefano Stabellini; +Cc: qemu-devel
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 <ehabkost@redhat.com>
> ---
> 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.
Paolo
> + return -1;
> + }
>
> pci_conf = dev->config;
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting
2015-10-19 19:42 ` Paolo Bonzini
@ 2015-10-20 10:01 ` Stefano Stabellini
2015-10-20 15:38 ` Eduardo Habkost
0 siblings, 1 reply; 4+ messages in thread
From: Stefano Stabellini @ 2015-10-20 10:01 UTC (permalink / raw)
To: ehabkost; +Cc: pbonzini, qemu-devel, Stefano Stabellini
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 <ehabkost@redhat.com>
> > ---
> > 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;
> >
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting
2015-10-20 10:01 ` Stefano Stabellini
@ 2015-10-20 15:38 ` Eduardo Habkost
0 siblings, 0 replies; 4+ messages in thread
From: Eduardo Habkost @ 2015-10-20 15:38 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: pbonzini, qemu-devel
On Tue, Oct 20, 2015 at 11:01:16AM +0100, Stefano Stabellini wrote:
> 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 <ehabkost@redhat.com>
> > > ---
> > > 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.
>
Oops, I misunderstood the previous message and I thought Paolo meant the
xen_enabled() check was being done too early, and not at realize time. I
wasn't aware that PCIDeviceClass::realize existed.
> Eduardo, if you are happy with that, I'll wait for your respin :-)
Yes, I will send a new version based on your conversion to k->realize.
Thanks!
--
Eduardo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-20 15:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-19 18:39 [Qemu-devel] [PATCH] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
2015-10-19 19:42 ` Paolo Bonzini
2015-10-20 10:01 ` Stefano Stabellini
2015-10-20 15:38 ` Eduardo Habkost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).