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)