Skip to content

Commit 92eecff

Browse files
bonzinistefanhaRH
authored andcommitted
trace: remove argument from trace_init_file
It is not needed, all the callers are just saving what was retrieved from -trace and trace_init_file can retrieve it on its own. Signed-off-by: Paolo Bonzini <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent c6f28ed commit 92eecff

File tree

10 files changed

+24
-49
lines changed

10 files changed

+24
-49
lines changed

bsd-user/main.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,6 @@ int main(int argc, char **argv)
745745
const char *gdbstub = NULL;
746746
char **target_environ, **wrk;
747747
envlist_t *envlist = NULL;
748-
char *trace_file = NULL;
749748
bsd_type = target_openbsd;
750749

751750
if (argc <= 1)
@@ -851,8 +850,7 @@ int main(int argc, char **argv)
851850
} else if (!strcmp(r, "strace")) {
852851
do_strace = 1;
853852
} else if (!strcmp(r, "trace")) {
854-
g_free(trace_file);
855-
trace_file = trace_opt_parse(optarg);
853+
trace_opt_parse(optarg);
856854
} else {
857855
usage();
858856
}
@@ -880,7 +878,7 @@ int main(int argc, char **argv)
880878
if (!trace_init_backends()) {
881879
exit(1);
882880
}
883-
trace_init_file(trace_file);
881+
trace_init_file();
884882

885883
/* Zero out regs */
886884
memset(regs, 0, sizeof(struct target_pt_regs));

linux-user/main.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,9 @@ static void handle_arg_version(const char *arg)
386386
exit(EXIT_SUCCESS);
387387
}
388388

389-
static char *trace_file;
390389
static void handle_arg_trace(const char *arg)
391390
{
392-
g_free(trace_file);
393-
trace_file = trace_opt_parse(arg);
391+
trace_opt_parse(arg);
394392
}
395393

396394
#if defined(TARGET_XTENSA)
@@ -672,7 +670,7 @@ int main(int argc, char **argv, char **envp)
672670
if (!trace_init_backends()) {
673671
exit(1);
674672
}
675-
trace_init_file(trace_file);
673+
trace_init_file();
676674
if (qemu_plugin_load_list(&plugins)) {
677675
exit(1);
678676
}

qemu-img.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -5466,7 +5466,6 @@ int main(int argc, char **argv)
54665466
const img_cmd_t *cmd;
54675467
const char *cmdname;
54685468
Error *local_error = NULL;
5469-
char *trace_file = NULL;
54705469
int c;
54715470
static const struct option long_options[] = {
54725471
{"help", no_argument, 0, 'h'},
@@ -5516,8 +5515,7 @@ int main(int argc, char **argv)
55165515
printf(QEMU_IMG_VERSION);
55175516
return 0;
55185517
case 'T':
5519-
g_free(trace_file);
5520-
trace_file = trace_opt_parse(optarg);
5518+
trace_opt_parse(optarg);
55215519
break;
55225520
}
55235521
}
@@ -5535,7 +5533,7 @@ int main(int argc, char **argv)
55355533
if (!trace_init_backends()) {
55365534
exit(1);
55375535
}
5538-
trace_init_file(trace_file);
5536+
trace_init_file();
55395537
qemu_set_log(LOG_TRACE);
55405538

55415539
/* find the command */

qemu-io.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,6 @@ int main(int argc, char **argv)
536536
Error *local_error = NULL;
537537
QDict *opts = NULL;
538538
const char *format = NULL;
539-
char *trace_file = NULL;
540539
bool force_share = false;
541540

