From: Eduardo Habkost <ehabkost@redhat.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting
Date: Wed, 21 Oct 2015 13:46:50 -0200 [thread overview]
Message-ID: <1445442410-13041-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1445442410-13041-1-git-send-email-ehabkost@redhat.com>
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
next prev parent reply other threads:[~2015-10-21 15:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Eduardo Habkost [this message]
2015-10-26 11:25 ` [Qemu-devel] [PATCH v2 2/2] xen-platform: Replace assert() with appropriate error reporting Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445442410-13041-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).