# HG changeset patch
# User Brendan Cully <brendan@xxxxxxxxx>
# Node ID a8d2b1393b769048c7b62822e45bef27eef80fb6
# Parent cbbfadf7c8a50ee5099477d48d43cf251a48ce37
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@xxxxxxxxx>
---
tools/python/xen/xend/XendCheckpoint.py | 5 ++--
tools/python/xen/xend/XendDomain.py | 8 +++----
tools/python/xen/xend/server/XMLRPCServer.py | 4 +--
tools/python/xen/xm/main.py | 29 ++++++++++++++++++++++-----
4 files changed, 33 insertions(+), 13 deletions(-)
diff -r cbbfadf7c8a5 -r a8d2b1393b76 tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py Fri Nov 17 16:21:14 2006 -0700
+++ b/tools/python/xen/xend/XendCheckpoint.py Tue Nov 21 18:09:23 2006 -0800
@@ -108,7 +108,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:
@@ -164,7 +164,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)
diff -r cbbfadf7c8a5 -r a8d2b1393b76 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Fri Nov 17 16:21:14 2006 -0700
+++ b/tools/python/xen/xend/XendDomain.py Tue Nov 21 18:09:23 2006 -0800
@@ -916,7 +916,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
@@ -928,14 +928,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
@@ -945,7 +945,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
diff -r cbbfadf7c8a5 -r a8d2b1393b76
tools/python/xen/xend/server/XMLRPCServer.py
--- a/tools/python/xen/xend/server/XMLRPCServer.py Fri Nov 17 16:21:14
2006 -0700
+++ b/tools/python/xen/xend/server/XMLRPCServer.py Tue Nov 21 18:09:23
2006 -0800
@@ -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():
diff -r cbbfadf7c8a5 -r a8d2b1393b76 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Fri Nov 17 16:21:14 2006 -0700
+++ b/tools/python/xen/xm/main.py Tue Nov 21 18:09:23 2006 -0800
@@ -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.'),
@@ -206,6 +206,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 = [
@@ -483,15 +486,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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|