Revision 20e62ad1

b/lib/hypervisor/hv_kvm.py
42 42
  import affinity   # pylint: disable=F0401
43 43
except ImportError:
44 44
  affinity = None
45
try:
46
  import fdsend   # pylint: disable=F0401
47
except ImportError:
48
  fdsend = None
45 49

  
46 50
from ganeti import utils
47 51
from ganeti import constants
......
1908 1912

  
1909 1913
    dev.pci = int(free)
1910 1914

  
1915
  def HotplugSupported(self, instance, action, dev_type):
1916
    """Check if hotplug is supported.
1917

  
1918
    Hotplug is *not* supported in case of:
1919
     - qemu versions < 1.0
1920
     - security models and chroot (disk hotplug)
1921
     - fdsend module is missing (nic hot-add)
1922

  
1923
    @raise errors.HypervisorError: in previous cases
1924

  
1925
    """
1926
    output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
1927
    # TODO: search for netdev_add, drive_add, device_add.....
1928
    match = self._INFO_VERSION_RE.search(output.stdout)
1929
    if not match:
1930
      raise errors.HotplugError("Try hotplug only in running instances.")
1931
    v_major, v_min, _, _ = match.groups()
1932
    if (v_major, v_min) <= (1, 0):
1933
      raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
1934

  
1935
    if dev_type == constants.HOTPLUG_TARGET_DISK:
1936
      hvp = instance.hvparams
1937
      security_model = hvp[constants.HV_SECURITY_MODEL]
1938
      use_chroot = hvp[constants.HV_KVM_USE_CHROOT]
1939
      if use_chroot:
1940
        raise errors.HotplugError("Disk hotplug is not supported"
1941
                                  " in case of chroot.")
1942
      if security_model != constants.HT_SM_NONE:
1943
        raise errors.HotplugError("Disk Hotplug is not supported in case"
1944
                                  " security models are used.")
1945

  
1946
    if (dev_type == constants.HOTPLUG_TARGET_NIC and
1947
        action == constants.HOTPLUG_ACTION_ADD and not fdsend):
1948
      raise errors.HotplugError("Cannot hot-add NIC."
1949
                                " fdsend python module is missing.")
1950
    return True
1951

  
1952
  def _CallHotplugCommand(self, name, cmd):
1953
    output = self._CallMonitorCommand(name, cmd)
1954
    # TODO: parse output and check if succeeded
1955
    for line in output.stdout.splitlines():
1956
      logging.info("%s", line)
1957

  
1911 1958
  @classmethod
1912 1959
  def _ParseKVMVersion(cls, text):
1913 1960
    """Parse the KVM version from the --help output.

Also available in: Unified diff