Add -p/--paused flag to xm restore
PATCH 1/1 Add -p/--paused flag to xm restore
This flag lets you restore a domain without unpausing it. It's been handy while playing around with the restore code.
# HG changeset patch
# User Brendan Cully <[email protected]>
# Date 1164161363 28800
# Node ID d77591fd85fd02ff0c1f6bc0b370fac64ca54700 # Parent 2274ce00504551f779757b24e2fa711a33c6e263 Add -p/--paused flag to xm restore.
When --paused is specified, the domain is paused after it is loaded.
tools/python/xen/xend/XendCheckpoint.py +3 -2
@@ -109,7 +109,7 @@ def save(fd, dominfo, network, live, dst raise Exception, exn -def restore(xd, fd, dominfo = None): +def restore(xd, fd, dominfo = None, paused = False): signature = read_exact(fd, len(SIGNATURE), "not a valid guest state file: signature read") if signature != SIGNATURE:
@@ -165,7 +165,8 @@ def restore(xd, fd, dominfo = None): os.read(fd, 1) # Wait for source to close connection dominfo.waitForDevices() # Wait for backends to set up - dominfo.unpause() + if not paused: + dominfo.unpause() dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
tools/python/xen/xend/XendDomain.py +4 -4
@@ -915,7 +915,7 @@ class XendDomain: # !!! raise XendError("Unsupported") - def domain_restore(self, src): + def domain_restore(self, src, paused=False): """Restore a domain from file. @param src: filename of checkpoint file to restore from
@@ -927,14 +927,14 @@ class XendDomain: try: fd = os.open(src, os.O_RDONLY) try: - return self.domain_restore_fd(fd) + return self.domain_restore_fd(fd, paused=paused) finally: os.close(fd) except OSError, ex: raise XendError("can't read guest state file %s: %s" % (src, ex[1])) - def domain_restore_fd(self, fd): + def domain_restore_fd(self, fd, paused=False): """Restore a domain from the given file descriptor. @param fd: file descriptor of the checkpoint file
@@ -944,7 +944,7 @@ class XendDomain: """ try: - return XendCheckpoint.restore(self, fd) + return XendCheckpoint.restore(self, fd, paused=paused) except: # I don't really want to log this exception here, but the error # handling in the relocation-socket handling code (relocate.py) is
tools/python/xen/xend/server/XMLRPCServer.py +2 -2
@@ -64,8 +64,8 @@ def domain_create(config): info = XendDomain.instance().domain_create(config) return fixup_sxpr(info.sxpr()) -def domain_restore(src): - info = XendDomain.instance().domain_restore(src) +def domain_restore(src, paused=False): + info = XendDomain.instance().domain_restore(src, paused) return fixup_sxpr(info.sxpr()) def get_log():
tools/python/xen/xm/main.py +24 -5
@@ -84,7 +84,7 @@ SUBCOMMAND_HELP = { 'Migrate a domain to another machine.'), 'pause' : ('<Domain>', 'Pause execution of a domain.'), 'reboot' : ('<Domain> [-wa]', 'Reboot a domain.'), - 'restore' : ('<CheckpointFile>', + 'restore' : ('<CheckpointFile> [-p]', 'Restore a domain from a saved state.'), 'save' : ('<Domain> <CheckpointFile>', 'Save a domain state to restore later.'),
@@ -203,6 +203,9 @@ SUBCOMMAND_OPTIONS = { ('-L', '--live', 'Dump core without pausing the domain'), ('-C', '--crash', 'Crash domain after dumping core'), ), + 'restore': ( + ('-p', '--paused', 'Do not unpause domain after restoring it'), + ), } common_commands = [
@@ -480,15 +483,31 @@ def xm_save(args): server.xend.domain.save(domid, savefile) def xm_restore(args): - arg_check(args, "restore", 1) - - savefile = os.path.abspath(args[0]) + arg_check(args, "restore", 1, 2) + + try: + (options, params) = getopt.gnu_getopt(args, 'p', ['paused']) + except getopt.GetoptError, opterr: + err(opterr) + sys.exit(1) + + paused = False + for (k, v) in options: + if k in ['-p', '--paused']: + paused = True + + if len(params) != 1: + err("Wrong number of parameters") + usage('restore') + sys.exit(1) + + savefile = os.path.abspath(params[0]) if not os.access(savefile, os.R_OK): err("xm restore: Unable to read file %s" % savefile) sys.exit(1) - server.xend.domain.restore(savefile) + server.xend.domain.restore(savefile, paused) def getDomains(domain_names, full = 0):
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Ewan Mellor
AppliedQuoted 10 lines · Brendan Cully
This flag lets you restore a domain without unpausing it. It's been handy while playing around with the restore code.
# HG changeset patch
# User Brendan Cully <[email protected]>
# Date 1164161363 28800
# Node IDd77591fd85fd02ff0c1f6bc0b370fac64ca54700# Parent2274ce00504551f779757b24e2fa711a33c6e263Add -p/--paused flag to xm restore.
Quoted 3 lines
When --paused is specified, the domain is paused after it is loaded.
Signed-off-by Brendan Cully <[email protected]>
Applied, thanks.
Ewan.