Revision a4584abe

b/lib/hypervisor/hv_kvm.py
1792 1792
    except EnvironmentError, err:
1793 1793
      raise errors.HypervisorError("Failed to save KVM runtime file: %s" % err)
1794 1794

  
1795
  def _ReadKVMRuntime(self, instance_name):
1795
  @classmethod
1796
  def _ReadKVMRuntime(cls, instance_name):
1796 1797
    """Read an instance's KVM runtime
1797 1798

  
1798 1799
    """
1799 1800
    try:
1800
      file_content = utils.ReadFile(self._InstanceKVMRuntime(instance_name))
1801
      file_content = utils.ReadFile(cls._InstanceKVMRuntime(instance_name))
1801 1802
    except EnvironmentError, err:
1802 1803
      raise errors.HypervisorError("Failed to load KVM runtime file: %s" % err)
1803 1804
    return file_content
......
1816 1817

  
1817 1818
    self._WriteKVMRuntime(instance.name, serialized_form)
1818 1819

  
1819
  def _LoadKVMRuntime(self, instance, serialized_runtime=None):
1820
  @classmethod
1821
  def _LoadKVMRuntime(cls, instance_name, serialized_runtime=None):
1820 1822
    """Load an instance's KVM runtime
1821 1823

  
1822 1824
    """
1823 1825
    if not serialized_runtime:
1824
      serialized_runtime = self._ReadKVMRuntime(instance.name)
1826
      serialized_runtime = cls._ReadKVMRuntime(instance_name)
1825 1827

  
1826 1828
    return _AnalyzeSerializedRuntime(serialized_runtime)
1827 1829

  
......
2224 2226
    if device.pci is None:
2225 2227
      self._GetFreePCISlot(instance, device)
2226 2228
    kvm_devid = _GenerateDeviceKVMId(dev_type, device)
2227
    runtime = self._LoadKVMRuntime(instance)
2229
    runtime = self._LoadKVMRuntime(instance.name)
2228 2230
    if dev_type == constants.HOTPLUG_TARGET_DISK:
2229 2231
      cmds = ["drive_add dummy file=%s,if=none,id=%s,format=raw" %
2230 2232
                (extra, kvm_devid)]
......
2255 2257
    invokes the device specific method.
2256 2258

  
2257 2259
    """
2258
    runtime = self._LoadKVMRuntime(instance)
2260
    runtime = self._LoadKVMRuntime(instance.name)
2259 2261
    entry = _GetExistingDeviceInfo(dev_type, device, runtime)
2260 2262
    kvm_device = _RUNTIME_DEVICE[dev_type](entry)
2261 2263
    kvm_devid = _GenerateDeviceKVMId(dev_type, kvm_device)
......
2413 2415
                                   " not running" % instance.name)
2414 2416
    # StopInstance will delete the saved KVM runtime so:
2415 2417
    # ...first load it...
2416
    kvm_runtime = self._LoadKVMRuntime(instance)
2418
    kvm_runtime = self._LoadKVMRuntime(instance.name)
2417 2419
    # ...now we can safely call StopInstance...
2418 2420
    if not self.StopInstance(instance):
2419 2421
      self.StopInstance(instance, force=True)
......
2445 2447
    @param target: target host (usually ip), on this node
2446 2448

  
2447 2449
    """
2448
    kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2450
    kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2449 2451
    incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT])
2450 2452
    kvmpath = instance.hvparams[constants.HV_KVM_PATH]
2451 2453
    kvmhelp = self._GetKVMOutput(kvmpath, self._KVMOPT_HELP)
......
2462 2464

  
2463 2465
    """
2464 2466
    if success:
2465
      kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2467
      kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2466 2468
      kvm_nics = kvm_runtime[1]
2467 2469

  
2468 2470
      for nic_seq, nic in enumerate(kvm_nics):

Also available in: Unified diff