Revision ad00ee21 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1952 1952

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

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

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

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

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

  
1975 1965
    if dev_type == constants.HOTPLUG_TARGET_DISK:
1976 1966
      hvp = instance.hvparams
1977 1967
      security_model = hvp[constants.HV_SECURITY_MODEL]
......
1989 1979
                                " fdsend python module is missing.")
1990 1980
    return True
1991 1981

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

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

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

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

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

Also available in: Unified diff