Revision 75b21ca0 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1977 1977
    """Verifies that hotplug is supported.
1978 1978

  
1979 1979
    Hotplug is *not* supported in case of:
1980
     - qemu versions < 1.0
1981 1980
     - security models and chroot (disk hotplug)
1982 1981
     - fdsend module is missing (nic hot-add)
1983 1982

  
1984 1983
    @raise errors.HypervisorError: in one of the previous cases
1985 1984

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

  
1996 1986
    if dev_type == constants.HOTPLUG_TARGET_DISK:
1997 1987
      hvp = instance.hvparams
1998 1988
      security_model = hvp[constants.HV_SECURITY_MODEL]
......
2009 1999
      raise errors.HotplugError("Cannot hot-add NIC."
2010 2000
                                " fdsend python module is missing.")
2011 2001

  
2002
  def HotplugSupported(self, instance):
2003
    """Checks if hotplug is generally supported.
2004

  
2005
    Hotplug is *not* supported in case of:
2006
     - qemu versions < 1.0
2007
     - for stopped instances
2008

  
2009
    @raise errors.HypervisorError: in one of the previous cases
2010

  
2011
    """
2012
    output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
2013
    # TODO: search for netdev_add, drive_add, device_add.....
2014
    match = self._INFO_VERSION_RE.search(output.stdout)
2015
    if not match:
2016
      raise errors.HotplugError("Try hotplug only in running instances.")
2017
    v_major, v_min, _, _ = match.groups()
2018
    if (int(v_major), int(v_min)) < (1, 0):
2019
      raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0")
2020

  
2012 2021
  def _CallHotplugCommand(self, name, cmd):
2013 2022
    output = self._CallMonitorCommand(name, cmd)
2014 2023
    # TODO: parse output and check if succeeded

Also available in: Unified diff