direct-io.hg

changeset 12521:a8d2b1393b76

Add -p/--paused flag to xm restore.

When --paused is specified, the domain is paused after it is loaded.

Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author Brendan Cully <brendan@cs.ubc.ca>
date Tue Nov 21 18:09:23 2006 -0800 (2006-11-21)
parents cbbfadf7c8a5
children b8cc9ffda0a3 6f0d8434d23f
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/server/XMLRPCServer.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Fri Nov 17 16:21:14 2006 -0700
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Tue Nov 21 18:09:23 2006 -0800
     1.3 @@ -108,7 +108,7 @@ def save(fd, dominfo, network, live, dst
     1.4          raise Exception, exn
     1.5  
     1.6  
     1.7 -def restore(xd, fd, dominfo = None):
     1.8 +def restore(xd, fd, dominfo = None, paused = False):
     1.9      signature = read_exact(fd, len(SIGNATURE),
    1.10          "not a valid guest state file: signature read")
    1.11      if signature != SIGNATURE:
    1.12 @@ -164,7 +164,8 @@ def restore(xd, fd, dominfo = None):
    1.13  
    1.14          os.read(fd, 1)           # Wait for source to close connection
    1.15          dominfo.waitForDevices() # Wait for backends to set up
    1.16 -        dominfo.unpause()
    1.17 +        if not paused:
    1.18 +            dominfo.unpause()
    1.19          
    1.20          dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
    1.21          
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Fri Nov 17 16:21:14 2006 -0700
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Nov 21 18:09:23 2006 -0800
     2.3 @@ -916,7 +916,7 @@ class XendDomain:
     2.4          # !!!
     2.5          raise XendError("Unsupported")
     2.6  
     2.7 -    def domain_restore(self, src):
     2.8 +    def domain_restore(self, src, paused=False):
     2.9          """Restore a domain from file.
    2.10  
    2.11          @param src: filename of checkpoint file to restore from
    2.12 @@ -928,14 +928,14 @@ class XendDomain:
    2.13          try:
    2.14              fd = os.open(src, os.O_RDONLY)
    2.15              try:
    2.16 -                return self.domain_restore_fd(fd)
    2.17 +                return self.domain_restore_fd(fd, paused=paused)
    2.18              finally:
    2.19                  os.close(fd)
    2.20          except OSError, ex:
    2.21              raise XendError("can't read guest state file %s: %s" %
    2.22                              (src, ex[1]))
    2.23  
    2.24 -    def domain_restore_fd(self, fd):
    2.25 +    def domain_restore_fd(self, fd, paused=False):
    2.26          """Restore a domain from the given file descriptor.
    2.27  
    2.28          @param fd: file descriptor of the checkpoint file
    2.29 @@ -945,7 +945,7 @@ class XendDomain:
    2.30          """
    2.31  
    2.32          try:
    2.33 -            return XendCheckpoint.restore(self, fd)
    2.34 +            return XendCheckpoint.restore(self, fd, paused=paused)
    2.35          except:
    2.36              # I don't really want to log this exception here, but the error
    2.37              # handling in the relocation-socket handling code (relocate.py) is
     3.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Fri Nov 17 16:21:14 2006 -0700
     3.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Tue Nov 21 18:09:23 2006 -0800
     3.3 @@ -64,8 +64,8 @@ def domain_create(config):
     3.4      info = XendDomain.instance().domain_create(config)
     3.5      return fixup_sxpr(info.sxpr())
     3.6  
     3.7 -def domain_restore(src):
     3.8 -    info = XendDomain.instance().domain_restore(src)
     3.9 +def domain_restore(src, paused=False):
    3.10 +    info = XendDomain.instance().domain_restore(src, paused)
    3.11      return fixup_sxpr(info.sxpr())
    3.12  
    3.13  def get_log():
     4.1 --- a/tools/python/xen/xm/main.py	Fri Nov 17 16:21:14 2006 -0700
     4.2 +++ b/tools/python/xen/xm/main.py	Tue Nov 21 18:09:23 2006 -0800
     4.3 @@ -84,7 +84,7 @@ SUBCOMMAND_HELP = {
     4.4                       'Migrate a domain to another machine.'),
     4.5      'pause'       : ('<Domain>', 'Pause execution of a domain.'),
     4.6      'reboot'      : ('<Domain> [-wa]', 'Reboot a domain.'),
     4.7 -    'restore'     : ('<CheckpointFile>',
     4.8 +    'restore'     : ('<CheckpointFile> [-p]',
     4.9                       'Restore a domain from a saved state.'),
    4.10      'save'        : ('<Domain> <CheckpointFile>',
    4.11                       'Save a domain state to restore later.'),
    4.12 @@ -206,6 +206,9 @@ SUBCOMMAND_OPTIONS = {
    4.13         ('-L', '--live', 'Dump core without pausing the domain'),
    4.14         ('-C', '--crash', 'Crash domain after dumping core'),
    4.15      ),
    4.16 +    'restore': (
    4.17 +      ('-p', '--paused', 'Do not unpause domain after restoring it'),
    4.18 +    ),
    4.19  }
    4.20  
    4.21  common_commands = [
    4.22 @@ -483,15 +486,31 @@ def xm_save(args):
    4.23      server.xend.domain.save(domid, savefile)
    4.24      
    4.25  def xm_restore(args):
    4.26 -    arg_check(args, "restore", 1)
    4.27 +    arg_check(args, "restore", 1, 2)
    4.28  
    4.29 -    savefile = os.path.abspath(args[0])
    4.30 +    try:
    4.31 +        (options, params) = getopt.gnu_getopt(args, 'p', ['paused'])
    4.32 +    except getopt.GetoptError, opterr:
    4.33 +        err(opterr)
    4.34 +        sys.exit(1)
    4.35 +
    4.36 +    paused = False
    4.37 +    for (k, v) in options:
    4.38 +        if k in ['-p', '--paused']:
    4.39 +            paused = True
    4.40 +
    4.41 +    if len(params) != 1:
    4.42 +        err("Wrong number of parameters")
    4.43 +        usage('restore')
    4.44 +        sys.exit(1)
    4.45 +
    4.46 +    savefile = os.path.abspath(params[0])
    4.47  
    4.48      if not os.access(savefile, os.R_OK):
    4.49          err("xm restore: Unable to read file %s" % savefile)
    4.50          sys.exit(1)
    4.51  
    4.52 -    server.xend.domain.restore(savefile)
    4.53 +    server.xend.domain.restore(savefile, paused)
    4.54  
    4.55  
    4.56  def getDomains(domain_names, full = 0):