mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
This patch adds a boolean parameter 'network' to the save method of the
XendCheckpoint class to differentiate between network suspend/resume (network=True) and local suspend/resume (network=False). Instead of passing the 'live' parameter to the migration methods, this 'network' parameter is passed now. This ends up being merely a renaming of the parameter. A check with the xm-test suite against this change has resulted in no additional errors. Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
This commit is contained in:
1 parent
9f124d8334
commit
b75af341bd
5 files changed
+30
-26
No files matched your search
@@ -54,7 +54,7 @@ def read_exact(fd, size, errmsg):
|
||||
|
||||
|
||||
|
||||
def save(fd, dominfo, live, dst):
|
||||
def save(fd, dominfo, network, live, dst):
|
||||
write_exact(fd, SIGNATURE, "could not write guest state file: signature")
|
||||
|
||||
config = sxp.to_string(dominfo.sxpr())
|
||||
@@ -66,7 +66,7 @@ def save(fd, dominfo, live, dst):
|
||||
dominfo.setName('migrating-' + domain_name)
|
||||
|
||||
try:
|
||||
dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP1, domain_name)
|
||||
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP1, domain_name)
|
||||
|
||||
write_exact(fd, pack("!i", len(config)),
|
||||
"could not write guest state file: config len")
|
||||
@@ -88,10 +88,10 @@ def save(fd, dominfo, live, dst):
|
||||
log.debug("Suspending %d ...", dominfo.getDomid())
|
||||
dominfo.shutdown('suspend')
|
||||
dominfo.waitForShutdown()
|
||||
dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP2,
|
||||
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
|
||||
domain_name)
|
||||
log.info("Domain %d suspended.", dominfo.getDomid())
|
||||
dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP3,
|
||||
dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP3,
|
||||
domain_name)
|
||||
tochild.write("done\n")
|
||||
tochild.flush()
|
||||
|
||||
@@ -408,7 +408,7 @@ class XendDomain:
|
||||
raise XendError("Cannot migrate privileged domain %i" % domid)
|
||||
|
||||
""" The following call may raise a XendError exception """
|
||||
dominfo.testMigrateDevices(live, dst)
|
||||
dominfo.testMigrateDevices(True, dst)
|
||||
|
||||
if port == 0:
|
||||
port = xroot.get_xend_relocation_port()
|
||||
@@ -420,7 +420,7 @@ class XendDomain:
|
||||
|
||||
sock.send("receive\n")
|
||||
sock.recv(80)
|
||||
XendCheckpoint.save(sock.fileno(), dominfo, live, dst)
|
||||
XendCheckpoint.save(sock.fileno(), dominfo, True, live, dst)
|
||||
|
||||
|
||||
def domain_save(self, domid, dst):
|
||||
@@ -440,7 +440,7 @@ class XendDomain:
|
||||
fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
|
||||
try:
|
||||
# For now we don't support 'live checkpoint'
|
||||
return XendCheckpoint.save(fd, dominfo, False, dst)
|
||||
return XendCheckpoint.save(fd, dominfo, False, False, dst)
|
||||
finally:
|
||||
os.close(fd)
|
||||
except OSError, ex:
|
||||
|
||||
@@ -1443,36 +1443,40 @@ class XendDomainInfo:
|
||||
|
||||
## public:
|
||||
|
||||
def testMigrateDevices(self, live, dst):
|
||||
def testMigrateDevices(self, network, dst):
|
||||
""" Notify all device about intention of migration
|
||||
@raise: XendError for a device that cannot be migrated
|
||||
"""
|
||||
for (n, c) in self.info['device']:
|
||||
rc = self.migrateDevice(n, c, live, dst, DEV_MIGRATE_TEST)
|
||||
rc = self.migrateDevice(n, c, network, dst, DEV_MIGRATE_TEST)
|
||||
if rc != 0:
|
||||
raise XendError("Device of type '%s' refuses migration." % n)
|
||||
|
||||
def migrateDevices(self, live, dst, step, domName=''):
|
||||
def migrateDevices(self, network, dst, step, domName=''):
|
||||
"""Notify the devices about migration
|
||||
"""
|
||||
ctr = 0
|
||||
try:
|
||||
for (n, c) in self.info['device']:
|
||||
self.migrateDevice(n, c, live, dst, step, domName)
|
||||
self.migrateDevice(n, c, network, dst, step, domName)
|
||||
ctr = ctr + 1
|
||||
except:
|
||||
for (n, c) in self.info['device']:
|
||||
if ctr == 0:
|
||||
step = step - 1
|
||||
ctr = ctr - 1
|
||||
self.recoverMigrateDevice(n, c, live, dst, step, domName)
|
||||
self.recoverMigrateDevice(n, c, network, dst, step, domName)
|
||||
raise
|
||||
|
||||
def migrateDevice(self, deviceClass, deviceConfig, live, dst, step, domName=''):
|
||||
return self.getDeviceController(deviceClass).migrate(deviceConfig, live, dst, step, domName)
|
||||
def migrateDevice(self, deviceClass, deviceConfig, network, dst,
|
||||
step, domName=''):
|
||||
return self.getDeviceController(deviceClass).migrate(deviceConfig,
|
||||
network, dst, step, domName)
|
||||
|
||||
def recoverMigrateDevice(self, deviceClass, deviceConfig, live, dst, step, domName=''):
|
||||
return self.getDeviceController(deviceClass).recover_migrate(deviceConfig, live, dst, step, domName)
|
||||
def recoverMigrateDevice(self, deviceClass, deviceConfig, network,
|
||||
dst, step, domName=''):
|
||||
return self.getDeviceController(deviceClass).recover_migrate(
|
||||
deviceConfig, network, dst, step, domName)
|
||||
|
||||
def waitForDevices(self):
|
||||
"""Wait for this domain's configured devices to connect.
|
||||
|
||||
@@ -267,9 +267,9 @@ class DevController:
|
||||
|
||||
raise NotImplementedError()
|
||||
|
||||
def migrate(self, deviceConfig, live, dst, step, domName):
|
||||
""" Migration of a device. The 'live' parameter indicates
|
||||
whether the device is live-migrated (live=1). 'dst' then gives
|
||||
def migrate(self, deviceConfig, network, dst, step, domName):
|
||||
""" Migration of a device. The 'network' parameter indicates
|
||||
whether the device is network-migrated (True). 'dst' then gives
|
||||
the hostname of the machine to migrate to.
|
||||
This function is called for 4 steps:
|
||||
If step == 0: Check whether the device is ready to be migrated
|
||||
@@ -296,7 +296,7 @@ class DevController:
|
||||
return 0
|
||||
|
||||
|
||||
def recover_migrate(self, deviceConfig, list, dst, step, domName):
|
||||
def recover_migrate(self, deviceConfig, network, dst, step, domName):
|
||||
""" Recover from device migration. The given step was the
|
||||
last one that was successfully executed.
|
||||
"""
|
||||
|
||||
@@ -71,12 +71,12 @@ class TPMifController(DevController):
|
||||
|
||||
return result
|
||||
|
||||
def migrate(self, deviceConfig, live, dst, step, domName):
|
||||
def migrate(self, deviceConfig, network, dst, step, domName):
|
||||
"""@see DevContoller.migrate"""
|
||||
if live:
|
||||
if network:
|
||||
tool = xroot.get_external_migration_tool()
|
||||
if tool != '':
|
||||
log.info("Request to live-migrate device to %s. step=%d.",
|
||||
log.info("Request to network-migrate device to %s. step=%d.",
|
||||
dst, step)
|
||||
|
||||
if step == DEV_MIGRATE_TEST:
|
||||
@@ -99,12 +99,12 @@ class TPMifController(DevController):
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def recover_migrate(self, deviceConfig, live, dst, step, domName):
|
||||
def recover_migrate(self, deviceConfig, network, dst, step, domName):
|
||||
"""@see DevContoller.recover_migrate"""
|
||||
if live:
|
||||
if network:
|
||||
tool = xroot.get_external_migration_tool()
|
||||
if tool != '':
|
||||
log.info("Request to recover live-migrated device. last good step=%d.",
|
||||
log.info("Request to recover network-migrated device. last good step=%d.",
|
||||
step)
|
||||
fd = os.popen("%s -type vtpm -step %d -host %s -domname %s -recover" %
|
||||
(tool, step, dst, domName),
|
||||
|
||||