aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-07-01 10:59:09 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-07-01 10:59:09 +0100
commit03f7fd7c9f565b3c6f30a7ac82bdfe5fb0ca6127 (patch)
tree73518836ab52b5e2664919dc025402f1b51f18d3
parentda67ff89f75e515d873ab42169aed36603b38183 (diff)
downloadxen-03f7fd7c9f565b3c6f30a7ac82bdfe5fb0ca6127.tar.gz
xen-03f7fd7c9f565b3c6f30a7ac82bdfe5fb0ca6127.tar.bz2
xen-03f7fd7c9f565b3c6f30a7ac82bdfe5fb0ca6127.zip
xend: open qemu-dm logfile in append mode if log rotation is disabled by config.
Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
-rw-r--r--tools/python/xen/xend/image.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index 4cf792fe88..ccebcfc033 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -380,8 +380,10 @@ class ImageHandler:
self.logfile = "/var/log/xen/qemu-dm-%s.log" % str(self.vm.info['name_label'])
# rotate log
+ logfile_mode = os.O_WRONLY|os.O_CREAT|os.O_APPEND
logrotate_count = XendOptions.instance().get_qemu_dm_logrotate_count()
if logrotate_count > 0:
+ logfile_mode |= os.O_TRUNC
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):
@@ -392,7 +394,7 @@ class ImageHandler:
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)
+ logfd = os.open(self.logfile, logfile_mode)
sys.stderr.flush()
pid = os.fork()