Revision f4529722

b/lib/backend.py
1647 1647
  """
1648 1648
  hyper = hypervisor.GetHypervisor(instance.hypervisor)
1649 1649
  try:
1650
    hyper.HotplugSupported(instance, action, dev_type)
1651
  except (errors.HotplugError, errors.HypervisorError), err:
1650
    hyper.VerifyHotplugSupport(instance, action, dev_type)
1651
  except errors.HotplugError, err:
1652 1652
    _Fail("Hotplug is not supported: %s", err)
1653 1653

  
1654 1654
  if action == constants.HOTPLUG_ACTION_ADD:
b/lib/hypervisor/hv_base.py
539 539
    else:
540 540
      return None
541 541

  
542
  # pylint: disable=R0201,W0613
542 543
  def HotAddDevice(self, instance, dev_type, device, extra, seq):
543 544
    """Hot-add a device.
544 545

  
545 546
    """
546
    pass
547
    raise errors.HotplugError("Hotplug is not supported by this hypervisor")
547 548

  
549
  # pylint: disable=R0201,W0613
548 550
  def HotDelDevice(self, instance, dev_type, device, extra, seq):
549 551
    """Hot-del a device.
550 552

  
551 553
    """
552
    pass
554
    raise errors.HotplugError("Hotplug is not supported by this hypervisor")
553 555

  
556
  # pylint: disable=R0201,W0613
554 557
  def HotModDevice(self, instance, dev_type, device, extra, seq):
555 558
    """Hot-mod a device.
556 559

  
557 560
    """
558
    pass
561
    raise errors.HotplugError("Hotplug is not supported by this hypervisor")
562

  
563
  # pylint: disable=R0201,W0613
564
  def VerifyHotplugSupport(self, instance, action, dev_type):
565
    """Verifies that hotplug is supported.
559 566

  
560
  def HotplugSupported(self, instance, action, dev_type):
561
    """Whether hotplug is supported.
567
    Hotplug is not supported by default. If a hypervisor wants to support
568
    it it should override this method.
569

  
570
    @type instance: L{objects.Instance}
571
    @param instance: the instance object
572
    @type action: string
573
    @param action: one of the supported hotplug commands
574
    @type dev_type: string
575
    @param dev_type: one of the supported device types to hotplug
576
    @raise errors.HotplugError: if hotplugging is not supported
562 577

  
563
    Depends on instance's hvparam, the action. and the dev_type
564 578
    """
565
    raise NotImplementedError
579
    raise errors.HotplugError("Hotplug is not supported by this hypervisor")
b/lib/hypervisor/hv_chroot.py
321 321

  
322 322
    """
323 323
    raise HypervisorError("Migration not supported by the chroot hypervisor")
324

  
325
  def HotplugSupported(self, instance, action, dev_type):
326
    """Whether hotplug is supported.
327

  
328
    """
329
    raise HypervisorError("Hotplug not supported by the chroot hypervisor")
b/lib/hypervisor/hv_fake.py
341 341

  
342 342
    """
343 343
    return objects.MigrationStatus(status=constants.HV_MIGRATION_COMPLETED)
344

  
345
  def HotplugSupported(self, instance, action, dev_type):
346
    """Whether hotplug is supported.
347

  
348
    """
349
    raise errors.HypervisorError("Hotplug not supported by the fake hypervisor")
b/lib/hypervisor/hv_kvm.py
1966 1966

  
1967 1967
    dev.pci = int(free)
1968 1968

  
1969
  def HotplugSupported(self, instance, action, dev_type):
1970
    """Check if hotplug is supported.
1969
  def VerifyHotplugSupport(self, instance, action, dev_type):
1970
    """Verifies that hotplug is supported.
1971 1971

  
1972 1972
    Hotplug is *not* supported in case of:
1973 1973
     - qemu versions < 1.0
1974 1974
     - security models and chroot (disk hotplug)
1975 1975
     - fdsend module is missing (nic hot-add)
1976 1976

  
1977
    @raise errors.HypervisorError: in previous cases
1977
    @raise errors.HypervisorError: in one of the previous cases
1978 1978

  
1979 1979
    """
1980 1980
    output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD)
......
2001 2001
        action == constants.HOTPLUG_ACTION_ADD and not fdsend):
2002 2002
      raise errors.HotplugError("Cannot hot-add NIC."
2003 2003
                                " fdsend python module is missing.")
2004
    return True
2005 2004

  
2006 2005
  def _CallHotplugCommand(self, name, cmd):
2007 2006
    output = self._CallMonitorCommand(name, cmd)
b/lib/hypervisor/hv_lxc.py
470 470

  
471 471
    """
472 472
    raise HypervisorError("Migration is not supported by the LXC hypervisor")
473

  
474
  def HotplugSupported(self, instance, action, dev_type):
475
    """Whether hotplug is supported.
476

  
477
    """
478
    raise HypervisorError("Hotplug not supported by the LXC hypervisor")
b/lib/hypervisor/hv_xen.py
897 897
    finally:
898 898
      utils.RunCmd([constants.XEN_CMD, "debug", "R"])
899 899

  
900
  def HotplugSupported(self, instance, action, dev_type):
901
    """Whether hotplug is supported.
902

  
903
    """
904
    raise errors.HypervisorError("Hotplug not supported by the xen hypervisor")
905

  
906 900

  
907 901
class XenPvmHypervisor(XenHypervisor):
908 902
  """Xen PVM hypervisor interface"""

Also available in: Unified diff