Revision b74de5e8 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1953 1953

  
1954 1954
    dev.pci = int(free)
1955 1955

  
1956
  def HotplugSupported(self, instance, action, dev_type):
1956
  def VerifyHotplugSupport(self, instance, action, dev_type):
1957 1957
    """Check if hotplug is supported.
1958 1958

  
1959 1959
    Hotplug is *not* supported in case of:
1960
     - qemu versions < 1.0
1961 1960
     - security models and chroot (disk hotplug)
1962 1961
     - fdsend module is missing (nic hot-add)
1963 1962

  
1964 1963
    @raise errors.HypervisorError: in previous cases
1965 1964

  
1966 1965
    """
1967
    output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
1968
    # TODO: search for netdev_add, drive_add, device_add.....
1969
    match = self._INFO_VERSION_RE.search(output.stdout)
1970
    if not match:
1971
      raise errors.HotplugError("Try hotplug only in running instances.")
1972
    v_major, v_min, _, _ = match.groups()
1973
    if (v_major, v_min) <= (1, 0):
1974
      raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
1975

  
1976 1966
    if dev_type == constants.HOTPLUG_TARGET_DISK:
1977 1967
      hvp = instance.hvparams
1978 1968
      security_model = hvp[constants.HV_SECURITY_MODEL]
......
1990 1980
                                " fdsend python module is missing.")
1991 1981
    return True
1992 1982

  
1983
  def HotplugSupported(self, instance):
1984
    """Checks if hotplug is generally supported.
1985

  
1986
    Hotplug is *not* supported in case of:
1987
     - qemu versions < 1.0
1988
     - for stopped instances
1989

  
1990
    @raise errors.HypervisorError: in one of the previous cases
1991

  
1992
    """
1993
    output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
1994
    # TODO: search for netdev_add, drive_add, device_add.....
1995
    match = self._INFO_VERSION_RE.search(output.stdout)
1996
    if not match:
1997
      raise errors.HotplugError("Try hotplug only in running instances.")
1998
    v_major, v_min, _, _ = match.groups()
1999
    if (int(v_major), int(v_min)) < (1, 0):
2000
      raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
2001

  
1993 2002
  def _CallHotplugCommand(self, name, cmd):
1994 2003
    output = self._CallMonitorCommand(name, cmd)
1995 2004
    # TODO: parse output and check if succeeded

Also available in: Unified diff