* [Qemu-devel] [PATCH v2 0/2] xen-platform: Replace assert() with appropriate error reporting
@ 2015-10-21 15:46 Eduardo Habkost
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize Eduardo Habkost
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
0 siblings, 2 replies; 5+ messages in thread
From: Eduardo Habkost @ 2015-10-21 15:46 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Paolo Bonzini, qemu-devel
New version, now using PCIDeviceClass::realize.
Eduardo Habkost (1):
xen-platform: Replace assert() with appropriate error reporting
Stefano Stabellini (1):
xen_platform: switch to realize
hw/i386/xen/xen_platform.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize
2015-10-21 15:46 [Qemu-devel] [PATCH v2 0/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
@ 2015-10-21 15:46 ` Eduardo Habkost
2015-10-26 11:24 ` Stefano Stabellini
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2015-10-21 15:46 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: Paolo Bonzini, qemu-devel
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Use realize to initialize the xen_platform device
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
* Remove useless return
* Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
* Rename xen_platform_initfn() to xen_platform_realize()
---
hw/i386/xen/xen_platform.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 8682c42..3dc68cb 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -382,7 +382,7 @@ static const VMStateDescription vmstate_xen_platform = {
}
};
-static int xen_platform_initfn(PCIDevice *dev)
+static void xen_platform_realize(PCIDevice *dev, Error **errp)
{
PCIXenPlatformState *d = XEN_PLATFORM(dev);
uint8_t *pci_conf;
@@ -407,8 +407,6 @@ static int xen_platform_initfn(PCIDevice *dev)
&d->mmio_bar);
platform_fixed_ioport_init(d);
-
- return 0;
}
static void platform_reset(DeviceState *dev)
@@ -423,7 +421,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- k->init = xen_platform_initfn;
+ k->realize = xen_platform_realize;
k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting
2015-10-21 15:46 [Qemu-devel] [PATCH v2 0/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize Eduardo Habkost
@ 2015-10-21 15:46 ` Eduardo Habkost
2015-10-26 11:25 ` Stefano Stabellini
1 sibling, 1 reply; 5+ messages in thread
From: Eduardo Habkost @ 2015-10-21 15:46 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
$
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:*
* Use error_setg() instead of error_report()
* Suggested-by: Paolo Bonzini <pbonzini@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 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 <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;
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize Eduardo Habkost
@ 2015-10-26 11:24 ` Stefano Stabellini
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2015-10-26 11:24 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: Paolo Bonzini, qemu-devel, Stefano Stabellini
On Wed, 21 Oct 2015, Eduardo Habkost wrote:
> From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> Use realize to initialize the xen_platform device
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Applied to my tree
> Changes v1 -> v2:
> * Remove useless return
> * Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> * Rename xen_platform_initfn() to xen_platform_realize()
> ---
> hw/i386/xen/xen_platform.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
> index 8682c42..3dc68cb 100644
> --- a/hw/i386/xen/xen_platform.c
> +++ b/hw/i386/xen/xen_platform.c
> @@ -382,7 +382,7 @@ static const VMStateDescription vmstate_xen_platform = {
> }
> };
>
> -static int xen_platform_initfn(PCIDevice *dev)
> +static void xen_platform_realize(PCIDevice *dev, Error **errp)
> {
> PCIXenPlatformState *d = XEN_PLATFORM(dev);
> uint8_t *pci_conf;
> @@ -407,8 +407,6 @@ static int xen_platform_initfn(PCIDevice *dev)
> &d->mmio_bar);
>
> platform_fixed_ioport_init(d);
> -
> - return 0;
> }
>
> static void platform_reset(DeviceState *dev)
> @@ -423,7 +421,7 @@ static void xen_platform_class_init(ObjectClass *klass, void *data)
> DeviceClass *dc = DEVICE_CLASS(klass);
> PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> - k->init = xen_platform_initfn;
> + k->realize = xen_platform_realize;
> k->vendor_id = PCI_VENDOR_ID_XEN;
> k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
> k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
@ 2015-10-26 11:25 ` Stefano Stabellini
0 siblings, 0 replies; 5+ messages in thread
From: Stefano Stabellini @ 2015-10-26 11:25 UTC (permalink / raw)
To: Eduardo Habkost; +Cc: Paolo Bonzini, qemu-devel, Stefano Stabellini
On Wed, 21 Oct 2015, 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
> $
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Applied to my tree
> Changes v1 -> v2:*
> * Use error_setg() instead of error_report()
> * Suggested-by: Paolo Bonzini <pbonzini@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 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 <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;
>
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-26 11:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21 15:46 [Qemu-devel] [PATCH v2 0/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize Eduardo Habkost
2015-10-26 11:24 ` Stefano Stabellini
2015-10-21 15:46 ` [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting Eduardo Habkost
2015-10-26 11:25 ` Stefano Stabellini
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).