ia64/xen-unstable

changeset 9028:a861cbd578f2

Instead of using a static filename in the guest bootloader, use a random
filename so that multiple guests can start up simultaneously.

Signed-off-by: Jeremy Katz <katzj@redhat.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Feb 26 10:53:18 2006 +0100 (2006-02-26)
parents b567eb77399f
children c7550ed2ccbf
files tools/python/xen/xend/XendBootloader.py
line diff
     1.1 --- a/tools/python/xen/xend/XendBootloader.py	Sun Feb 26 10:50:15 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendBootloader.py	Sun Feb 26 10:53:18 2006 +0100
     1.3 @@ -1,7 +1,7 @@
     1.4  #
     1.5  # XendBootloader.py - Framework to run a boot loader for picking the kernel
     1.6  #
     1.7 -# Copyright 2005 Red Hat, Inc.
     1.8 +# Copyright 2005-2006 Red Hat, Inc.
     1.9  # Jeremy Katz <katzj@redhat.com>
    1.10  #
    1.11  # This software may be freely redistributed under the terms of the GNU
    1.12 @@ -13,13 +13,12 @@
    1.13  #
    1.14  
    1.15  import os, select, errno
    1.16 +import random
    1.17  import sxp
    1.18  
    1.19  from XendLogging import log
    1.20  from XendError import VmError
    1.21  
    1.22 -BL_FIFO = "/var/lib/xen/xenbl"
    1.23 -
    1.24  def bootloader(blexec, disk, quiet = 0, vcpus = None, entry = None):
    1.25      """Run the boot loader executable on the given disk and return a
    1.26      config image.
    1.27 @@ -38,14 +37,18 @@ def bootloader(blexec, disk, quiet = 0, 
    1.28          log.error(msg)
    1.29          raise VmError(msg)
    1.30  
    1.31 -    os.mkfifo(BL_FIFO, 0600)
    1.32 +    while True:
    1.33 +        fifo = "/var/lib/xen/xenbl.%s" %(random.randint(0, 32000),)
    1.34 +        if not os.path.exists(fifo):
    1.35 +            break
    1.36 +    os.mkfifo(fifo, 0600)
    1.37  
    1.38      child = os.fork()
    1.39      if (not child):
    1.40          args = [ blexec ]
    1.41          if quiet:
    1.42              args.append("-q")
    1.43 -        args.append("--output=%s" %(BL_FIFO,))
    1.44 +        args.append("--output=%s" %(fifo,))
    1.45          if entry is not None:
    1.46              args.append("--entry=%s" %(entry,))
    1.47          args.append(disk)
    1.48 @@ -59,7 +62,7 @@ def bootloader(blexec, disk, quiet = 0, 
    1.49  
    1.50      while 1:
    1.51          try:
    1.52 -            r = os.open(BL_FIFO, os.O_RDONLY)
    1.53 +            r = os.open(fifo, os.O_RDONLY)
    1.54          except OSError, e:
    1.55              if e.errno == errno.EINTR:
    1.56                  continue
    1.57 @@ -74,7 +77,7 @@ def bootloader(blexec, disk, quiet = 0, 
    1.58          
    1.59      os.waitpid(child, 0)
    1.60      os.close(r)
    1.61 -    os.unlink(BL_FIFO)
    1.62 +    os.unlink(fifo)
    1.63  
    1.64      if len(ret) == 0:
    1.65          msg = "Boot loader didn't return any data!"