All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 01/29] trace: remove argument from trace_init_file
Date: Tue, 27 Oct 2020 14:21:16 -0400	[thread overview]
Message-ID: <20201027182144.3315885-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20201027182144.3315885-1-pbonzini@redhat.com>

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 <pbonzini@redhat.com>
---
 bsd-user/main.c                      |  6 ++----
 linux-user/main.c                    |  6 ++----
 qemu-img.c                           |  6 ++----
 qemu-io.c                            |  6 ++----
 qemu-nbd.c                           |  6 ++----
 scsi/qemu-pr-helper.c                |  6 ++----
 softmmu/vl.c                         |  6 ++----
 storage-daemon/qemu-storage-daemon.c |  9 +++------
 trace/control.c                      | 10 ++++------
 trace/control.h                      | 12 +++---------
 10 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index ac40d79bfa..0a918e8f74 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -745,7 +745,6 @@ int main(int argc, char **argv)
     const char *gdbstub = NULL;
     char **target_environ, **wrk;
     envlist_t *envlist = NULL;
-    char *trace_file = NULL;
     bsd_type = target_openbsd;
 
     if (argc <= 1)
@@ -851,8 +850,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(r, "strace")) {
             do_strace = 1;
         } else if (!strcmp(r, "trace")) {
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
         } else {
             usage();
         }
@@ -880,7 +878,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
 
     /* Zero out regs */
     memset(regs, 0, sizeof(struct target_pt_regs));
diff --git a/linux-user/main.c b/linux-user/main.c
index 75c9785157..24d1eb73ad 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -386,11 +386,9 @@ static void handle_arg_version(const char *arg)
     exit(EXIT_SUCCESS);
 }
 
-static char *trace_file;
 static void handle_arg_trace(const char *arg)
 {
-    g_free(trace_file);
-    trace_file = trace_opt_parse(arg);
+    trace_opt_parse(arg);
 }
 
 #if defined(TARGET_XTENSA)
@@ -672,7 +670,7 @@ int main(int argc, char **argv, char **envp)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     if (qemu_plugin_load_list(&plugins)) {
         exit(1);
     }
diff --git a/qemu-img.c b/qemu-img.c
index 2103507936..ccfdf1f48d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -5434,7 +5434,6 @@ int main(int argc, char **argv)
     const img_cmd_t *cmd;
     const char *cmdname;
     Error *local_error = NULL;
-    char *trace_file = NULL;
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
@@ -5484,8 +5483,7 @@ int main(int argc, char **argv)
             printf(QEMU_IMG_VERSION);
             return 0;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         }
     }
@@ -5503,7 +5501,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     /* find the command */
diff --git a/qemu-io.c b/qemu-io.c
index 7cc832b3d6..ac88d8bd40 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -536,7 +536,6 @@ int main(int argc, char **argv)
     Error *local_error = NULL;
     QDict *opts = NULL;
     const char *format = NULL;
-    char *trace_file = NULL;
     bool force_share = false;
 
 #ifdef CONFIG_POSIX
