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-devel

[Xen-devel] [PATCH][XEND]Reprt error for a existing file

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH][XEND]Reprt error for a existing file
From: "Kazuki Mizushima" <mizushima.kazuk@xxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2007 19:47:54 +0900
Delivery-date: Wed, 07 Mar 2007 02:47:13 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

I try to make a patch which reports error for a existing file to prevent overwriting before the file.

#xm dump-core 12 a.dump
Dumping core of domain: 12 ...
Error: Cannot dump core for existing file /tmp/a.dump
Usage: xm dump-core [-L|--live] [-C|--crash] <Domain> [Filename]

Dump core for a specific domain.
 -L, --live                     Dump core without pausing the domain
 -C, --crash                    Crash domain after dumping core

# xm save 12 a.save
Error: Cannot save for existing file /tmp/a.save
Usage: xm save <Domain> <CheckpointFile>

Save a domain state to restore later.
#

Signed-off-by: Kazuki Mizushima <mizushima.kazuk@xxxxxxxxxxxxxx>


diff -r 3ac19fda0bc2 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py       Fri Mar 02 12:11:52 2007 +0000
+++ b/tools/python/xen/xend/XendDomain.py       Wed Mar 07 14:57:58 2007 +0900
@@ -1094,6 +1094,9 @@ class XendDomain:
        if dominfo.getDomid() == DOM0_ID:
            raise XendError("Cannot dump core for privileged domain %s" % domid)

+        if os.path.exists(filename):
+            raise XendError("Cannot dump core for existing file %s" % filename)
+
        try:
            log.info("Domain core dump requested for domain %s (%d) "
                     "live=%d crash=%d.",
@@ -1190,6 +1193,9 @@ class XendDomain:

            if dominfo.getDomid() == DOM0_ID:
                raise XendError("Cannot save privileged domain %i" % domid)
+
+            if os.path.exists(dst):
+                raise XendError("Cannot save for existing file %s" % dst)

            oflags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
            if hasattr(os, "O_LARGEFILE"):



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