Revision 24711492 lib/hypervisor/hv_kvm.py
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
2003 | 2003 |
"""Verifies that hotplug is supported. |
2004 | 2004 |
|
2005 | 2005 |
Hotplug is *not* supported in case of: |
2006 |
- qemu versions < 1.0 |
|
2007 | 2006 |
- security models and chroot (disk hotplug) |
2008 | 2007 |
- fdsend module is missing (nic hot-add) |
2009 | 2008 |
|
2010 | 2009 |
@raise errors.HypervisorError: in one of the previous cases |
2011 | 2010 |
|
2012 | 2011 |
""" |
2013 |
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD) |
|
2014 |
# TODO: search for netdev_add, drive_add, device_add..... |
|
2015 |
match = self._INFO_VERSION_RE.search(output.stdout) |
|
2016 |
if not match: |
|
2017 |
raise errors.HotplugError("Try hotplug only in running instances.") |
|
2018 |
v_major, v_min, _, _ = match.groups() |
|
2019 |
if (int(v_major), int(v_min)) < (1, 0): |
|
2020 |
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0") |
|
2021 |
|
|
2022 | 2012 |
if dev_type == constants.HOTPLUG_TARGET_DISK: |
2023 | 2013 |
hvp = instance.hvparams |
2024 | 2014 |
security_model = hvp[constants.HV_SECURITY_MODEL] |
... | ... | |
2035 | 2025 |
raise errors.HotplugError("Cannot hot-add NIC." |
2036 | 2026 |
" fdsend python module is missing.") |
2037 | 2027 |
|
2028 |
def HotplugSupported(self, instance): |
|
2029 |
"""Checks if hotplug is generally supported. |
|
2030 |
|
|
2031 |
Hotplug is *not* supported in case of: |
|
2032 |
- qemu versions < 1.0 |
|
2033 |
- for stopped instances |
|
2034 |
|
|
2035 |
@raise errors.HypervisorError: in one of the previous cases |
|
2036 |
|
|
2037 |
""" |
|
2038 |
output = self._CallMonitorCommand(instance.name, self._INFO_VERSION_CMD) |
|
2039 |
# TODO: search for netdev_add, drive_add, device_add..... |
|
2040 |
match = self._INFO_VERSION_RE.search(output.stdout) |
|
2041 |
if not match: |
|
2042 |
raise errors.HotplugError("Try hotplug only in running instances.") |
|
2043 |
v_major, v_min, _, _ = match.groups() |
|
2044 |
if (int(v_major), int(v_min)) < (1, 0): |
|
2045 |
raise errors.HotplugError("Hotplug not supported for qemu versions < 1.0") |
|
2046 |
|
|
2038 | 2047 |
def _CallHotplugCommand(self, name, cmd): |
2039 | 2048 |
output = self._CallMonitorCommand(name, cmd) |
2040 | 2049 |
# TODO: parse output and check if succeeded |
Also available in: Unified diff