[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 21/23] trace: fix "-trace file=..."
From: |
Paolo Bonzini |
Subject: |
[PULL 21/23] trace: fix "-trace file=..." |
Date: |
Sat, 6 Mar 2021 11:54:17 +0100 |
Because trace_opt_parse always deletes the options it has parsed,
trace_init_file's call to qemu_find_opts_singleton always
creates an empty -trace option group. Therefore, the subsequent
qemu_opt_get(opts, "file") always returns NULL.
To fix this, save the last "-trace file=..." option in a global
variable and use it later in trace_init_file.
This is similar to what was done before commit 92eecfff32 ("trace:
remove argument from trace_init_file", 2020-11-11), except contained
within trace/control.c and without memory leaks.
Fixes: 92eecfff32 ("trace: remove argument from trace_init_file", 2020-11-11)
Cc: stefanha@redhat.com
Reported-by: armbru@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210209145759.141231-2-pbonzini@redhat.com>
---
trace/control.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/trace/control.c b/trace/control.c
index cd04dd4e0c..4be38e1af2 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -40,6 +40,7 @@ static size_t nevent_groups;
static uint32_t next_id;
static uint32_t next_vcpu_id;
static bool init_trace_on_startup;
+static char *trace_opts_file;
QemuOptsList qemu_trace_opts = {
.name = "trace",
@@ -224,10 +225,8 @@ static void trace_init_events(const char *fname)
void trace_init_file(void)
{
- QemuOpts *opts = qemu_find_opts_singleton("trace");
- const char *file = qemu_opt_get(opts, "file");
#ifdef CONFIG_TRACE_SIMPLE
- st_set_trace_file(file);
+ st_set_trace_file(trace_opts_file);
if (init_trace_on_startup) {
st_set_trace_file_enabled(true);
}
@@ -238,11 +237,11 @@ void trace_init_file(void)
* backend. However we should only override -D if we actually have
* something to override it with.
*/
- if (file) {
- qemu_set_log_filename(file, &error_fatal);
+ if (trace_opts_file) {
+ qemu_set_log_filename(trace_opts_file, &error_fatal);
}
#else
- if (file) {
+ if (trace_opts_file) {
fprintf(stderr, "error: --trace file=...: "
"option not supported by the selected tracing backends\n");
exit(1);
@@ -303,6 +302,8 @@ void trace_opt_parse(const char *optarg)
}
trace_init_events(qemu_opt_get(opts, "events"));
init_trace_on_startup = true;
+ g_free(trace_opts_file);
+ trace_opts_file = g_strdup(qemu_opt_get(opts, "file"));
qemu_opts_del(opts);
}
--
2.29.2
- [PULL 05/23] qom: Check for wellformed id in user_creatable_add_type(), (continued)
- [PULL 05/23] qom: Check for wellformed id in user_creatable_add_type(), Paolo Bonzini, 2021/03/06
- [PULL 06/23] vl.c: do not execute trace_init_backends() before daemonizing, Paolo Bonzini, 2021/03/06
- [PULL 07/23] accel: kvm: Fix memory waste under mismatch page size, Paolo Bonzini, 2021/03/06
- [PULL 10/23] elf_ops: correct loading of 32 bit PVH kernel, Paolo Bonzini, 2021/03/06
- [PULL 11/23] x86/pvh: extract only 4 bytes of start address for 32 bit kernels, Paolo Bonzini, 2021/03/06
- [PULL 13/23] scsi: Rename linux-specific SG_ERR codes to generic SCSI_HOST error codes, Paolo Bonzini, 2021/03/06
- [PULL 12/23] qemu-config: add error propagation to qemu_config_parse, Paolo Bonzini, 2021/03/06
- [PULL 15/23] scsi-generic: do not snoop the output of failed commands, Paolo Bonzini, 2021/03/06
- [PULL 16/23] scsi: inline sg_io_sense_from_errno() into the callers., Paolo Bonzini, 2021/03/06
- [PULL 20/23] meson: adjust timeouts for some slower tests, Paolo Bonzini, 2021/03/06
- [PULL 21/23] trace: fix "-trace file=...",
Paolo Bonzini <=
- [PULL 22/23] trace: skip qemu_set_log_filename if no "-D" option was passed, Paolo Bonzini, 2021/03/06
- [PULL 08/23] accel: kvm: Add aligment assert for kvm_log_clear_one_slot, Paolo Bonzini, 2021/03/06
- [PULL 14/23] scsi: Add mapping for generic SCSI_HOST status to sense codes, Paolo Bonzini, 2021/03/06
- [PULL 17/23] scsi: move host_status handling into SCSI drivers, Paolo Bonzini, 2021/03/06
- [PULL 18/23] qemu-option: do not suggest using the delay option, Paolo Bonzini, 2021/03/06
- [PULL 19/23] build-sys: invoke ninja with -d keepdepfile, Paolo Bonzini, 2021/03/06
- [PULL 23/23] meson: Stop if cfi is enabled with system slirp, Paolo Bonzini, 2021/03/06
- [PULL 09/23] lsilogic: Use PCIDevice::exit instead of DeviceState::unrealize, Paolo Bonzini, 2021/03/06
- Re: [PULL 00/23] Misc patches for 2021-03-06, no-reply, 2021/03/06
- Re: [PULL 00/23] Misc patches for 2021-03-06, Peter Maydell, 2021/03/08