@@ -601,8 +600,7 @@ int main(int argc, char **argv)
             }
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case 'V':
             printf("%s version " QEMU_FULL_VERSION "\n"
@@ -653,7 +651,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     /* initialize commands */
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a0701cdf36..e2ae822012 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -578,7 +578,6 @@ int main(int argc, char **argv)
     const char *tlscredsid = NULL;
     bool imageOpts = false;
     bool writethrough = true;
-    char *trace_file = NULL;
     bool fork_process = false;
     bool list = false;
     int old_stderr = -1;
@@ -762,8 +761,7 @@ int main(int argc, char **argv)
             imageOpts = true;
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case QEMU_NBD_OPT_TLSAUTHZ:
             tlsauthz = optarg;
@@ -810,7 +808,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
     socket_activation = check_socket_activation();
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index d26faaf91e..2733d92f2d 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -884,7 +884,6 @@ int main(int argc, char **argv)
     int quiet = 0;
     int ch;
     Error *local_err = NULL;
-    char *trace_file = NULL;
     bool daemonize = false;
     bool pidfile_specified = false;
     bool socket_path_specified = false;
@@ -968,8 +967,7 @@ int main(int argc, char **argv)
             ++loglevel;
             break;
         case 'T':
-            g_free(trace_file);
-            trace_file = trace_opt_parse(optarg);
+            trace_opt_parse(optarg);
             break;
         case 'V':
             version(argv[0]);
@@ -992,7 +990,7 @@ int main(int argc, char **argv)
     if (!trace_init_backends()) {
         exit(EXIT_FAILURE);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
     qemu_set_log(LOG_TRACE);
 
 #ifdef CONFIG_MPATH
diff --git a/softmmu/vl.c b/softmmu/vl.c
index d5a21ebcf4..d39d914dd0 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2886,7 +2886,6 @@ void qemu_init(int argc, char **argv, char **envp)
     int display_remote = 0;
     const char *log_mask = NULL;
     const char *log_file = NULL;
-    char *trace_file = NULL;
     ram_addr_t maxram_size;
     uint64_t ram_slots = 0;
     FILE *vmstate_dump_file = NULL;
@@ -3687,8 +3686,7 @@ void qemu_init(int argc, char **argv, char **envp)
                 xen_domid_restrict = true;
                 break;
             case QEMU_OPTION_trace:
-                g_free(trace_file);
-                trace_file = trace_opt_parse(optarg);
+                trace_opt_parse(optarg);
                 break;
             case QEMU_OPTION_plugin:
                 qemu_plugin_opt_parse(optarg, &plugin_list);
@@ -3938,7 +3936,7 @@ void qemu_init(int argc, char **argv, char **envp)
     if (!trace_init_backends()) {
         exit(1);
     }
-    trace_init_file(trace_file);
+    trace_init_file();
 
     /* Open the logfile at this point and set the log mask if necessary.
      */
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index e419ba9f19..7c914b0dc1 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -180,12 +180,9 @@ static void process_options(int argc, char *argv[])
             help();
             exit(EXIT_SUCCESS);
         case 'T':
-            {
-                char *trace_file = trace_opt_parse(optarg);
-                trace_init_file(trace_file);
-                g_free(trace_file);
-                break;
-            }
+            trace_opt_parse(optarg);
+            trace_init_file();
+            break;
         case 'V':
             printf("qemu-storage-daemon version "
                    QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");
diff --git a/trace/control.c b/trace/control.c
index b35e512dce..7a57fa7dd5 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -221,8 +221,10 @@ static void trace_init_events(const char *fname)
     loc_pop(&loc);
 }
 
-void trace_init_file(const char *file)
+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_enabled(true);
@@ -286,9 +288,8 @@ bool trace_init_backends(void)
     return true;
 }
 
-char *trace_opt_parse(const char *optarg)
+void trace_opt_parse(const char *optarg)
 {
-    char *trace_file;
     QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
                                              optarg, true);
     if (!opts) {
@@ -298,10 +299,7 @@ char *trace_opt_parse(const char *optarg)
         trace_enable_events(qemu_opt_get(opts, "enable"));
     }
     trace_init_events(qemu_opt_get(opts, "events"));
-    trace_file = g_strdup(qemu_opt_get(opts, "file"));
     qemu_opts_del(opts);
-
-    return trace_file;
 }
 
 uint32_t trace_get_vcpu_event_count(void)
diff --git a/trace/control.h b/trace/control.h
index 1f81c491b6..05b95ea453 100644
--- a/trace/control.h
+++ b/trace/control.h
@@ -167,8 +167,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
 
 /**
  * trace_init_backends:
- * @file:   Name of trace output file; may be NULL.
- *          Corresponds to commandline option "--trace file=...".
  *
  * Initialize the tracing backend.
  *
@@ -178,14 +176,12 @@ bool trace_init_backends(void);
 
 /**
  * trace_init_file:
- * @file:   Name of trace output file; may be NULL.
- *          Corresponds to commandline option "--trace file=...".
  *
  * Record the name of the output file for the tracing backend.
  * Exits if no selected backend does not support specifying the
- * output file, and a non-NULL file was passed.
+ * output file, and a file was specified with "-trace file=...".
  */
-void trace_init_file(const char *file);
+void trace_init_file(void);
 
 /**
  * trace_init_vcpu:
@@ -229,10 +225,8 @@ extern QemuOptsList qemu_trace_opts;
  * @optarg: A string argument of --trace command line argument
  *
  * Initialize tracing subsystem.
- *
- * Returns the filename to save trace to.  It must be freed with g_free().
  */
