Revision 8351df2f

b/lib/hypervisor/hv_xen.py
721 721
    cluster_name = ssconf.SimpleStore().GetClusterName()
722 722

  
723 723
    return self._MigrateInstance(cluster_name, instance.name, target, port,
724
                                 live)
724
                                 live, instance.hvparams)
725 725

  
726 726
  def _MigrateInstance(self, cluster_name, instance_name, target, port, live,
727
                       _ping_fn=netutils.TcpPing):
727
                       hvparams, _ping_fn=netutils.TcpPing):
728 728
    """Migrate an instance to a target node.
729 729

  
730 730
    @see: L{MigrateInstance} for details
731 731

  
732 732
    """
733
    if self.GetInstanceInfo(instance_name) is None:
733
    if hvparams is None:
734
      raise errors.HypervisorError("No hvparams provided.")
735

  
736
    if self.GetInstanceInfo(instance_name, hvparams=hvparams) is None:
734 737
      raise errors.HypervisorError("Instance not running, cannot migrate")
735 738

  
736
    cmd = self._GetCommand()
739
    cmd = self._GetCommand(hvparams=hvparams)
737 740

  
738 741
    if (cmd == constants.XEN_CMD_XM and
739 742
        not _ping_fn(target, port, live_port_needed=True)):
b/test/py/ganeti.hypervisor.hv_xen_unittest.py
524 524
  TARGET = NotImplemented
525 525
  CMD = NotImplemented
526 526
  HVNAME = NotImplemented
527
  VALID_HVPARAMS = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
527 528

  
528 529
  def setUp(self):
529 530
    super(_TestXenHypervisor, self).setUp()
......
791 792
    for live in [False, True]:
792 793
      try:
793 794
        hv._MigrateInstance(NotImplemented, name, target, port, live,
794
                            _ping_fn=NotImplemented)
795
                            self.VALID_HVPARAMS, _ping_fn=NotImplemented)
795 796
      except errors.HypervisorError, err:
796 797
        self.assertEqual(str(err), "Instance not running, cannot migrate")
797 798
      else:
......
811 812
    port = 28349
812 813

  
813 814
    hv = self._GetHv(run_cmd=self._MigrateInstTargetUnreachCmd)
815
    hvparams = {constants.HV_XEN_CMD: self.CMD}
814 816

  
815 817
    for live in [False, True]:
816 818
      if self.CMD == constants.XEN_CMD_XL:
......
819 821
      else:
820 822
        try:
821 823
          hv._MigrateInstance(NotImplemented, name, target, port, live,
824
                              hvparams,
822 825
                              _ping_fn=compat.partial(self._FakeTcpPing,
823 826
                                                      (target, port), False))
824 827
        except errors.HypervisorError, err:
......
865 868
    target = constants.IP4_ADDRESS_LOCALHOST
866 869
    port = 22364
867 870

  
871
    hvparams = {constants.HV_XEN_CMD: self.CMD}
872

  
868 873
    for live in [False, True]:
869 874
      for fail in [False, True]:
870 875
        ping_fn = \
......
881 886
        if fail:
882 887
          try:
883 888
            hv._MigrateInstance(clustername, instname, target, port, live,
884
                                _ping_fn=ping_fn)
889
                                hvparams, _ping_fn=ping_fn)
885 890
          except errors.HypervisorError, err:
886 891
            self.assertTrue(str(err).startswith("Failed to migrate instance"))
887 892
          else:
888 893
            self.fail("Exception was not raised")
889 894
        else:
890 895
          hv._MigrateInstance(clustername, instname, target, port, live,
891
                              _ping_fn=ping_fn)
896
                              hvparams, _ping_fn=ping_fn)
892 897

  
893 898
        if self.CMD == constants.XEN_CMD_XM:
894 899
          expected_pings = 1

Also available in: Unified diff