mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
util/log: Pass Error pointer to qemu_set_log
Do not force exit within qemu_set_log; return bool and pass an Error value back up the stack as per usual. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-5-richard.henderson@linaro.org>
This commit is contained in:
parent
e2c7c6a454
commit
c5955f4ff4
12 changed files with 22 additions and 18 deletions
12
util/log.c
12
util/log.c
|
@ -73,7 +73,7 @@ static void qemu_logfile_free(QemuLogFile *logfile)
|
|||
}
|
||||
|
||||
/* enable or disable low levels log */
|
||||
void qemu_set_log(int log_flags)
|
||||
bool qemu_set_log(int log_flags, Error **errp)
|
||||
{
|
||||
bool need_to_open_file = false;
|
||||
QemuLogFile *logfile;
|
||||
|
@ -103,9 +103,9 @@ void qemu_set_log(int log_flags)
|
|||
if (logfilename) {
|
||||
logfile->fd = fopen(logfilename, log_append ? "a" : "w");
|
||||
if (!logfile->fd) {
|
||||
g_free(logfile);
|
||||
perror(logfilename);
|
||||
_exit(1);
|
||||
error_setg_errno(errp, errno, "Error opening logfile %s",
|
||||
logfilename);
|
||||
return false;
|
||||
}
|
||||
/* In case we are a daemon redirect stderr to logfile */
|
||||
if (is_daemonized()) {
|
||||
|
@ -129,6 +129,7 @@ void qemu_set_log(int log_flags)
|
|||
log_append = 1;
|
||||
qatomic_rcu_set(&qemu_logfile, logfile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -159,8 +160,7 @@ bool qemu_set_log_filename(const char *filename, Error **errp)
|
|||
}
|
||||
|
||||
qemu_log_close();
|
||||
qemu_set_log(qemu_loglevel);
|
||||
return true;
|
||||
return qemu_set_log(qemu_loglevel, errp);
|
||||
}
|
||||
|
||||
/* Returns true if addr is in our debug filter or no filter defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue