xen-platform: Replace assert() with appropriate error reporting
v2 cover xen-platform: Replace assert() with appropriate error reporting
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(-)
Signature · 1 line
2.1.0
PATCH v2 2/2 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 $
---
Changes v1 -> v2:*
* Use error_setg() instead of error_report()
* Suggested-by: Paolo Bonzini <[email protected]>
--- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/i386/xen/xen_platform.c +5 -1
@@ -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;
Signature · 1 line
2.1.0
PATCH v2 1/2 xen_platform: switch to realize
In reply to Eduardo HabkostFrom: Stefano Stabellini <[email protected]>
Use realize to initialize the xen_platform device
---
Changes v1 -> v2:
* Remove useless return
* Suggested-by: Paolo Bonzini <[email protected]>
* Rename xen_platform_initfn() to xen_platform_realize()
--- hw/i386/xen/xen_platform.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/i386/xen/xen_platform.c +2 -4
@@ -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 ;
Signature · 1 line
2.1.0
Stefano Stabellini
AppliedRe: [Qemu-devel] [PATCH v2 1/2] xen_platform: switch to realize
Quoted 6 lines · Eduardo Habkost
From: Stefano Stabellini <[email protected]>
Use realize to initialize the
xen_platformdeviceSigned-off-by Stefano Stabellini <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>
Applied to my tree
Quoted 42 lines
Changes v1 -> v2:
* Remove useless return
* Suggested-by: Paolo Bonzini <[email protected]>
* Renamexen_platform_initfn()toxen_platform_realize()--- hw/i386/xen/xen_platform.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)hw/i386/xen/xen_platform.c +2
-4@@ -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 ;Signature · 1 line
2.1.0
Stefano Stabellini
AppliedQuoted 11 lines · Eduardo Habkost
Commit
dbb7405d8caad0814ceddd568cb49f163a847561made 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) $
Quoted 7 lines
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 <[email protected]>
Applied to my tree
Quoted 34 lines
Changes v1 -> v2:*
* Useerror_setg()instead oferror_report()
* Suggested-by: Paolo Bonzini <[email protected]>--- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +5
-1@@ -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;Signature · 1 line
2.1.0