ia64/xen-unstable

changeset 10039:36e0159c001b

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>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 10 16:52:55 2006 +0100 (2006-05-10)
parents 60f7b567bb2b
children 91c77df11b43
files tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomain.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/DevController.py tools/python/xen/xend/server/tpmif.py
line diff
     1.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Wed May 10 16:47:00 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Wed May 10 16:52:55 2006 +0100
     1.3 @@ -54,7 +54,7 @@ def read_exact(fd, size, errmsg):
     1.4  
     1.5  
     1.6  
     1.7 -def save(fd, dominfo, live, dst):
     1.8 +def save(fd, dominfo, network, live, dst):
     1.9      write_exact(fd, SIGNATURE, "could not write guest state file: signature")
    1.10  
    1.11      config = sxp.to_string(dominfo.sxpr())
    1.12 @@ -66,7 +66,7 @@ def save(fd, dominfo, live, dst):
    1.13      dominfo.setName('migrating-' + domain_name)
    1.14  
    1.15      try:
    1.16 -        dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP1, domain_name)
    1.17 +        dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP1, domain_name)
    1.18  
    1.19          write_exact(fd, pack("!i", len(config)),
    1.20                      "could not write guest state file: config len")
    1.21 @@ -88,10 +88,10 @@ def save(fd, dominfo, live, dst):
    1.22                  log.debug("Suspending %d ...", dominfo.getDomid())
    1.23                  dominfo.shutdown('suspend')
    1.24                  dominfo.waitForShutdown()
    1.25 -                dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP2,
    1.26 +                dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP2,
    1.27                                         domain_name)
    1.28                  log.info("Domain %d suspended.", dominfo.getDomid())
    1.29 -                dominfo.migrateDevices(live, dst, DEV_MIGRATE_STEP3,
    1.30 +                dominfo.migrateDevices(network, dst, DEV_MIGRATE_STEP3,
    1.31                                         domain_name)
    1.32                  tochild.write("done\n")
    1.33                  tochild.flush()
     2.1 --- a/tools/python/xen/xend/XendDomain.py	Wed May 10 16:47:00 2006 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomain.py	Wed May 10 16:52:55 2006 +0100
     2.3 @@ -408,7 +408,7 @@ class XendDomain:
     2.4              raise XendError("Cannot migrate privileged domain %i" % domid)
     2.5  
     2.6          """ The following call may raise a XendError exception """
     2.7 -        dominfo.testMigrateDevices(live, dst)
     2.8 +        dominfo.testMigrateDevices(True, dst)
     2.9  
    2.10          if port == 0:
    2.11              port = xroot.get_xend_relocation_port()
    2.12 @@ -420,7 +420,7 @@ class XendDomain:
    2.13  
    2.14          sock.send("receive\n")
    2.15          sock.recv(80)
    2.16 -        XendCheckpoint.save(sock.fileno(), dominfo, live, dst)
    2.17 +        XendCheckpoint.save(sock.fileno(), dominfo, True, live, dst)
    2.18  
    2.19  
    2.20      def domain_save(self, domid, dst):
    2.21 @@ -440,7 +440,7 @@ class XendDomain:
    2.22              fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
    2.23              try:
    2.24                  # For now we don't support 'live checkpoint' 
    2.25 -                return XendCheckpoint.save(fd, dominfo, False, dst)
    2.26 +                return XendCheckpoint.save(fd, dominfo, False, False, dst)
    2.27              finally:
    2.28                  os.close(fd)
    2.29          except OSError, ex:
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed May 10 16:47:00 2006 +0100
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed May 10 16:52:55 2006 +0100
     3.3 @@ -1443,36 +1443,40 @@ class XendDomainInfo:
     3.4  
     3.5      ## public:
     3.6  
     3.7 -    def testMigrateDevices(self, live, dst):
     3.8 +    def testMigrateDevices(self, network, dst):
     3.9          """ Notify all device about intention of migration
    3.10          @raise: XendError for a device that cannot be migrated
    3.11          """
    3.12          for (n, c) in self.info['device']:
    3.13 -            rc = self.migrateDevice(n, c, live, dst, DEV_MIGRATE_TEST)
    3.14 +            rc = self.migrateDevice(n, c, network, dst, DEV_MIGRATE_TEST)
    3.15              if rc != 0:
    3.16                  raise XendError("Device of type '%s' refuses migration." % n)
    3.17  
    3.18 -    def migrateDevices(self, live, dst, step, domName=''):
    3.19 +    def migrateDevices(self, network, dst, step, domName=''):
    3.20          """Notify the devices about migration
    3.21          """
    3.22          ctr = 0
    3.23          try:
    3.24              for (n, c) in self.info['device']:
    3.25 -                self.migrateDevice(n, c, live, dst, step, domName)
    3.26 +                self.migrateDevice(n, c, network, dst, step, domName)
    3.27                  ctr = ctr + 1
    3.28          except:
    3.29              for (n, c) in self.info['device']:
    3.30                  if ctr == 0:
    3.31                      step = step - 1
    3.32                  ctr = ctr - 1
    3.33 -                self.recoverMigrateDevice(n, c, live, dst, step, domName)
    3.34 +                self.recoverMigrateDevice(n, c, network, dst, step, domName)
    3.35              raise
    3.36  
    3.37 -    def migrateDevice(self, deviceClass, deviceConfig, live, dst, step, domName=''):
    3.38 -        return self.getDeviceController(deviceClass).migrate(deviceConfig, live, dst, step, domName)
    3.39 +    def migrateDevice(self, deviceClass, deviceConfig, network, dst,
    3.40 +                      step, domName=''):
    3.41 +        return self.getDeviceController(deviceClass).migrate(deviceConfig,
    3.42 +                                        network, dst, step, domName)
    3.43  
    3.44 -    def recoverMigrateDevice(self, deviceClass, deviceConfig, live, dst, step, domName=''):
    3.45 -        return self.getDeviceController(deviceClass).recover_migrate(deviceConfig, live, dst, step, domName)
    3.46 +    def recoverMigrateDevice(self, deviceClass, deviceConfig, network,
    3.47 +                             dst, step, domName=''):
    3.48 +        return self.getDeviceController(deviceClass).recover_migrate(
    3.49 +                     deviceConfig, network, dst, step, domName)
    3.50  
    3.51      def waitForDevices(self):
    3.52          """Wait for this domain's configured devices to connect.
     4.1 --- a/tools/python/xen/xend/server/DevController.py	Wed May 10 16:47:00 2006 +0100
     4.2 +++ b/tools/python/xen/xend/server/DevController.py	Wed May 10 16:52:55 2006 +0100
     4.3 @@ -267,9 +267,9 @@ class DevController:
     4.4  
     4.5          raise NotImplementedError()
     4.6  
     4.7 -    def migrate(self, deviceConfig, live, dst, step, domName):
     4.8 -        """ Migration of a device. The 'live' parameter indicates
     4.9 -            whether the device is live-migrated (live=1). 'dst' then gives
    4.10 +    def migrate(self, deviceConfig, network, dst, step, domName):
    4.11 +        """ Migration of a device. The 'network' parameter indicates
    4.12 +            whether the device is network-migrated (True). 'dst' then gives
    4.13              the hostname of the machine to migrate to.
    4.14          This function is called for 4 steps:
    4.15          If step == 0: Check whether the device is ready to be migrated
    4.16 @@ -296,7 +296,7 @@ class DevController:
    4.17          return 0
    4.18  
    4.19  
    4.20 -    def recover_migrate(self, deviceConfig, list, dst, step, domName):
    4.21 +    def recover_migrate(self, deviceConfig, network, dst, step, domName):
    4.22          """ Recover from device migration. The given step was the
    4.23              last one that was successfully executed.
    4.24          """
     5.1 --- a/tools/python/xen/xend/server/tpmif.py	Wed May 10 16:47:00 2006 +0100
     5.2 +++ b/tools/python/xen/xend/server/tpmif.py	Wed May 10 16:52:55 2006 +0100
     5.3 @@ -71,12 +71,12 @@ class TPMifController(DevController):
     5.4  
     5.5          return result
     5.6  
     5.7 -    def migrate(self, deviceConfig, live, dst, step, domName):
     5.8 +    def migrate(self, deviceConfig, network, dst, step, domName):
     5.9          """@see DevContoller.migrate"""
    5.10 -        if live:
    5.11 +        if network:
    5.12              tool = xroot.get_external_migration_tool()
    5.13              if tool != '':
    5.14 -                log.info("Request to live-migrate device to %s. step=%d.",
    5.15 +                log.info("Request to network-migrate device to %s. step=%d.",
    5.16                           dst, step)
    5.17  
    5.18                  if step == DEV_MIGRATE_TEST:
    5.19 @@ -99,12 +99,12 @@ class TPMifController(DevController):
    5.20                  return -1
    5.21          return 0
    5.22  
    5.23 -    def recover_migrate(self, deviceConfig, live, dst, step, domName):
    5.24 +    def recover_migrate(self, deviceConfig, network, dst, step, domName):
    5.25          """@see DevContoller.recover_migrate"""
    5.26 -        if live:
    5.27 +        if network:
    5.28              tool = xroot.get_external_migration_tool()
    5.29              if tool != '':
    5.30 -                log.info("Request to recover live-migrated device. last good step=%d.",
    5.31 +                log.info("Request to recover network-migrated device. last good step=%d.",
    5.32                           step)
    5.33                  fd = os.popen("%s -type vtpm -step %d -host %s -domname %s -recover" %
    5.34                                (tool, step, dst, domName),