Skip to contentSkip to conversation

Reprt error for a existing file

PATCH Superseded Kazuki Mizushima 4 participants 7 messages Mar 7, 2007 – Mar 16, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reprt error for a existing file

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.
#

tools/python/xen/xend/XendDomain.py Wed Mar 07 14:57:58 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Fri Mar 02 12:11:52 2007 +0000 +6 -0
diff -r 3ac19fda0bc2 tools/python/xen/xend/XendDomain.py
@@ -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"):
#1 lore raw

PATCH RESEND 1/1 Reprt error for a existing file

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.

Quoted 9 lines

#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

Quoted 8 lines
# 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.
#

Thanks,
Kazuki Mizushima

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +6 -0
diff -r 517e67f0fe52 tools/python/xen/xend/XendDomain.py
@@ -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"):
#2 lore raw
Quoted 4 lines · Kazuki Mizushima

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.

Personally I like being able to overwrite state files without having to delete them. Which is why I've not applied this patch myself.

-- Keir

#3 lore raw
Quoted 15 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Keir Fraser
Sent: 15 March 2007 10:29
To: Kazuki Mizushima; [email protected]
Subject: Re: [Xen-devel] [PATCH][XEND][RESEND]Reprt error for a existing file

Quoted 1 line · Kazuki Mizushima

This patch prevents output file overwriting for xm

Quoted 8 lines

save/dump-core case.

Quoted 3 lines

Would you give me a comment on this patch? If not, please apply it. I made it again for the current.

Personally I like being able to overwrite state files without having to
delete them. Which is why I've not applied this patch myself.

Ah, I was just writing a reply like this:
Can I add a "personal opinion": I've been using a script to save/restore for a large number of cycles - it relies on overwriting the existing save-file. Would it be possibel to add a "-f|--force" to allow overwriting of the save/dump-file?

I have no objection to the patch as such, but it would be nice not to be able to save over the existing file if the user wants to.

--
Mats

Quoted 11 lines

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
In reply to Kazuki Mizushima

Hi, Kazuki

I think renaming filename is better.
Common Linux dump features(e.g. diskdump, netdump, and so on) are rename dumpfile when the same filename exist.

For example, what do you think renaming from <time>-<dom_name>.<dom_id>.core to <time>-<dom_name>.<dom_id>.core-1?

Best Regards,

Akio Takebe

Quoted 65 lines

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.

Quoted 9 lines

#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

Quoted 8 lines
# 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.
#

Thanks,
Kazuki Mizushima

diff -r 517e67f0fe52 tools/python/xen/xend/XendDomain.py

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +3 -0
@@ -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.",

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +3 -0
@@ -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
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Akio Takebe
Sent: 15 March 2007 12:32
To: Kazuki Mizushima; [email protected]
Subject: Re: [Xen-devel] [PATCH][XEND][RESEND]Reprt error for a existing file

Hi, Kazuki

Quoted 7 lines

I think renaming filename is better.
Common Linux dump features(e.g. diskdump, netdump, and so on) are rename dumpfile when the same filename exist.

For example, what do you think renaming from
<time>-<dom_name>.<dom_id>.core
to <time>-<dom_name>.<dom_id>.core-1?

That's fine for dump-files. I don't think the concept is good for save-files, as there's many reasons one would want to save/restore the same domain over and over (say for example daily back-ups, after a month you'd have 30 or so files!).

--
Mats

Quoted 88 lines

Best Regards,

Akio Takebe

Quoted 3 lines

Hi,

This patch prevents output file overwriting for xm

save/dump-core case.

Quoted 12 lines

Would you give me a comment on this patch? If not, please apply it. I made it again for the current.

Quoted 7 lines

#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

Quoted 12 lines
Quoted 10 lines

-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.
#

Quoted 6 lines

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

Quoted 1 line

+++ b/tools/python/xen/xend/XendDomain.py Thu Mar 15

18:41:49 2007 +0900

Review class XendDomain: · line 1095

Quoted 3 lines
(quoted diff) +0 -0
@@ -1094,6 +1094,9 @@ class XendDomain:
        if dominfo.getDomid() == DOM0_ID:
            raise XendError("Cannot dump core for 

privileged domain %s" %

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 class XendDomain:

Quoted 4 lines
tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +2 -0
 domid)
 
+        if os.path.exists(filename):
+            raise XendError("Cannot dump core for existing 

file %s" %

Quoted 4 lines
tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +1 -0
 filename)
+
        try:

log.info("Domain core dump requested for domain

%s (%d) "

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 class XendDomain: · line 1195

Quoted 5 lines
                     "live=%d crash=%d.",
tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +0 -0
@@ -1190,6 +1193,9 @@ class XendDomain:
 
            if dominfo.getDomid() == DOM0_ID:
                raise XendError("Cannot save privileged 

domain %i" % domid)

tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 class XendDomain:

Quoted 3 lines
tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +3 -0
+
+            if os.path.exists(dst):
+                raise XendError("Cannot save for existing 

file %s" % dst)

Quoted 8 lines
tools/python/xen/xend/XendDomain.py Thu Mar 15 18:41:49 2007 +0900 renamed from tools/python/xen/xend/XendDomain.py Wed Mar 14 19:35:26 2007 +0000 +0 -0
            oflags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC
            if hasattr(os, "O_LARGEFILE"):
 
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw

Hi, Mats

Quoted 5 lines

That's fine for dump-files. I don't think the concept is good for save-files, as there's many reasons one would want to save/restore the same domain over and over (say for example daily back-ups, after a month you'd have 30 or so files!).

I agree.

Best Regards,

Akio Takebe