From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kazuki Mizushima" Subject: [PATCH][XEND][RESEND]Reprt error for a existing file Date: Thu, 15 Mar 2007 19:18:00 +0900 Message-ID: <027b01c766eb$356e5780$a1ec830a@dirac> References: <016f01c760a6$0f67d890$a1ec830a@dirac> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=response Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi, This patch prevents output file overwriting for xm save/dump-core case. Would you give me a comment on this patch? If not, please apply it. I made it again for the current. > #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] [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 > > Save a domain state to restore later. > # > > Signed-off-by: Kazuki Mizushima Thanks, Kazuki Mizushima diff -r 517e67f0fe52 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +++ b/tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 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"):