Enable libvirt coredumps

This adds a flag and basic config for enabling coredumps for libvirt.

Partial-Bug: 1643911
Co-Authored-By: Matthew Booth <mbooth@redhat.com>

Change-Id: If7cd54e804a5a389a0d82a325b58f5b41b8ef0db
This commit is contained in:
Ian Wienand 2017-03-29 11:52:06 +11:00
parent 6fbd969c85
commit bfcc760b96
2 changed files with 50 additions and 8 deletions

View File

@ -20,8 +20,46 @@ set +o xtrace
# extremely verbose.)
DEBUG_LIBVIRT=$(trueorfalse True DEBUG_LIBVIRT)
# Try to enable coredumps for libvirt
# Currently fairly specific to OpenStackCI hosts
DEBUG_LIBVIRT_COREDUMPS=$(trueorfalse False DEBUG_LIBVIRT_COREDUMPS)
# Only Xenial is left with libvirt-bin. Everywhere else is libvirtd
if is_ubuntu && [ ! -f /etc/init.d/libvirtd ]; then
LIBVIRT_DAEMON=libvirt-bin
else
LIBVIRT_DAEMON=libvirtd
fi
# Enable coredumps for libvirt
# Bug: https://bugs.launchpad.net/nova/+bug/1643911
function _enable_coredump {
local confdir=/etc/systemd/system/${LIBVIRT_DAEMON}.service.d
local conffile=${confdir}/coredump.conf
# Create a coredump directory, and instruct the kernel to save to
# here
sudo mkdir -p /var/core
sudo chmod a+wrx /var/core
echo '/var/core/core.%e.%p.%h.%t' | \
sudo tee /proc/sys/kernel/core_pattern
# Drop a config file to up the core ulimit
sudo mkdir -p ${confdir}
sudo tee ${conffile} <<EOF
[Service]
LimitCORE=infinity
EOF
# Tell systemd to reload the unit (service restarts later after
# config anyway)
sudo systemctl daemon-reload
}
# Installs required distro-specific libvirt packages.
function install_libvirt {
if is_ubuntu; then
install_package qemu-system
install_package libvirt-bin libvirt-dev
@ -48,7 +86,10 @@ function install_libvirt {
install_package libvirt libvirt-devel
pip_install_gr libvirt-python
fi
if [[ $DEBUG_LIBVIRT_COREDUMPS == True ]]; then
_enable_coredump
fi
}
@ -68,14 +109,6 @@ cgroup_device_acl = [
EOF
fi
# Since the release of Debian Wheezy the libvirt init script is libvirtd
# and not libvirtd-bin anymore.
if is_ubuntu && [ ! -f /etc/init.d/libvirtd ]; then
LIBVIRT_DAEMON=libvirt-bin
else
LIBVIRT_DAEMON=libvirtd
fi
if is_fedora || is_suse; then
# Starting with fedora 18 and opensuse-12.3 enable stack-user to
# virsh -c qemu:///system by creating a policy-kit rule for

View File

@ -223,6 +223,14 @@ def guru_meditation_reports():
print("guru meditation report in %s log" % service)
def var_core():
if os.path.exists('/var/core'):
_header("/var/core dumps")
# NOTE(ianw) : see DEBUG_LIBVIRT_COREDUMPS. We could think
# about getting backtraces out of these. There are other
# tools out there that can do that sort of thing though.
_dump_cmd("ls -ltrah /var/core")
def main():
opts = get_options()
fname = filename(opts.dir, opts.name)
@ -238,6 +246,7 @@ def main():
ebtables_dump()
compute_consoles()
guru_meditation_reports()
var_core()
if __name__ == '__main__':