mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
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>
This commit is contained in:
1 parent
3206f975b8
commit
acc3cc66f7
4 files changed
+32
-12
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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)
|
||||
arg_check(args, "restore", 1, 2)
|
||||
|
||||
savefile = os.path.abspath(args[0])
|
||||
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):
|
||||
|
||||