Skip to contentSkip to conversation

tools/pygrub: store kernels in /var/run/pygrub

PATCH Superseded Olaf Hering 5 participants 8 messages Apr 17, 2014 – Apr 22, 2014

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/pygrub: store kernels in /var/run/pygrub

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/pygrub. If the directory does not exist create it, unless --output-directory=<dir> was specified.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

---

New code not runtime tested as pygrub, just as hello_world.py...

 tools/pygrub/src/pygrub | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
tools/pygrub/src/pygrub +12 -1
index 54fecee..a89fd49 100644
@@ -14,6 +14,7 @@
 #
 
 import os, sys, string, struct, tempfile, re, traceback
+import errno
 import copy
 import logging
 import platform
@@ -757,7 +758,7 @@ if __name__ == "__main__":
     debug = False
     not_really = False
     output_format = "sxp"
-    output_directory = "/var/run/xend/boot"
+    output_directory = None
 
     # what was passed in
     incfg = { "kernel": None, "ramdisk": None, "args": "" }
@@ -813,6 +814,16 @@ if __name__ == "__main__":
     if debug:
 	logging.basicConfig(level=logging.DEBUG)
 
+    if output_directory is None:
+        output_directory = "/var/run/pygrub"
+        try:
+            os.mkdir(output_directory, 0700)
+        except OSError as exc:
+            if exc.errno == errno.EEXIST and os.path.isdir(output_directory):
+                pass
+            else:
+                raise
+
     if output is None or output == "-":
         fd = sys.stdout.fileno()
     else:
#1 lore raw
Quoted 11 lines · Olaf Hering

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/pygrub. If the directory does not exist create it, unless --output-directory=<dir> was specified.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

---

New code not runtime tested as pygrub, just as hello_world.py...

I don't think it is valid in the slightest for programs like this to be mkdir()ing their environment. It is very much a packaging responsibility.

Quoted 26 lines
 tools/pygrub/src/pygrub | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
tools/pygrub/src/pygrub +2 -1
index 54fecee..a89fd49 100644
@@ -14,6 +14,7 @@
 #
 
 import os, sys, string, struct, tempfile, re, traceback
+import errno
 import copy
 import logging
 import platform
@@ -757,7 +758,7 @@ if __name__ == "__main__":
     debug = False
     not_really = False
     output_format = "sxp"
-    output_directory = "/var/run/xend/boot"
+    output_directory = None
 
     # what was passed in
     incfg = { "kernel": None, "ramdisk": None, "args": "" }

tools/pygrub/src/pygrub if __name__ == "__main__": · line 821

Quoted 8 lines
tools/pygrub/src/pygrub +5 -0
@@ -813,6 +814,16 @@ if __name__ == "__main__":
     if debug:
 	logging.basicConfig(level=logging.DEBUG)
 
+    if output_directory is None:
+        output_directory = "/var/run/pygrub"
+        try:
+            os.mkdir(output_directory, 0700)
+        except OSError as exc:

This is only valid for python 2.5 (or possibly 2.6). You want

except OSError,exc:

for 2.4 compatibility.

~Andrew

Quoted 13 lines
tools/pygrub/src/pygrub +5 -0
+            if exc.errno == errno.EEXIST and os.path.isdir(output_directory):
+                pass
+            else:
+                raise
+
     if output is None or output == "-":
         fd = sys.stdout.fileno()
     else:

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

#2 lore raw
Quoted 2 lines · Andrew Cooper

I don't think it is valid in the slightest for programs like this to be mkdir()ing their environment. It is very much a packaging responsibility.

So the startup scripts have to do that mkdir once at bootup?

Olaf

#3 lore raw
In reply to Andrew Cooper
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Olaf Hering

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/pygrub. If the directory does not exist create it, unless --output-directory=<dir> was specified.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

Quoted 7 lines
Quoted 4 lines

---

New code not runtime tested as pygrub, just as hello_world.py...

I don't think it is valid in the slightest for programs like this to be mkdir()ing their environment. It is very much a packaging responsibility.

/var/run may not be persistent so this can't be done by the packaging.

David

#4 lore raw
In reply to Olaf Hering

Olaf Hering writes ("[PATCH] tools/pygrub: store kernels in /var/run/pygrub"):

Quoted 6 lines

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/pygrub. If the directory does not exist create it, unless --output-directory=<dir> was specified.

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

I don't understand why this necessitates changing the directory. Surely it should just be created.

Also, I think pygrub is a piece of Xen and we should be using /var/run/xen (not xend as xend is obsolete).

Ian.

#5 lore raw
Quoted 5 lines · Ian Jackson

Olaf Hering writes ("[PATCH] tools/pygrub: store kernels in /var/run/pygrub"):

Quoted 4 lines

Move location of temporary bootfiles from /var/run/xend/boot to /var/run/pygrub. If the directory does not exist create it, unless --output-directory=<dir> was specified.

Quoted 8 lines
Quoted 2 lines

The reason for this change is that all entrys below /var/run have to be created at runtime in case /var/run is cleared on every boot.

I don't understand why this necessitates changing the directory. Surely it should just be created.

Also, I think pygrub is a piece of Xen and we should be using /var/run/xen (not xend as xend is obsolete).

Yes.

FWIW libxl (the only remaining automated caller of this code) always passes --output-directory= ${XEN_RUN_DIR:-/var/run/xen}/bootloader.$domid/dir

Ian.

#6 lore raw
In reply to Ian Jackson
Quoted 2 lines · Ian Jackson

Also, I think pygrub is a piece of Xen and we should be using /var/run/xen (not xend as xend is obsolete).

So I will adjust this patch to use /var/run/xen/pygrub/. Or should pygrub put its files right into "/var/run/xen/"?

Olaf

#7 lore raw

Olaf Hering writes ("Re: [PATCH] tools/pygrub: store kernels in /var/run/pygrub"):

Quoted 6 lines · Ian Jackson
Quoted 3 lines

Also, I think pygrub is a piece of Xen and we should be using /var/run/xen (not xend as xend is obsolete).

So I will adjust this patch to use /var/run/xen/pygrub/.

I think that is good.

Quoted 1 line

Or should pygrub put its files right into "/var/run/xen/"?

The subdir is probably useful.

Thanks,
Ian.