From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yosuke Iwamatsu Subject: Re: [PATCH] xend: open qemu-dm log files in append mode Date: Fri, 27 Jun 2008 18:31:08 +0900 Message-ID: <4864B35C.6050403@ab.jp.nec.com> References: <486323E3.3000407@ab.jp.nec.com> <18531.44047.726185.484243@mariner.uk.xensource.com> <20080626145100.GO20952@redhat.com> <18531.45028.236043.309416@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080009000600030103020400" Return-path: In-Reply-To: <18531.45028.236043.309416@mariner.uk.xensource.com> 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 Jackson Cc: Yuji Shimada , xen-devel@lists.xensource.com, berrange@redhat.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------080009000600030103020400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Ian Jackson wrote: > Daniel P. Berrange writes ("Re: [Xen-devel] [PATCH] xend: open qemu-dm log files in append mode"): >> XenD already does rotate the qemu logs unless the code I added todo >> that has since been removed, so if the domain reboots we should keep >> at least one historic log > > It only keeps one. I think Yuji Shimada would like more than one but > that would be a straightforward change to make to the code. > > Ian. So the attached patch improves the qemu-log rotation in xend to keep maximum of 20 backup logfiles per domain. I still prefer the previous patch that will avoid information loss when, for example, a guest repeats cursh and reboot. But this patch might be at least a little bit better than the current one-historic-backup solution. Any comment? Thanks, Yosuke --------------080009000600030103020400 Content-Type: all/allfiles; name="qemu-log-rotate.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-log-rotate.patch" xend: improve the rotation of qemu-dm logfiles. Signed-off-by: Yosuke Iwamatsu diff -r 926a366ca82f tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Fri Jun 20 15:21:26 2008 +0100 +++ b/tools/python/xen/xend/image.py Fri Jun 27 16:54:40 2008 +0900 @@ -378,9 +378,16 @@ class ImageHandler: # keep track of pid and spawned options to kill it later self.logfile = "/var/log/xen/qemu-dm-%s.log" % str(self.vm.info['name_label']) + + # rotate log + nr_max_log_rotation = 20 + if os.path.exists(self.logfile + ".%d" % nr_max_log_rotation): + os.unlink(self.logfile + ".%d" % nr_max_log_rotation) + for n in range(nr_max_log_rotation - 1, 0, -1): + if os.path.exists(self.logfile + ".%d" % n): + os.rename(self.logfile + ".%d" % n, + self.logfile + ".%d" % (n + 1)) if os.path.exists(self.logfile): - if os.path.exists(self.logfile + ".1"): - os.unlink(self.logfile + ".1") os.rename(self.logfile, self.logfile + ".1") null = os.open("/dev/null", os.O_RDONLY) --------------080009000600030103020400 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------080009000600030103020400--