xen-platform: Replace assert() with appropriate error reporting
PATCH 1/1 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 qemu-system-x86_64: -device xen-platform: Device initialization failed $
--- 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 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;
Signature · 1 line
2.1.0
Quoted 36 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) $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 <[email protected]>--- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +1
-0@@ -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>
hw/i386/xen/xen_platform.c static int xen_platform_initfn(PCIDevice *dev) · line 393
Quoted 6 lines
hw/i386/xen/xen_platform.c +2
-1@@ -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
Quoted 6 lines
hw/i386/xen/xen_platform.c +2
-0+return -1 ; + } pci_conf = dev->config;
Quoted 39 lines · Paolo Bonzini
Quoted 38 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) $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 <[email protected]>--- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +1
-0@@ -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;
Quoted 8 lines
hw/i386/xen/xen_platform.c static int xen_platform_initfn(PCIDevice *dev) · line 393
Quoted 4 lines
hw/i386/xen/xen_platform.c +2
-1/* 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 :-)
Quoted 8 lines
Quoted 7 lines
hw/i386/xen/xen_platform.c +2
-0+return -1 ; + } pci_conf = dev->config;
Quoted 40 lines · Stefano Stabellini
Quoted 39 lines · Paolo Bonzini
Quoted 38 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) $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 <[email protected]>--- hw/i386/xen/xen_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)hw/i386/xen/xen_platform.c +1
-0@@ -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;
Quoted 9 lines
Quoted 8 lines
hw/i386/xen/xen_platform.c static int xen_platform_initfn(PCIDevice *dev) · line 393
Quoted 4 lines
hw/i386/xen/xen_platform.c +2
-1/* 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.
Quoted 1 line
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!
Signature · 1 line
Eduardo