Revision 58d38b02

b/lib/backend.py
1155 1155
  hyper = hypervisor.GetHypervisor(instance.hypervisor)
1156 1156

  
1157 1157
  try:
1158
    hyper.MigrateInstance(instance.name, target, live)
1158
    hyper.MigrateInstance(instance, target, live)
1159 1159
  except errors.HypervisorError, err:
1160 1160
    _Fail("Failed to migrate instance: %s", err, exc=True)
1161 1161

  
b/lib/hypervisor/hv_base.py
232 232
    """
233 233
    pass
234 234

  
235
  def MigrateInstance(self, name, target, live):
235
  def MigrateInstance(self, instance, target, live):
236 236
    """Migrate an instance.
237 237

  
238
    @type name: string
239
    @param name: name of the instance to be migrated
238
    @type instance: L{object.Instance}
239
    @param name: the instance to be migrated
240 240
    @type target: string
241 241
    @param target: hostname (usually ip) of the target node
242 242
    @type live: boolean
b/lib/hypervisor/hv_kvm.py
608 608
    else:
609 609
      self.StopInstance(instance, force=True)
610 610

  
611
  def MigrateInstance(self, instance_name, target, live):
611
  def MigrateInstance(self, instance, target, live):
612 612
    """Migrate an instance to a target node.
613 613

  
614 614
    The migration will not be attempted if the instance is not
615 615
    currently running.
616 616

  
617
    @type instance_name: string
618
    @param instance_name: name of the instance to be migrated
617
    @type instance: L{objects.Instance}
618
    @param instance: the instance to be migrated
619 619
    @type target: string
620 620
    @param target: ip address of the target node
621 621
    @type live: boolean
622 622
    @param live: perform a live migration
623 623

  
624 624
    """
625
    instance_name = instance.name
625 626
    pidfile, pid, alive = self._InstancePidAlive(instance_name)
626 627
    if not alive:
627 628
      raise errors.HypervisorError("Instance not running, cannot migrate")
b/lib/hypervisor/hv_xen.py
392 392
    The migration will not be attempted if the instance is not
393 393
    currently running.
394 394

  
395
    @type instance: string
396
    @param instance: instance name
395
    @type instance: L{objects.Instance}
396
    @param instance: the instance to be migrated
397 397
    @type target: string
398 398
    @param target: ip address of the target node
399 399
    @type live: boolean
400 400
    @param live: perform a live migration
401 401

  
402 402
    """
403
    if self.GetInstanceInfo(instance) is None:
403
    if self.GetInstanceInfo(instance.name) is None:
404 404
      raise errors.HypervisorError("Instance not running, cannot migrate")
405 405
    args = ["xm", "migrate"]
406 406
    if live:
407 407
      args.append("-l")
408
    args.extend([instance, target])
408
    args.extend([instance.name, target])
409 409
    result = utils.RunCmd(args)
410 410
    if result.failed:
411 411
      raise errors.HypervisorError("Failed to migrate instance %s: %s" %
412
                                   (instance, result.output))
412
                                   (instance.name, result.output))
413 413
    # remove old xen file after migration succeeded
414 414
    try:
415
      self._RemoveConfigFile(instance)
415
      self._RemoveConfigFile(instance.name)
416 416
    except EnvironmentError:
417 417
      logging.exception("Failure while removing instance config file")
418 418

  

Also available in: Unified diff