From: Edwin Zhai Subject: [PATCH] rename QEMU device model log file by dom id and redirect stdout/stderr only if spawning device model background. Date: Mon, 23 Jan 2006 11:11:37 +0800 Message-ID: <20060123031137.GA7005@edwin-gen.ccr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Pratt , Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org rename QEMU device model log file by dom id and redirect stdout/stderr only if spawning device model background. Signed-off-by: Zhai Edwin diff -r c4ae9456a459 tools/ioemu/exec.c --- a/tools/ioemu/exec.c Fri Jan 20 20:31:09 2006 +0100 +++ b/tools/ioemu/exec.c Mon Jan 23 11:02:47 2006 +0800 @@ -143,8 +143,10 @@ setvbuf(logfile, NULL, _IOLBF, 0); #endif - stdout = logfile; - stderr = logfile; + if ( !isatty( fileno(stdout))) { + stdout = logfile; + stderr = logfile; + } } } diff -r c4ae9456a459 tools/ioemu/vl.c --- a/tools/ioemu/vl.c Fri Jan 20 20:31:09 2006 +0100 +++ b/tools/ioemu/vl.c Mon Jan 23 11:02:47 2006 +0800 @@ -2699,11 +2699,6 @@ macaddr[4] = 0x34; macaddr[5] = 0x56; - /* init debug */ - sprintf(qemu_dm_logfilename, "/var/log/qemu-dm.%d.log", getpid()); - cpu_set_log_filename(qemu_dm_logfilename); - cpu_set_log(0); - optind = 1; for(;;) { if (optind >= argc) @@ -2913,6 +2908,12 @@ case QEMU_OPTION_d: { domid = atoi(optarg); + + /* init debug */ + sprintf(qemu_dm_logfilename, "/var/log/qemu-dm.dom%d.log", domid); + cpu_set_log_filename(qemu_dm_logfilename); + cpu_set_log(0); + fprintf(logfile, "domid: %d\n", domid); } break;