'Trigger crash dump by injecting an NMI to the specified instance.'

def trigger_crash_dump(self, instance):

    try:
        self._host.get_guest(instance).inject_nmi()
    except libvirt.libvirtError as ex:
        error_code = ex.get_error_code()
        if (error_code == libvirt.VIR_ERR_NO_SUPPORT):
            raise exception.TriggerCrashDumpNotSupported()
        elif (error_code == libvirt.VIR_ERR_OPERATION_INVALID):
            raise exception.InstanceNotRunning(instance_id=instance.uuid)
        LOG.exception(_('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