-char *trace_opt_parse(const char *optarg);
+void trace_opt_parse(const char *optarg);
 
 /**
  * trace_get_vcpu_event_count:
-- 
2.26.2




  reply	other threads:[~2020-10-27 18:30 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 18:21 [RFC PATCH v2 00/37] cleanup qemu_init and make sense of command line processing Paolo Bonzini
2020-10-27 18:21 ` Paolo Bonzini [this message]
2020-10-27 18:21 ` [PATCH 02/29] semihosting: fix order of initialization functions Paolo Bonzini
2020-10-27 18:21 ` [PATCH 03/29] vl: extract validation of -smp to machine.c Paolo Bonzini
2020-10-28 16:32   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 04/29] vl: remove bogus check Paolo Bonzini
2020-10-28 16:48   ` Igor Mammedov
2020-10-28 16:55     ` Daniel P. Berrangé
2020-10-28 19:32   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 05/29] vl: split various early command line options to a separate function Paolo Bonzini
2020-11-02 15:30   ` Igor Mammedov
2020-11-02 16:33     ` Paolo Bonzini
2020-10-27 18:21 ` [PATCH 06/29] vl: move various initialization routines out of qemu_init Paolo Bonzini
2020-11-02 15:40   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 07/29] vl: extract qemu_init_subsystems Paolo Bonzini
2020-11-02 15:55   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 08/29] vl: move prelaunch part of qemu_init to new functions Paolo Bonzini
2020-11-11 19:29   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 09/29] vl: extract various command line validation snippets to a new function Paolo Bonzini
2020-11-11 19:39   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 10/29] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
2020-11-11 19:58   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 11/29] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
2020-11-11 19:57   ` Igor Mammedov
2020-11-11 20:04     ` Paolo Bonzini
2020-11-18 16:55       ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 12/29] vl: create "-net nic -net user" default earlier Paolo Bonzini
2020-11-18 14:43   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 13/29] vl: load plugins as late as possible Paolo Bonzini
2020-10-27 18:21 ` [PATCH 14/29] vl: move semihosting command line fallback to qemu_finish_machine_init Paolo Bonzini
2020-10-27 18:21 ` [PATCH 15/29] vl: extract default devices to separate functions Paolo Bonzini
2020-10-27 18:21 ` [PATCH 16/29] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
2020-10-27 18:21 ` [PATCH 17/29] vl: separate qemu_create_early_backends Paolo Bonzini
2020-11-18 16:29   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 18/29] vl: separate qemu_create_late_backends Paolo Bonzini
2020-11-18 16:33   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 19/29] vl: separate qemu_create_machine Paolo Bonzini
2020-11-18 16:45   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 20/29] vl: separate qemu_apply_machine_options Paolo Bonzini
2020-11-18 16:57   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 21/29] vl: separate qemu_resolve_machine_memdev Paolo Bonzini
2020-11-20 13:15   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 22/29] vl: initialize displays before preconfig loop Paolo Bonzini
2020-11-20 15:11   ` Igor Mammedov
2020-11-20 15:53     ` Paolo Bonzini
2020-11-20 16:32       ` Igor Mammedov
2020-11-20 16:46         ` Paolo Bonzini
2020-11-20 17:11           ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 23/29] vl: move -global check earlier Paolo Bonzini
2020-11-20 15:10   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 24/29] migration, vl: start migration via qmp_migrate_incoming Paolo Bonzini
2020-11-20 15:34   ` Igor Mammedov
2020-11-20 16:02     ` Paolo Bonzini
2020-12-02 13:10       ` Dr. David Alan Gilbert
2020-12-02 13:15         ` Daniel P. Berrangé
2020-12-02 13:29           ` Paolo Bonzini
2020-12-02 13:36         ` Paolo Bonzini
2020-12-02 15:08           ` Dr. David Alan Gilbert
2020-10-27 18:21 ` [PATCH 25/29] vl: start VM via qmp_cont Paolo Bonzini
2020-11-20 16:08   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 26/29] hmp: introduce cmd_available Paolo Bonzini
2020-11-20 15:46   ` Igor Mammedov
2020-10-27 18:21 ` [PATCH 27/29] remove preconfig state Paolo Bonzini
2020-11-20 16:01   ` Igor Mammedov
2020-11-20 16:22     ` Paolo Bonzini
2020-10-27 18:21 ` [PATCH 28/29] vl: remove separate preconfig main_loop Paolo Bonzini
2020-11-20 16:26   ` Igor Mammedov
2020-11-20 16:39     ` Paolo Bonzini
2020-11-23  8:34     ` Paolo Bonzini
2020-10-27 18:21 ` [PATCH 29/29] vl: allow -incoming defer with -preconfig Paolo Bonzini
2020-11-20 16:28   ` Igor Mammedov
2020-11-20 16:45     ` Paolo Bonzini
2020-11-02 15:57 ` [RFC PATCH v2 00/37] cleanup qemu_init and make sense of command line processing Igor Mammedov
2020-11-02 16:34   ` Paolo Bonzini
2020-11-03 12:57     ` Igor Mammedov
2020-11-03 14:37       ` Paolo Bonzini
2020-11-20 16:19         ` Igor Mammedov
2020-11-20 16:27           ` Paolo Bonzini

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=20201027182144.3315885-2-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.