WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xend: improve the rotation of qemu-dm log

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xend: improve the rotation of qemu-dm logfiles.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Jul 2008 05:50:09 -0700
Delivery-date: Tue, 01 Jul 2008 05:50:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1214906323 -3600
# Node ID 20966aa897390b622fd0d4286dc812a09450eb8c
# Parent  c33a40b4c22bfdd1cdc808bda2bd4d19f48ee4dc
xend: improve the rotation of qemu-dm logfiles.

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>
---
 tools/examples/xend-config.sxp       |    3 +++
 tools/python/xen/xend/XendOptions.py |    7 +++++++
 tools/python/xen/xend/image.py       |   16 ++++++++++++----
 3 files changed, 22 insertions(+), 4 deletions(-)

diff -r c33a40b4c22b -r 20966aa89739 tools/examples/xend-config.sxp
--- a/tools/examples/xend-config.sxp    Mon Jun 30 14:19:09 2008 +0100
+++ b/tools/examples/xend-config.sxp    Tue Jul 01 10:58:43 2008 +0100
@@ -242,3 +242,6 @@
 
 # Script to run when the label of a resource has changed.
 #(resource-label-change-script '')
+
+# Rotation count of qemu-dm log file.
+#(qemu-dm-logrotate-count 10)
diff -r c33a40b4c22b -r 20966aa89739 tools/python/xen/xend/XendOptions.py
--- a/tools/python/xen/xend/XendOptions.py      Mon Jun 30 14:19:09 2008 +0100
+++ b/tools/python/xen/xend/XendOptions.py      Tue Jul 01 10:58:43 2008 +0100
@@ -132,6 +132,9 @@ class XendOptions:
     """Default script to configure a backend network interface"""
     vif_script = osdep.vif_script
 
+    """Default rotation count of qemu-dm log file."""
+    qemu_dm_logrotate_count = 10
+
     def __init__(self):
         self.configure()
 
@@ -350,6 +353,10 @@ class XendOptions:
 
     def get_vnc_x509_verify(self):
         return self.get_config_string('vnc-x509-verify', 
self.xend_vnc_x509_verify)
+
+    def get_qemu_dm_logrotate_count(self):
+        return self.get_config_int("qemu-dm-logrotate-count",
+                                   self.qemu_dm_logrotate_count)
 
 
 class XendOptionsFile(XendOptions):
diff -r c33a40b4c22b -r 20966aa89739 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Mon Jun 30 14:19:09 2008 +0100
+++ b/tools/python/xen/xend/image.py    Tue Jul 01 10:58:43 2008 +0100
@@ -378,10 +378,18 @@ 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'])
-        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")
+
+        # rotate log
+        logrotate_count = XendOptions.instance().get_qemu_dm_logrotate_count()
+        if logrotate_count > 0:
+            if os.path.exists("%s.%d" % (self.logfile, logrotate_count)):
+                os.unlink("%s.%d" % (self.logfile, logrotate_count))
+            for n in range(logrotate_count - 1, 0, -1):
+                if os.path.exists("%s.%d" % (self.logfile, n)):
+                    os.rename("%s.%d" % (self.logfile, n),
+                              "%s.%d" % (self.logfile, (n + 1)))
+            if os.path.exists(self.logfile):
+                os.rename(self.logfile, self.logfile + ".1")
 
         null = os.open("/dev/null", os.O_RDONLY)
         logfd = os.open(self.logfile, 
os.O_WRONLY|os.O_CREAT|os.O_TRUNC|os.O_APPEND)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xend: improve the rotation of qemu-dm logfiles., Xen patchbot-unstable <=