libvirt:Add a driver API to inject an NMI
This patch adds a new driver API to inject an NMI to an instance. This API is implemented by libvirt driver. NMI (Non-maskable Interruption) is used to trigger a special function such as the kernel crash dump mechanism. DocImpact Change-Id: Iaf63352139c466430d3304a87a66398133541fac Implements: blueprint inject-nmi
This commit is contained in:
parent
8a73c0430d
commit
d0ee3ab01d
|
@ -751,6 +751,9 @@ class Domain(object):
|
|||
def jobStats(self, flags=0):
|
||||
return {}
|
||||
|
||||
def injectNMI(self, flags=0):
|
||||
return 0
|
||||
|
||||
|
||||
class DomainSnapshot(object):
|
||||
def __init__(self, name, domain):
|
||||
|
|
|
@ -365,6 +365,11 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
|
|||
self.connection.power_off(instance_ref)
|
||||
self.connection.power_on(self.ctxt, instance_ref, network_info, None)
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_inject_nmi(self):
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
self.connection.inject_nmi(instance_ref)
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_soft_delete(self):
|
||||
instance_ref, network_info = self._get_running_instance(obj=True)
|
||||
|
|
|
@ -673,6 +673,13 @@ class ComputeDriver(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def inject_nmi(self, instance):
|
||||
"""Inject an NMI to the specified instance.
|
||||
|
||||
:param instance: nova objects.instance.Instance
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def soft_delete(self, instance):
|
||||
"""Soft delete the specified instance.
|
||||
|
||||
|
|
|
@ -243,6 +243,9 @@ class FakeDriver(driver.ComputeDriver):
|
|||
block_device_info=None):
|
||||
pass
|
||||
|
||||
def inject_nmi(self, instance):
|
||||
pass
|
||||
|
||||
def soft_delete(self, instance):
|
||||
pass
|
||||
|
||||
|
|
|
@ -2233,6 +2233,20 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# and available before we attempt to start the instance.
|
||||
self._hard_reboot(context, instance, network_info, block_device_info)
|
||||
|
||||
def inject_nmi(self, instance):
|
||||
|
||||
"""Inject an NMI to the specified instance."""
|
||||
try:
|
||||
self._host.get_guest(instance).inject_nmi()
|
||||
except libvirt.libvirtError as ex:
|
||||
error_code = ex.get_error_code()
|
||||
msg = (_('Error from libvirt while injecting an NMI to '
|
||||
'%(instance_uuid)s: '
|
||||
'[Error Code %(error_code)s] %(ex)s')
|
||||
% {'instance_uuid': instance.uuid,
|
||||
'error_code': error_code, 'ex': ex})
|
||||
raise exception.NovaException(msg)
|
||||
|
||||
def suspend(self, context, instance):
|
||||
"""Suspend the specified instance."""
|
||||
guest = self._host.get_guest(instance)
|
||||
|
|
|
@ -114,6 +114,10 @@ class Guest(object):
|
|||
"""Stops a running guest."""
|
||||
self._domain.destroy()
|
||||
|
||||
def inject_nmi(self):
|
||||
"""Injects an NMI to a guest."""
|
||||
self._domain.injectNMI()
|
||||
|
||||
def resume(self):
|
||||
"""Resumes a suspended guest."""
|
||||
self._domain.resume()
|
||||
|
|
Loading…
Reference in New Issue