From: Anthony Xu <anthony.xu@intel.com>
To: qemu-devel@nongnu.org
Cc: stefanha@redhat.com, pbonzini@redhat.com,
Anthony Xu <anthony.xu@intel.com>
Subject: [Qemu-devel] [PATCH] trace: add sanity check
Date: Tue, 9 May 2017 15:37:12 -0700 [thread overview]
Message-ID: <1494369432-15418-1-git-send-email-anthony.xu@intel.com> (raw)
If trace backend is set to TRACE_NOP, trace_get_vcpu_event_count
returns 0, cause bitmap_new call abort.
Signed-off-by: Anthony Xu <anthony.xu@intel.com>
---
qom/cpu.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/qom/cpu.c b/qom/cpu.c
index f02e9c0..f9111a0 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -382,6 +382,7 @@ static void cpu_common_unrealizefn(DeviceState *dev, Error **errp)
static void cpu_common_initfn(Object *obj)
{
+ uint32_t count;
CPUState *cpu = CPU(obj);
CPUClass *cc = CPU_GET_CLASS(obj);
@@ -396,7 +397,10 @@ static void cpu_common_initfn(Object *obj)
QTAILQ_INIT(&cpu->breakpoints);
QTAILQ_INIT(&cpu->watchpoints);
- cpu->trace_dstate = bitmap_new(trace_get_vcpu_event_count());
+ count = trace_get_vcpu_event_count();
+ if (count) {
+ cpu->trace_dstate = bitmap_new(count);
+ }
cpu_exec_initfn(cpu);
}
--
1.8.3.1
next reply other threads:[~2017-05-09 22:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-09 22:37 Anthony Xu [this message]
2017-05-10 16:29 ` [Qemu-devel] [PATCH] trace: add sanity check Stefan Hajnoczi
2017-05-10 18:09 ` Xu, Anthony
2017-05-11 17:30 ` Stefan Hajnoczi
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=1494369432-15418-1-git-send-email-anthony.xu@intel.com \
--to=anthony.xu@intel.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).