Revision 254d4709
b/lib/backend.py | ||
---|---|---|
1663 | 1663 |
return fn(instance, dev_type, device, extra, seq) |
1664 | 1664 |
|
1665 | 1665 |
|
1666 |
def HotplugSupported(instance): |
|
1667 |
"""Checks if hotplug is generally supported. |
|
1668 |
|
|
1669 |
""" |
|
1670 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1671 |
try: |
|
1672 |
hyper.HotplugSupported(instance) |
|
1673 |
except errors.HotplugError, err: |
|
1674 |
_Fail("Hotplug is not supported: %s", err) |
|
1675 |
|
|
1676 |
|
|
1666 | 1677 |
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor): |
1667 | 1678 |
"""Creates a block device for an instance. |
1668 | 1679 |
|
b/lib/cmdlib/instance.py | ||
---|---|---|
2754 | 2754 |
constants.DT_EXT), |
2755 | 2755 |
errors.ECODE_INVAL) |
2756 | 2756 |
|
2757 |
if self.op.hotplug: |
|
2758 |
result = self.rpc.call_hotplug_supported(self.instance.primary_node, |
|
2759 |
self.instance) |
|
2760 |
result.Raise("Hotplug is not supported.") |
|
2761 |
|
|
2757 | 2762 |
# OS change |
2758 | 2763 |
if self.op.os_name and not self.op.force: |
2759 | 2764 |
CheckNodeHasOS(self, instance.primary_node, self.op.os_name, |
b/lib/hypervisor/hv_base.py | ||
---|---|---|
564 | 564 |
def VerifyHotplugSupport(self, instance, action, dev_type): |
565 | 565 |
"""Verifies that hotplug is supported. |
566 | 566 |
|
567 |
Hotplug is not supported by default. If a hypervisor wants to support
|
|
568 |
it it should override this method.
|
|
567 |
Given the target device and hotplug action checks if hotplug is
|
|
568 |
actually supported.
|
|
569 | 569 |
|
570 | 570 |
@type instance: L{objects.Instance} |
571 | 571 |
@param instance: the instance object |
... | ... | |
576 | 576 |
@raise errors.HotplugError: if hotplugging is not supported |
577 | 577 |
|
578 | 578 |
""" |
579 |
raise errors.HotplugError("Hotplug is not supported.") |
|
580 |
|
|
581 |
def HotplugSupported(self, instance): |
|
582 |
"""Checks if hotplug is supported. |
|
583 |
|
|
584 |
By default is not. Currently only KVM hypervisor supports it. |
|
585 |
|
|
586 |
""" |
|
579 | 587 |
raise errors.HotplugError("Hotplug is not supported by this hypervisor") |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
1970 | 1970 |
"""Verifies that hotplug is supported. |
1971 | 1971 |
|
1972 | 1972 |
Hotplug is *not* supported in case of: |
1973 |
- qemu versions < 1.0 |
|
1974 | 1973 |
- security models and chroot (disk hotplug) |
1975 | 1974 |
- fdsend module is missing (nic hot-add) |
1976 | 1975 |
|
1977 | 1976 |
@raise errors.HypervisorError: in one of the previous cases |
1978 | 1977 |
|
1979 | 1978 |
""" |
1980 |
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD) |
|
1981 |
# TODO: search for netdev_add, drive_add, device_add..... |
|
1982 |
match = self._INFO_VERSION_RE.search(output.stdout) |
|
1983 |
if not match: |
|
1984 |
raise errors.HotplugError("Try hotplug only in running instances.") |
|
1985 |
v_major, v_min, _, _ = match.groups() |
|
1986 |
if (int(v_major), int(v_min)) < (1, 0): |
|
1987 |
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0") |
|
1988 |
|
|
1989 | 1979 |
if dev_type == constants.HOTPLUG_TARGET_DISK: |
1990 | 1980 |
hvp = instance.hvparams |
1991 | 1981 |
security_model = hvp[constants.HV_SECURITY_MODEL] |
... | ... | |
2002 | 1992 |
raise errors.HotplugError("Cannot hot-add NIC." |
2003 | 1993 |
" fdsend python module is missing.") |
2004 | 1994 |
|
1995 |
def HotplugSupported(self, instance): |
|
1996 |
"""Checks if hotplug is generally supported. |
|
1997 |
|
|
1998 |
Hotplug is *not* supported in case of: |
|
1999 |
- qemu versions < 1.0 |
|
2000 |
- for stopped instances |
|
2001 |
|
|
2002 |
@raise errors.HypervisorError: in one of the previous cases |
|
2003 |
|
|
2004 |
""" |
|
2005 |
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD) |
|
2006 |
# TODO: search for netdev_add, drive_add, device_add..... |
|
2007 |
match = self._INFO_VERSION_RE.search(output.stdout) |
|
2008 |
if not match: |
|
2009 |
raise errors.HotplugError("Try hotplug only in running instances.") |
|
2010 |
v_major, v_min, _, _ = match.groups() |
|
2011 |
if (int(v_major), int(v_min)) < (1, 0): |
|
2012 |
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0") |
|
2013 |
|
|
2005 | 2014 |
def _CallHotplugCommand(self, name, cmd): |
2006 | 2015 |
output = self._CallMonitorCommand(name, cmd) |
2007 | 2016 |
# TODO: parse output and check if succeeded |
b/lib/rpc_defs.py | ||
---|---|---|
295 | 295 |
("extra", None, "Extra info for device (dev_path for disk)"), |
296 | 296 |
("seq", None, "Device seq"), |
297 | 297 |
], None, None, "Hoplug a device to a running instance"), |
298 |
("hotplug_supported", SINGLE, None, constants.RPC_TMO_NORMAL, [ |
|
299 |
("instance", ED_INST_DICT, "Instance object"), |
|
300 |
], None, None, "Check if hotplug is supported"), |
|
298 | 301 |
] |
299 | 302 |
|
300 | 303 |
_IMPEXP_CALLS = [ |
b/lib/server/noded.py | ||
---|---|---|
619 | 619 |
return backend.HotplugDevice(instance, action, dev_type, device, extra, seq) |
620 | 620 |
|
621 | 621 |
@staticmethod |
622 |
def perspective_hotplug_supported(params): |
|
623 |
"""Checks if hotplug is supported. |
|
624 |
|
|
625 |
""" |
|
626 |
instance = objects.Instance.FromDict(params[0]) |
|
627 |
return backend.HotplugSupported(instance) |
|
628 |
|
|
629 |
@staticmethod |
|
622 | 630 |
def perspective_migration_info(params): |
623 | 631 |
"""Gather information about an instance to be migrated. |
624 | 632 |
|
Also available in: Unified diff