Revision b73f1c59 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1008 1008
        data.append(info)
1009 1009
    return data
1010 1010

  
1011
  def _GenerateKVMRuntime(self, instance, block_devices, startup_paused):
1011
  def _GenerateKVMRuntime(self, instance, block_devices, startup_paused,
1012
                          kvmhelp):
1012 1013
    """Generate KVM information to start an instance.
1013 1014

  
1015
    @type kvmhelp: string
1016
    @param kvmhelp: output of kvm --help
1014 1017
    @attention: this function must not have any side-effects; for
1015 1018
        example, it must not write to the filesystem, or read values
1016 1019
        from the current system the are expected to differ between
......
1021 1024
    """
1022 1025
    # pylint: disable=R0912,R0914,R0915
1023 1026
    hvp = instance.hvparams
1024
    kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
1025 1027

  
1026 1028
    pidfile = self._InstancePidFile(instance.name)
1027 1029
    kvm = constants.KVM_PATH
......
1429 1431
    if not self._InstancePidAlive(name)[2]:
1430 1432
      raise errors.HypervisorError("Failed to start instance %s" % name)
1431 1433

  
1432
  def _ExecuteKVMRuntime(self, instance, kvm_runtime, incoming=None):
1434
  def _ExecuteKVMRuntime(self, instance, kvm_runtime, kvmhelp, incoming=None):
1433 1435
    """Execute a KVM cmd, after completing it with some last minute data.
1434 1436

  
1435 1437
    @type incoming: tuple of strings
1436 1438
    @param incoming: (target_host_ip, port)
1439
    @type kvmhelp: string
1440
    @param kvmhelp: output of kvm --help
1437 1441

  
1438 1442
    """
1439 1443
    # Small _ExecuteKVMRuntime hv parameters programming howto:
......
1453 1457
    kvm_cmd, kvm_nics, up_hvp = kvm_runtime
1454 1458
    up_hvp = objects.FillDict(conf_hvp, up_hvp)
1455 1459

  
1456
    kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
1457 1460
    _, v_major, v_min, _ = self._ParseKVMVersion(kvmhelp)
1458 1461

  
1459 1462
    # We know it's safe to run as a different user upon migration, so we'll use
......
1635 1638

  
1636 1639
    """
1637 1640
    self._CheckDown(instance.name)
1641
    kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
1638 1642
    kvm_runtime = self._GenerateKVMRuntime(instance, block_devices,
1639
                                           startup_paused)
1643
                                           startup_paused, kvmhelp)
1640 1644
    self._SaveKVMRuntime(instance, kvm_runtime)
1641
    self._ExecuteKVMRuntime(instance, kvm_runtime)
1645
    self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp)
1642 1646

  
1643 1647
  def _CallMonitorCommand(self, instance_name, command):
1644 1648
    """Invoke a command on the instance monitor.
......
1764 1768
      self.StopInstance(instance, force=True)
1765 1769
    # ...and finally we can save it again, and execute it...
1766 1770
    self._SaveKVMRuntime(instance, kvm_runtime)
1767
    self._ExecuteKVMRuntime(instance, kvm_runtime)
1771
    kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
1772
    self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp)
1768 1773

  
1769 1774
  def MigrationInfo(self, instance):
1770 1775
    """Get instance information to perform a migration.
......
1790 1795
    """
1791 1796
    kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
1792 1797
    incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT])
1793
    self._ExecuteKVMRuntime(instance, kvm_runtime, incoming=incoming_address)
1798
    kvmhelp = self._GetKVMHelpOutput(constants.KVM_PATH)
1799
    self._ExecuteKVMRuntime(instance, kvm_runtime, kvmhelp,
1800
                            incoming=incoming_address)
1794 1801

  
1795 1802
  def FinalizeMigrationDst(self, instance, info, success):
1796 1803
    """Finalize the instance migration on the target node.

Also available in: Unified diff