[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL for-7.1 28/36] util/log: Remove qemu_log_close
From: |
Richard Henderson |
Subject: |
[PULL for-7.1 28/36] util/log: Remove qemu_log_close |
Date: |
Sun, 20 Mar 2022 10:11:27 -0700 |
The only real use is in cpu_abort, where we have just
flushed the file via qemu_log_unlock, and are just about
to force-crash the application via abort. We do not
really need to close the FILE before the abort.
The two uses in test-logging.c can be handled with
qemu_set_log_filename_flags.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/qemu/log.h | 3 ---
cpu.c | 1 -
tests/unit/test-logging.c | 4 ++--
util/log.c | 17 +----------------
4 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/include/qemu/log.h b/include/qemu/log.h
index ef247776cf..783faec309 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -92,7 +92,4 @@ int qemu_str_to_log_mask(const char *str);
*/
void qemu_print_log_usage(FILE *f);
-/* Close the log file */
-void qemu_log_close(void);
-
#endif
diff --git a/cpu.c b/cpu.c
index 054f21b307..3eb324c1c9 100644
--- a/cpu.c
+++ b/cpu.c
@@ -406,7 +406,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...)
fprintf(logfile, "\n");
cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP);
qemu_log_unlock(logfile);
- qemu_log_close();
}
va_end(ap2);
va_end(ap);
diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c
index 7016710a74..4e649e44c5 100644
--- a/tests/unit/test-logging.c
+++ b/tests/unit/test-logging.c
@@ -170,7 +170,7 @@ static void test_logfile_lock(gconstpointer data)
* Initiate a close file and make sure our handle remains
* valid since we still have the logfile lock.
*/
- qemu_log_close();
+ qemu_set_log_filename_flags(NULL, 0, &error_abort);
fprintf(logfile, "%s 2nd write to file\n", __func__);
fflush(logfile);
qemu_log_unlock(logfile);
@@ -208,7 +208,7 @@ int main(int argc, char **argv)
tmp_path, test_logfile_lock);
rc = g_test_run();
- qemu_log_close();
+ qemu_set_log_filename_flags(NULL, 0, &error_abort);
drain_call_rcu();
rmdir_full(tmp_path);
diff --git a/util/log.c b/util/log.c
index 46a0d38d41..691d6d7930 100644
--- a/util/log.c
+++ b/util/log.c
@@ -207,7 +207,7 @@ static void qemu_set_log_internal(const char *filename,
bool changed_name,
if (is_daemonized()) {
dup2(fileno(fd), STDERR_FILENO);
fclose(fd);
- /* This will skip closing logfile in qemu_log_close() */
+ /* This will skip closing logfile in qemu_logfile_free. */
fd = stderr;
}
} else {
@@ -330,21 +330,6 @@ out:
g_strfreev(ranges);
}
-/* Close the log file */
-void qemu_log_close(void)
-{
- QemuLogFile *logfile;
-
- qemu_mutex_lock(&qemu_logfile_mutex);
- logfile = qemu_logfile;
-
- if (logfile) {
- qatomic_rcu_set(&qemu_logfile, NULL);
- call_rcu(logfile, qemu_logfile_free, rcu);
- }
- qemu_mutex_unlock(&qemu_logfile_mutex);
-}
-
const QEMULogItem qemu_log_items[] = {
{ CPU_LOG_TB_OUT_ASM, "out_asm",
"show generated host assembly code for each compiled TB" },
--
2.25.1
- [PULL for-7.1 15/36] util/log: Use qemu_log_lock/unlock in qemu_log, (continued)
- [PULL for-7.1 15/36] util/log: Use qemu_log_lock/unlock in qemu_log, Richard Henderson, 2022/03/20
- [PULL for-7.1 18/36] bsd-user: Expand log_page_dump inline, Richard Henderson, 2022/03/20
- [PULL for-7.1 19/36] linux-user: Expand log_page_dump inline, Richard Henderson, 2022/03/20
- [PULL for-7.1 17/36] util/log: Drop call to setvbuf, Richard Henderson, 2022/03/20
- [PULL for-7.1 21/36] include/exec/log: Do not reference QemuLogFile directly, Richard Henderson, 2022/03/20
- [PULL for-7.1 22/36] include/qemu/log: Move entire implementation out-of-line, Richard Henderson, 2022/03/20
- [PULL for-7.1 24/36] util/log: Introduce qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 23/36] sysemu/os-win32: Test for and use _lock_file/_unlock_file, Richard Henderson, 2022/03/20
- [PULL for-7.1 26/36] linux-user: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 27/36] softmmu: Use qemu_set_log_filename_flags, Richard Henderson, 2022/03/20
- [PULL for-7.1 28/36] util/log: Remove qemu_log_close,
Richard Henderson <=
- [PULL for-7.1 31/36] util/log: Rename qemu_logfile_mutex to global_mutex, Richard Henderson, 2022/03/20
- [PULL for-7.1 33/36] util/log: Combine two logfile closes, Richard Henderson, 2022/03/20
- [PULL for-7.1 35/36] util/log: Limit RCUCloseFILE to file closing, Richard Henderson, 2022/03/20
- [PULL for-7.1 32/36] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal, Richard Henderson, 2022/03/20
- [PULL for-7.1 36/36] util/log: Support per-thread log files, Richard Henderson, 2022/03/20
- [PULL for-7.1 34/36] util/log: Rename QemuLogFile to RCUCloseFILE, Richard Henderson, 2022/03/20
- Re: [PULL for-7.1 00/36] Logging cleanup and per-thread logfiles, Richard Henderson, 2022/03/20