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] move pygrub tmp files to /var/run/

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] move pygrub tmp files to /var/run/
From: John Levon <levon@xxxxxxxxxxxxxxxxx>
Date: Fri, 8 Dec 2006 19:58:42 +0000
Delivery-date: Fri, 08 Dec 2006 11:58:49 -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
User-agent: Mutt/1.5.9i
# HG changeset patch
# User john.levon@xxxxxxx
# Date 1165607792 28800
# Node ID 4485a53cd801f1982ababdd9a7119bdd8d0b4cce
# Parent  95c016afec4d72385b8627617ef81f697834c50d
pygrub tmp files should live in /var/run/ not /var/lib/, as they are indeed
runtime only.

Also fix a race condition in making the pygrub fifo.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/tools/pygrub/Makefile b/tools/pygrub/Makefile
--- a/tools/pygrub/Makefile
+++ b/tools/pygrub/Makefile
@@ -12,11 +12,11 @@ ifndef XEN_PYTHON_NATIVE_INSTALL
 ifndef XEN_PYTHON_NATIVE_INSTALL
 install: all
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--home="$(DESTDIR)/usr" --prefix=""
-       $(INSTALL_DIR) $(DESTDIR)/var/lib/xen
+       $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
 else
 install: all
        CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install 
--root="$(DESTDIR)"
-       $(INSTALL_DIR) $(DESTDIR)/var/lib/xen
+       $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
 endif
 
 .PHONY: clean
diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -514,14 +514,16 @@ if __name__ == "__main__":
     fs = fsimage.open(file, offset)
 
     kernel = fs.open_file(img.kernel[1],).read()
-    (tfd, fn) = tempfile.mkstemp(prefix="vmlinuz.", dir="/var/lib/xen")
+    (tfd, fn) = tempfile.mkstemp(prefix="boot_kernel.",
+        dir="/var/run/xend/boot")
     os.write(tfd, kernel)
     os.close(tfd)
     sxp = "linux (kernel %s)" %(fn,)
 
     if img.initrd:
         initrd = fs.open_file(img.initrd[1],).read()
-        (tfd, fn) = tempfile.mkstemp(prefix="initrd.", dir="/var/lib/xen")
+        (tfd, fn) = tempfile.mkstemp(prefix="boot_ramdisk.",
+            dir="/var/run/xend/boot")
         os.write(tfd, initrd)
         os.close(tfd)
         sxp += "(ramdisk %s)" %(fn,)
diff --git a/tools/python/xen/xend/XendBootloader.py 
b/tools/python/xen/xend/XendBootloader.py
--- a/tools/python/xen/xend/XendBootloader.py
+++ b/tools/python/xen/xend/XendBootloader.py
@@ -12,11 +12,12 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 
-import os, select, errno
+import os, select, errno, stat
 import random
 import shlex
 from xen.xend import sxp
 
+from xen.util import mkdir
 from XendLogging import log
 from XendError import VmError
 
@@ -37,11 +38,16 @@ def bootloader(blexec, disk, quiet = 0, 
         log.error(msg)
         raise VmError(msg)
 
+    mkdir.parents("/var/run/xend/boot/", stat.S_IRWXU)
+
     while True:
-        fifo = "/var/lib/xen/xenbl.%s" % random.randint(0, 32000)
-        if not os.path.exists(fifo):
-            break
-    os.mkfifo(fifo, 0600)
+        fifo = "/var/run/xend/boot/xenbl.%s" %(random.randint(0, 32000),)
+        try:
+            os.mkfifo(fifo, 0600)
+        except OSError, e:
+            if (e.errno != errno.EEXIST):
+                raise
+        break
 
     child = os.fork()
     if (not child):

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] move pygrub tmp files to /var/run/, John Levon <=