mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
Command line support for altering the log file location
Add command line support for logging to a location other than /tmp/qemu.log. With logging enabled (command line option -d), the log is written to the hard-coded path /tmp/qemu.log. This patch adds support for writing the log to a different location by passing the -D option. Signed-off-by: Matthew Fernandez <matthew.fernandez@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
71f34ad053
commit
c235d7387c
7 changed files with 114 additions and 54 deletions
|
@ -2832,6 +2832,8 @@ int main(int argc, char **argv, char **envp)
|
|||
{
|
||||
const char *filename;
|
||||
const char *cpu_model;
|
||||
const char *log_file = DEBUG_LOGFILE;
|
||||
const char *log_mask = NULL;
|
||||
struct target_pt_regs regs1, *regs = ®s1;
|
||||
struct image_info info1, *info = &info1;
|
||||
struct linux_binprm bprm;
|
||||
|
@ -2853,9 +2855,6 @@ int main(int argc, char **argv, char **envp)
|
|||
|
||||
qemu_cache_utils_init(envp);
|
||||
|
||||
/* init debug */
|
||||
cpu_set_log_filename(DEBUG_LOGFILE);
|
||||
|
||||
if ((envlist = envlist_create()) == NULL) {
|
||||
(void) fprintf(stderr, "Unable to allocate envlist\n");
|
||||
exit(1);
|
||||
|
@ -2894,22 +2893,15 @@ int main(int argc, char **argv, char **envp)
|
|||
if (!strcmp(r, "-")) {
|
||||
break;
|
||||
} else if (!strcmp(r, "d")) {
|
||||
int mask;
|
||||
const CPULogItem *item;
|
||||
|
||||
if (optind >= argc)
|
||||
if (optind >= argc) {
|
||||
break;
|
||||
|
||||
r = argv[optind++];
|
||||
mask = cpu_str_to_log_mask(r);
|
||||
if (!mask) {
|
||||
printf("Log items (comma separated):\n");
|
||||
for(item = cpu_log_items; item->mask != 0; item++) {
|
||||
printf("%-10s %s\n", item->name, item->help);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
cpu_set_log(mask);
|
||||
log_mask = argv[optind++];
|
||||
} else if (!strcmp(r, "D")) {
|
||||
if (optind >= argc) {
|
||||
break;
|
||||
}
|
||||
log_file = argv[optind++];
|
||||
} else if (!strcmp(r, "E")) {
|
||||
r = argv[optind++];
|
||||
if (envlist_setenv(envlist, r) != 0)
|
||||
|
@ -3022,6 +3014,23 @@ int main(int argc, char **argv, char **envp)
|
|||
filename = argv[optind];
|
||||
exec_path = argv[optind];
|
||||
|
||||
/* init debug */
|
||||
cpu_set_log_filename(log_file);
|
||||
if (log_mask) {
|
||||
int mask;
|
||||
const CPULogItem *item;
|
||||
|
||||
mask = cpu_str_to_log_mask(r);
|
||||
if (!mask) {
|
||||
printf("Log items (comma separated):\n");
|
||||
for (item = cpu_log_items; item->mask != 0; item++) {
|
||||
printf("%-10s %s\n", item->name, item->help);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
cpu_set_log(mask);
|
||||
}
|
||||
|
||||
/* Zero out regs */
|
||||
memset(regs, 0, sizeof(struct target_pt_regs));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue