From: Serge Hallyn <serge.hallyn@ubuntu.com>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH] vl.c: don't try to insert malloc tracepoints on newer glib (v2)
Date: Fri, 4 Sep 2015 19:09:28 +0000 [thread overview]
Message-ID: <20150904190928.GE30773@ubuntumail> (raw)
Because it has deprecated it with commit
3be6ed60aa58095691bd697344765e715a327fc1. This prevents the warning
(process:3535): GLib-WARNING **: /build/glib2.0-3tdlHy/glib2.0-2.45.6/./glib/gmem.c:482: custom memory allocation vtable not supported
Changelog (v2): consolidate #ifdefs
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
---
vl.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/vl.c b/vl.c
index 584ca88..6a69027 100644
--- a/vl.c
+++ b/vl.c
@@ -2719,6 +2719,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
return popt;
}
+#if !GLIB_CHECK_VERSION(2, 44, 0)
static gpointer malloc_and_trace(gsize n_bytes)
{
void *ptr = malloc(n_bytes);
@@ -2739,6 +2740,25 @@ static void free_and_trace(gpointer mem)
free(mem);
}
+static void register_glib_mem_trace_functions(void)
+{
+ GMemVTable mem_trace = {
+ .malloc = malloc_and_trace,
+ .realloc = realloc_and_trace,
+ .free = free_and_trace,
+ };
+
+ g_mem_set_vtable(&mem_trace);
+}
+#else
+static void register_glib_mem_trace_functions(void)
+{
+ /* Newer versions of glib don't support intercepting the
+ * memory allocation functions.
+ */
+}
+#endif
+
static int machine_set_property(void *opaque,
const char *name, const char *value,
Error **errp)
@@ -2966,11 +2986,6 @@ int main(int argc, char **argv, char **envp)
bool userconfig = true;
const char *log_mask = NULL;
const char *log_file = NULL;
- GMemVTable mem_trace = {
- .malloc = malloc_and_trace,
- .realloc = realloc_and_trace,
- .free = free_and_trace,
- };
const char *trace_events = NULL;
const char *trace_file = NULL;
ram_addr_t maxram_size;
@@ -2986,7 +3001,7 @@ int main(int argc, char **argv, char **envp)
error_set_progname(argv[0]);
qemu_init_exec_dir(argv[0]);
- g_mem_set_vtable(&mem_trace);
+ register_glib_mem_trace_functions();
module_call_init(MODULE_INIT_QOM);
--
2.5.0
next reply other threads:[~2015-09-04 19:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 19:09 Serge Hallyn [this message]
2015-09-04 22:42 ` [Qemu-devel] [PATCH] vl.c: don't try to insert malloc tracepoints on newer glib (v2) Peter Maydell
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=20150904190928.GE30773@ubuntumail \
--to=serge.hallyn@ubuntu.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).