Revision b08cd7bf lib/hypervisor/hv_kvm.py

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

  
1740
  def _ReadKVMRuntime(self, instance_name):
1740
  @classmethod
1741
  def _ReadKVMRuntime(cls, instance_name):
1741 1742
    """Read an instance's KVM runtime
1742 1743

  
1743 1744
    """
1744 1745
    try:
1745
      file_content = utils.ReadFile(self._InstanceKVMRuntime(instance_name))
1746
      file_content = utils.ReadFile(cls._InstanceKVMRuntime(instance_name))
1746 1747
    except EnvironmentError, err:
1747 1748
      raise errors.HypervisorError("Failed to load KVM runtime file: %s" % err)
1748 1749
    return file_content
......
1761 1762

  
1762 1763
    self._WriteKVMRuntime(instance.name, serialized_form)
1763 1764

  
1764
  def _LoadKVMRuntime(self, instance, serialized_runtime=None):
1765
  @classmethod
1766
  def _LoadKVMRuntime(cls, instance_name, serialized_runtime=None):
1765 1767
    """Load an instance's KVM runtime
1766 1768

  
1767 1769
    """
1768 1770
    if not serialized_runtime:
1769
      serialized_runtime = self._ReadKVMRuntime(instance.name)
1771
      serialized_runtime = cls._ReadKVMRuntime(instance_name)
1770 1772

  
1771 1773
    return _AnalyzeSerializedRuntime(serialized_runtime)
1772 1774

  
......
2172 2174
    if device.pci is None:
2173 2175
      self._GetFreePCISlot(instance, device)
2174 2176
    kvm_devid = _GenerateDeviceKVMId(dev_type, device)
2175
    runtime = self._LoadKVMRuntime(instance)
2177
    runtime = self._LoadKVMRuntime(instance.name)
2176 2178
    if dev_type == constants.HOTPLUG_TARGET_DISK:
2177 2179
      cmds = ["drive_add dummy file=%s,if=none,id=%s,format=raw" %
2178 2180
                (extra, kvm_devid)]
......
2203 2205
    invokes the device specific method.
2204 2206

  
2205 2207
    """
2206
    runtime = self._LoadKVMRuntime(instance)
2208
    runtime = self._LoadKVMRuntime(instance.name)
2207 2209
    entry = _GetExistingDeviceInfo(dev_type, device, runtime)
2208 2210
    kvm_device = _RUNTIME_DEVICE[dev_type](entry)
2209 2211
    kvm_devid = _GenerateDeviceKVMId(dev_type, kvm_device)
......
2362 2364
                                   " not running" % instance.name)
2363 2365
    # StopInstance will delete the saved KVM runtime so:
2364 2366
    # ...first load it...
2365
    kvm_runtime = self._LoadKVMRuntime(instance)
2367
    kvm_runtime = self._LoadKVMRuntime(instance.name)
2366 2368
    # ...now we can safely call StopInstance...
2367 2369
    if not self.StopInstance(instance):
2368 2370
      self.StopInstance(instance, force=True)
......
2394 2396
    @param target: target host (usually ip), on this node
2395 2397

  
2396 2398
    """
2397
    kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2399
    kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2398 2400
    incoming_address = (target, instance.hvparams[constants.HV_MIGRATION_PORT])
2399 2401
    kvmpath = instance.hvparams[constants.HV_KVM_PATH]
2400 2402
    kvmhelp = self._GetKVMOutput(kvmpath, self._KVMOPT_HELP)
......
2411 2413

  
2412 2414
    """
2413 2415
    if success:
2414
      kvm_runtime = self._LoadKVMRuntime(instance, serialized_runtime=info)
2416
      kvm_runtime = self._LoadKVMRuntime(instance.name, serialized_runtime=info)
2415 2417
      kvm_nics = kvm_runtime[1]
2416 2418

  
2417 2419
      for nic_seq, nic in enumerate(kvm_nics):

Also available in: Unified diff