From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QT1Tt-0002uM-Ku for qemu-devel@nongnu.org; Sat, 04 Jun 2011 20:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QT1Tr-0002K3-Lc for qemu-devel@nongnu.org; Sat, 04 Jun 2011 20:46:17 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:38788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QT1Tr-0002IR-5c for qemu-devel@nongnu.org; Sat, 04 Jun 2011 20:46:15 -0400 Received: by iwl42 with SMTP id 42so3118862iwl.4 for ; Sat, 04 Jun 2011 17:46:13 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 5 Jun 2011 10:46:13 +1000 Message-ID: From: Matthew Fernandez Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Command line support for altering the log file location List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Anthony Liguori , qemu-devel@nongnu.org So, to clarify, all text above the '----' is included as the commit message and the sign off line should be in this section. All text below the '----' before the first diff is treated as comments that are not to be committed. Is this correct? If so I'll send through an ammended patch with these changes. On 4 June 2011 20:18, Blue Swirl wrote: > On Tue, May 31, 2011 at 9:20 AM, Matthew Fernandez > wrote: >> Hi, >> >> The included patch adds command line support for logging to a location >> other than /tmp/qemu.log. The diff is relative to commit >> 2eb9f241824d000fcd90bd7f4b49e40b88e62975. Please let me know if >> anything needs to be cleaned up or changed. Anthony, I'm not sure who >> should be responsible for reviewing/accepting this, but I've CCed you >> as it touches vl.c. > > The patch looks OK, however the above text (which git-am would use as > the commit message) needs to be changed. How about something like > this: > Add command line support for logging to a location other than /tmp/qemu.l= og. > > If you want to add comments which should not go to the commit message, > please put them below the line with '----'. > >> Thanks, >> Matthew >> >> ---- >> Signed-off-by: Matthew Fernandez > > Also this needs to be above the =A0'----' line. > >> >> diff --git a/bsd-user/main.c b/bsd-user/main.c >> index 0c3fca1..0af8a7e 100644 >> --- a/bsd-user/main.c >> +++ b/bsd-user/main.c >> @@ -690,7 +690,8 @@ static void usage(void) >> =A0 =A0 =A0 =A0 =A0 =A0"-bsd type =A0 =A0 =A0 =A0 select emulated BSD ty= pe >> FreeBSD/NetBSD/OpenBSD (default)\n" >> =A0 =A0 =A0 =A0 =A0 =A0"\n" >> =A0 =A0 =A0 =A0 =A0 =A0"Debug options:\n" >> - =A0 =A0 =A0 =A0 =A0 "-d options =A0 activate log (logfile=3D%s)\n" >> + =A0 =A0 =A0 =A0 =A0 "-d options =A0 activate log (default logfile=3D%s= )\n" >> + =A0 =A0 =A0 =A0 =A0 "-D logfile =A0 override default logfile location\= n" >> =A0 =A0 =A0 =A0 =A0 =A0"-p pagesize =A0set the host page size to 'pagesi= ze'\n" >> =A0 =A0 =A0 =A0 =A0 =A0"-singlestep =A0always run in singlestep mode\n" >> =A0 =A0 =A0 =A0 =A0 =A0"-strace =A0 =A0 =A0log system calls\n" >> @@ -731,6 +732,8 @@ int main(int argc, char **argv) >> =A0{ >> =A0 =A0 const char *filename; >> =A0 =A0 const char *cpu_model; >> + =A0 =A0const char *log_file =3D DEBUG_LOGFILE; >> + =A0 =A0const char *log_mask =3D NULL; >> =A0 =A0 struct target_pt_regs regs1, *regs =3D ®s1; >> =A0 =A0 struct image_info info1, *info =3D &info1; >> =A0 =A0 TaskState ts1, *ts =3D &ts1; >> @@ -745,9 +748,6 @@ int main(int argc, char **argv) >> =A0 =A0 if (argc <=3D 1) >> =A0 =A0 =A0 =A0 usage(); >> >> - =A0 =A0/* init debug */ >> - =A0 =A0cpu_set_log_filename(DEBUG_LOGFILE); >> - >> =A0 =A0 if ((envlist =3D envlist_create()) =3D=3D NULL) { >> =A0 =A0 =A0 =A0 (void) fprintf(stderr, "Unable to allocate envlist\n"); >> =A0 =A0 =A0 =A0 exit(1); >> @@ -775,22 +775,15 @@ int main(int argc, char **argv) >> =A0 =A0 =A0 =A0 if (!strcmp(r, "-")) { >> =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "d")) { >> - =A0 =A0 =A0 =A0 =A0 =A0int mask; >> - =A0 =A0 =A0 =A0 =A0 =A0const CPULogItem *item; >> - >> - =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >> - >> - =A0 =A0 =A0 =A0 =A0 =A0r =3D argv[optind++]; >> - =A0 =A0 =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> - =A0 =A0 =A0 =A0 =A0 =A0if (!mask) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"= ); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for(item =3D cpu_log_items; item->mask = !=3D 0; item++) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name= , item->help); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0 =A0 =A0 =A0 =A0log_mask =3D argv[optind++]; >> + =A0 =A0 =A0 =A0} else if (!strcmp(r, "D")) { >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0log_file =3D argv[optind++]; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "E")) { >> =A0 =A0 =A0 =A0 =A0 =A0 r =3D argv[optind++]; >> =A0 =A0 =A0 =A0 =A0 =A0 if (envlist_setenv(envlist, r) !=3D 0) >> @@ -867,6 +860,23 @@ int main(int argc, char **argv) >> =A0 =A0 =A0 =A0 usage(); >> =A0 =A0 filename =3D argv[optind]; >> >> + =A0 =A0/* init debug */ >> + =A0 =A0cpu_set_log_filename(log_file); >> + =A0 =A0if (log_mask) { >> + =A0 =A0 =A0 =A0int mask; >> + =A0 =A0 =A0 =A0const CPULogItem *item; >> + >> + =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> + =A0 =A0 =A0 =A0if (!mask) { >> + =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"); >> + =A0 =A0 =A0 =A0 =A0 =A0for (item =3D cpu_log_items; item->mask !=3D 0;= item++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name, item->= help); >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> + =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0} >> + >> =A0 =A0 /* Zero out regs */ >> =A0 =A0 memset(regs, 0, sizeof(struct target_pt_regs)); >> >> diff --git a/cpus.c b/cpus.c >> index 1fc34b7..17e96b5 100644 >> --- a/cpus.c >> +++ b/cpus.c >> @@ -1142,6 +1142,11 @@ void set_cpu_log(const char *optarg) >> =A0 =A0 cpu_set_log(mask); >> =A0} >> >> +void set_cpu_log_filename(const char *optarg) >> +{ >> + =A0 =A0cpu_set_log_filename(optarg); >> +} >> + >> =A0/* Return the virtual CPU time, based on the instruction counter. =A0= */ >> =A0int64_t cpu_get_icount(void) >> =A0{ >> diff --git a/cpus.h b/cpus.h >> index 6fdeb0d..f42b54e 100644 >> --- a/cpus.h >> +++ b/cpus.h >> @@ -19,6 +19,7 @@ void vm_state_notify(int running, int reason); >> =A0bool cpu_exec_all(void); >> =A0void set_numa_modes(void); >> =A0void set_cpu_log(const char *optarg); >> +void set_cpu_log_filename(const char *optarg); >> =A0void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *opt= arg); >> >> =A0#endif >> diff --git a/darwin-user/main.c b/darwin-user/main.c >> index 175e12f..a6dc859 100644 >> --- a/darwin-user/main.c >> +++ b/darwin-user/main.c >> @@ -738,6 +738,8 @@ TaskState *first_task_state; >> =A0int main(int argc, char **argv) >> =A0{ >> =A0 =A0 const char *filename; >> + =A0 =A0const char *log_file =3D DEBUG_LOGFILE; >> + =A0 =A0const char *log_mask =3D NULL; >> =A0 =A0 struct target_pt_regs regs1, *regs =3D ®s1; >> =A0 =A0 TaskState ts1, *ts =3D &ts1; >> =A0 =A0 CPUState *env; >> @@ -749,9 +751,6 @@ int main(int argc, char **argv) >> =A0 =A0 if (argc <=3D 1) >> =A0 =A0 =A0 =A0 usage(); >> >> - =A0 =A0/* init debug */ >> - =A0 =A0cpu_set_log_filename(DEBUG_LOGFILE); >> - >> =A0 =A0 optind =3D 1; >> =A0 =A0 for(;;) { >> =A0 =A0 =A0 =A0 if (optind >=3D argc) >> @@ -764,22 +763,15 @@ int main(int argc, char **argv) >> =A0 =A0 =A0 =A0 if (!strcmp(r, "-")) { >> =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "d")) { >> - =A0 =A0 =A0 =A0 =A0 =A0int mask; >> - =A0 =A0 =A0 =A0 =A0 =A0CPULogItem *item; >> - >> - =A0 =A0 =A0 =A0if (optind >=3D argc) >> - =A0 =A0 =A0 =A0break; >> - >> - =A0 =A0 =A0 =A0r =3D argv[optind++]; >> - =A0 =A0 =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> - =A0 =A0 =A0 =A0 =A0 =A0if (!mask) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"= ); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for(item =3D cpu_log_items; item->mask = !=3D 0; item++) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name= , item->help); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0 =A0 =A0 =A0 =A0log_mask =3D argv[optind++]; >> + =A0 =A0 =A0 =A0} else if (!strcmp(r, "D")) { >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0log_file =3D argv[optind++]; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "s")) { >> =A0 =A0 =A0 =A0 =A0 =A0 r =3D argv[optind++]; >> =A0 =A0 =A0 =A0 =A0 =A0 stack_size =3D strtol(r, (char **)&r, 0); >> @@ -821,6 +813,23 @@ int main(int argc, char **argv) >> =A0 =A0 =A0 =A0 usage(); >> =A0 =A0 filename =3D argv[optind]; >> >> + =A0 =A0/* init debug */ >> + =A0 =A0cpu_set_log_filename(log_file); >> + =A0 =A0if (log_mask) { >> + =A0 =A0 =A0 =A0int mask; >> + =A0 =A0 =A0 =A0CPULogItem *item; >> + >> + =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> + =A0 =A0 =A0 =A0if (!mask) { >> + =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"); >> + =A0 =A0 =A0 =A0 =A0 =A0for (item =3D cpu_log_items; item->mask !=3D 0;= item++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name, item->= help); >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> + =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0} >> + >> =A0 =A0 /* Zero out regs */ >> =A0 =A0 memset(regs, 0, sizeof(struct target_pt_regs)); >> >> diff --git a/linux-user/main.c b/linux-user/main.c >> index 088def3..23c229c 100644 >> --- a/linux-user/main.c >> +++ b/linux-user/main.c >> @@ -2848,6 +2848,8 @@ int main(int argc, char **argv, char **envp) >> =A0{ >> =A0 =A0 const char *filename; >> =A0 =A0 const char *cpu_model; >> + =A0 =A0const char *log_file =3D DEBUG_LOGFILE; >> + =A0 =A0const char *log_mask =3D NULL; >> =A0 =A0 struct target_pt_regs regs1, *regs =3D ®s1; >> =A0 =A0 struct image_info info1, *info =3D &info1; >> =A0 =A0 struct linux_binprm bprm; >> @@ -2869,9 +2871,6 @@ int main(int argc, char **argv, char **envp) >> >> =A0 =A0 qemu_cache_utils_init(envp); >> >> - =A0 =A0/* init debug */ >> - =A0 =A0cpu_set_log_filename(DEBUG_LOGFILE); >> - >> =A0 =A0 if ((envlist =3D envlist_create()) =3D=3D NULL) { >> =A0 =A0 =A0 =A0 (void) fprintf(stderr, "Unable to allocate envlist\n"); >> =A0 =A0 =A0 =A0 exit(1); >> @@ -2910,22 +2909,15 @@ int main(int argc, char **argv, char **envp) >> =A0 =A0 =A0 =A0 if (!strcmp(r, "-")) { >> =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "d")) { >> - =A0 =A0 =A0 =A0 =A0 =A0int mask; >> - =A0 =A0 =A0 =A0 =A0 =A0const CPULogItem *item; >> - >> - =A0 =A0 =A0 =A0 =A0 if (optind >=3D argc) >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> - >> - =A0 =A0 =A0 =A0 =A0 r =3D argv[optind++]; >> - =A0 =A0 =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> - =A0 =A0 =A0 =A0 =A0 =A0if (!mask) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"= ); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for(item =3D cpu_log_items; item->mask = !=3D 0; item++) { >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name= , item->help); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> =A0 =A0 =A0 =A0 =A0 =A0 } >> - =A0 =A0 =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0 =A0 =A0 =A0 =A0log_mask =3D argv[optind++]; >> + =A0 =A0 =A0 =A0} else if (!strcmp(r, "D")) { >> + =A0 =A0 =A0 =A0 =A0 =A0if (optind >=3D argc) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0log_file =3D argv[optind++]; >> =A0 =A0 =A0 =A0 } else if (!strcmp(r, "E")) { >> =A0 =A0 =A0 =A0 =A0 =A0 r =3D argv[optind++]; >> =A0 =A0 =A0 =A0 =A0 =A0 if (envlist_setenv(envlist, r) !=3D 0) >> @@ -3038,6 +3030,23 @@ int main(int argc, char **argv, char **envp) >> =A0 =A0 filename =3D argv[optind]; >> =A0 =A0 exec_path =3D argv[optind]; >> >> + =A0 =A0/* init debug */ >> + =A0 =A0cpu_set_log_filename(log_file); >> + =A0 =A0if (log_mask) { >> + =A0 =A0 =A0 =A0int mask; >> + =A0 =A0 =A0 =A0const CPULogItem *item; >> + >> + =A0 =A0 =A0 =A0mask =3D cpu_str_to_log_mask(r); >> + =A0 =A0 =A0 =A0if (!mask) { >> + =A0 =A0 =A0 =A0 =A0 =A0printf("Log items (comma separated):\n"); >> + =A0 =A0 =A0 =A0 =A0 =A0for (item =3D cpu_log_items; item->mask !=3D 0;= item++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("%-10s %s\n", item->name, item->= help); >> + =A0 =A0 =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0 =A0 =A0exit(1); >> + =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0cpu_set_log(mask); >> + =A0 =A0} >> + >> =A0 =A0 /* Zero out regs */ >> =A0 =A0 memset(regs, 0, sizeof(struct target_pt_regs)); >> >> diff --git a/qemu-options.hx b/qemu-options.hx >> index 82e085a..05513e8 100644 >> --- a/qemu-options.hx >> +++ b/qemu-options.hx >> @@ -1991,6 +1991,15 @@ STEXI >> =A0Output log in /tmp/qemu.log >> =A0ETEXI >> >> +DEF("D", HAS_ARG, QEMU_OPTION_D, \ >> + =A0 =A0"-D logfile =A0 =A0 =A0output log to logfile (instead of the de= fault >> /tmp/qemu.log)\n", >> + =A0 =A0QEMU_ARCH_ALL) >> +STEXI >> +@item -D >> +@findex -D >> +Output log in logfile instead of /tmp/qemu.log >> +ETEXI >> + >> =A0DEF("hdachs", HAS_ARG, QEMU_OPTION_hdachs, \ >> =A0 =A0 "-hdachs c,h,s[,t]\n" \ >> =A0 =A0 " =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0force hard disk 0 physical geom= etry and the >> optional BIOS\n" \ >> diff --git a/vl.c b/vl.c >> index b362871..e459f64 100644 >> --- a/vl.c >> +++ b/vl.c >> @@ -2060,6 +2060,8 @@ int main(int argc, char **argv, char **envp) >> =A0#endif >> =A0 =A0 int defconfig =3D 1; >> =A0 =A0 const char *trace_file =3D NULL; >> + =A0 =A0const char *log_mask =3D NULL; >> + =A0 =A0const char *log_file =3D NULL; >> >> =A0 =A0 atexit(qemu_run_exit_notifiers); >> =A0 =A0 error_set_progname(argv[0]); >> @@ -2434,7 +2436,10 @@ int main(int argc, char **argv, char **envp) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0#endif >> =A0 =A0 =A0 =A0 =A0 =A0 case QEMU_OPTION_d: >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_cpu_log(optarg); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0log_mask =3D optarg; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break; >> + =A0 =A0 =A0 =A0 =A0 =A0case QEMU_OPTION_D: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0log_file =3D optarg; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break; >> =A0 =A0 =A0 =A0 =A0 =A0 case QEMU_OPTION_s: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gdbstub_dev =3D "tcp::" DEFAULT_GDBSTUB_= PORT; >> @@ -2900,6 +2905,18 @@ int main(int argc, char **argv, char **envp) >> =A0 =A0 } >> =A0 =A0 loc_set_none(); >> >> + =A0 =A0/* Open the logfile at this point, if necessary. We can't open = the logfile >> + =A0 =A0 * when encountering either of the logging options (-d or -D) b= ecause the >> + =A0 =A0 * other one may be encountered later on the command line, chan= ging the >> + =A0 =A0 * location or level of logging. >> + =A0 =A0 */ >> + =A0 =A0if (log_mask) { >> + =A0 =A0 =A0 =A0if (log_file) { >> + =A0 =A0 =A0 =A0 =A0 =A0set_cpu_log_filename(log_file); >> + =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0set_cpu_log(log_mask); >> + =A0 =A0} >> + >> =A0 =A0 if (!st_init(trace_file)) { >> =A0 =A0 =A0 =A0 fprintf(stderr, "warning: unable to initialize simple tr= ace >> backend\n"); >> =A0 =A0 } >> >> >