542541
#ifdef CONFIG_POSIX
@@ -601,8 +600,7 @@ int main(int argc, char **argv)
601600
}
602601
break;
603602
case 'T':
604-
g_free(trace_file);
605-
trace_file = trace_opt_parse(optarg);
603+
trace_opt_parse(optarg);
606604
break;
607605
case 'V':
608606
printf("%s version " QEMU_FULL_VERSION "\n"
@@ -653,7 +651,7 @@ int main(int argc, char **argv)
653651
if (!trace_init_backends()) {
654652
exit(1);
655653
}
656-
trace_init_file(trace_file);
654+
trace_init_file();
657655
qemu_set_log(LOG_TRACE);
658656

659657
/* initialize commands */

qemu-nbd.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ int main(int argc, char **argv)
581581
const char *tlscredsid = NULL;
582582
bool imageOpts = false;
583583
bool writethrough = true;
584-
char *trace_file = NULL;
585584
bool fork_process = false;
586585
bool list = false;
587586
int old_stderr = -1;
@@ -768,8 +767,7 @@ int main(int argc, char **argv)
768767
imageOpts = true;
769768
break;
770769
case 'T':
771-
g_free(trace_file);
772-
trace_file = trace_opt_parse(optarg);
770+
trace_opt_parse(optarg);
773771
break;
774772
case QEMU_NBD_OPT_TLSAUTHZ:
775773
tlsauthz = optarg;
@@ -816,7 +814,7 @@ int main(int argc, char **argv)
816814
if (!trace_init_backends()) {
817815
exit(1);
818816
}
819-
trace_init_file(trace_file);
817+
trace_init_file();
820818
qemu_set_log(LOG_TRACE);
821819

822820
socket_activation = check_socket_activation();

scsi/qemu-pr-helper.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ int main(int argc, char **argv)
884884
int quiet = 0;
885885
int ch;
886886
Error *local_err = NULL;
887-
char *trace_file = NULL;
888887
bool daemonize = false;
889888
bool pidfile_specified = false;
890889
bool socket_path_specified = false;
@@ -968,8 +967,7 @@ int main(int argc, char **argv)
968967
++loglevel;
969968
break;
970969
case 'T':
971-
g_free(trace_file);
972-
trace_file = trace_opt_parse(optarg);
970+
trace_opt_parse(optarg);
973971
break;
974972
case 'V':
975973
version(argv[0]);
@@ -992,7 +990,7 @@ int main(int argc, char **argv)
992990
if (!trace_init_backends()) {
993991
exit(EXIT_FAILURE);
994992
}
995-
trace_init_file(trace_file);
993+
trace_init_file();
996994
qemu_set_log(LOG_TRACE);
997995

998996
#ifdef CONFIG_MPATH

softmmu/vl.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,6 @@ void qemu_init(int argc, char **argv, char **envp)
28862886
int display_remote = 0;
28872887
const char *log_mask = NULL;
28882888
const char *log_file = NULL;
2889-
char *trace_file = NULL;
28902889
ram_addr_t maxram_size;
28912890
uint64_t ram_slots = 0;
28922891
FILE *vmstate_dump_file = NULL;
@@ -3688,8 +3687,7 @@ void qemu_init(int argc, char **argv, char **envp)
36883687
xen_domid_restrict = true;
36893688
break;
36903689
case QEMU_OPTION_trace:
3691-
g_free(trace_file);
3692-
trace_file = trace_opt_parse(optarg);
3690+
trace_opt_parse(optarg);
36933691
break;
36943692
case QEMU_OPTION_plugin:
36953693
qemu_plugin_opt_parse(optarg, &plugin_list);
@@ -3939,7 +3937,7 @@ void qemu_init(int argc, char **argv, char **envp)
39393937
if (!trace_init_backends()) {
39403938
exit(1);
39413939
}
3942-
trace_init_file(trace_file);
3940+
trace_init_file();
39433941

39443942
/* Open the logfile at this point and set the log mask if necessary.
39453943
*/

storage-daemon/qemu-storage-daemon.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,9 @@ static void process_options(int argc, char *argv[])
180180
help();
181181
exit(EXIT_SUCCESS);
182182
case 'T':
183-
{
184-
char *trace_file = trace_opt_parse(optarg);
185-
trace_init_file(trace_file);
186-
g_free(trace_file);
187-
break;
188-
}
183+
trace_opt_parse(optarg);
184+
trace_init_file();
185+
break;
189186
case 'V':
190187
printf("qemu-storage-daemon version "
191188
QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");

trace/control.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ static void trace_init_events(const char *fname)
222222
loc_pop(&loc);
223223
}
224224

225-
void trace_init_file(const char *file)
225+
void trace_init_file(void)
226226
{
227+
QemuOpts *opts = qemu_find_opts_singleton("trace");
228+
const char *file = qemu_opt_get(opts, "file");
227229
#ifdef CONFIG_TRACE_SIMPLE
228230
st_set_trace_file(file);
229231
if (init_trace_on_startup) {
@@ -289,9 +291,8 @@ bool trace_init_backends(void)
289291
return true;
290292
}
291293

292-
char *trace_opt_parse(const char *optarg)
294+
void trace_opt_parse(const char *optarg)
293295
{
294-
char *trace_file;
295296
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
296297
optarg, true);
297298
if (!opts) {
@@ -301,11 +302,8 @@ char *trace_opt_parse(const char *optarg)
301302
trace_enable_events(qemu_opt_get(opts, "enable"));
302303
}
303304
trace_init_events(qemu_opt_get(opts, "events"));
304-
trace_file = g_strdup(qemu_opt_get(opts, "file"));
305305
init_trace_on_startup = true;
306306
qemu_opts_del(opts);
307-
308-
return trace_file;
309307
}
310308

311309
uint32_t trace_get_vcpu_event_count(void)

trace/control.h

+3-9
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
167167

168168
/**
169169
* trace_init_backends:
170-
* @file: Name of trace output file; may be NULL.
171-
* Corresponds to commandline option "--trace file=...".
172170
*
173171
* Initialize the tracing backend.
174172
*
@@ -178,14 +176,12 @@ bool trace_init_backends(void);
178176

179177
/**
180178
* trace_init_file:
181-
* @file: Name of trace output file; may be NULL.
182-
* Corresponds to commandline option "--trace file=...".
183179
*
184180
* Record the name of the output file for the tracing backend.
185181
* Exits if no selected backend does not support specifying the
186-
* output file, and a non-NULL file was passed.
182+
* output file, and a file was specified with "-trace file=...".
187183
*/
188-
void trace_init_file(const char *file);
184+
void trace_init_file(void);
189185

190186
/**
191187
* trace_init_vcpu:
@@ -229,10 +225,8 @@ extern QemuOptsList qemu_trace_opts;
229225
* @optarg: A string argument of --trace command line argument
230226
*
231227
* Initialize tracing subsystem.
232-
*
233-
* Returns the filename to save trace to. It must be freed with g_free().
234228
*/
235-
char *trace_opt_parse(const char *optarg);
229+
void trace_opt_parse(const char *optarg);
236230

237231
/**
238232
* trace_get_vcpu_event_count:

0 commit comments

Comments
 (0)