File libvirt-supportconfig of Package libvirt.42084

#!/bin/bash
#############################################################
# Name:        Supportconfig Plugin for libvirt
# Description: Gathers important troubleshooting information
#              about libvirt
# Author:      Jim Fehlig <jfehlig@suse.com>
#############################################################

RCFILE="/usr/lib/supportconfig/resources/supportconfig.rc"
OF="output-libvirt.txt"

LIBVIRTD_CONF_FILES="$(find -L /etc/libvirt/*.conf -type f | sort)"
PERSISTENT_VM_CONF_FILES=""
ACTIVE_VM_CONF_FILES=""
LIBVIRTD_LOG_FILES="$(find -L /var/log/libvirt/ -name libvirtd.log -type f | sort)"


if [ -s $RCFILE ]; then
    if ! source $RCFILE; then
        log_write $OF "ERROR: Initializing resource file: $RCFILE"
        exit 1
    fi
fi

rpm_installed() {
    thisrpm="$1"

    if rpm -q "$thisrpm" >/dev/null 2>&1; then
        return 0
    fi
    return 1
}

if rpm_installed libvirt-daemon-driver-libxl; then
    test -d /etc/libvirt/libxl && PERSISTENT_VM_CONF_FILES="$PERSISTENT_VM_CONF_FILES $(find -L /etc/libvirt/libxl/ -type f | sort)"
    test -d /run/libvirt/libxl && ACTIVE_VM_CONF_FILES="$ACTIVE_VM_CONF_FILES $(find -L /run/libvirt/libxl/ -type f | sort)"
    test -d /var/log/libvirt/libxl && LIBVIRTD_LOG_FILES="$LIBVIRTD_LOG_FILES $(find -L /var/log/libvirt/libxl/ -type f | sort)"
fi

if rpm_installed libvirt-daemon-driver-qemu; then
    test -d /etc/libvirt/qemu && PERSISTENT_VM_CONF_FILES="$PERSISTENT_VM_CONF_FILES $(find -L /etc/libvirt/qemu/ -type f | sort)"
    test -d /run/libvirt/qemu && ACTIVE_VM_CONF_FILES="$ACTIVE_VM_CONF_FILES $(find -L /run/libvirt/qemu/ -type f | sort)"
    test -d /var/log/libvirt/qemu && LIBVIRTD_LOG_FILES="$LIBVIRTD_LOG_FILES $(find -L /var/log/libvirt/qemu/ -type f | sort)"
fi

if rpm_installed libvirt-daemon-driver-lxc; then
    test -d /etc/libvirt/lxc && PERSISTENT_VM_CONF_FILES="$PERSISTENT_VM_CONF_FILES $(find -L /etc/libvirt/lxc/ -type f | sort)"
    test -d /run/libvirt/lxc && ACTIVE_VM_CONF_FILES="$ACTIVE_VM_CONF_FILES $(find -L /run/libvirt/lxc/ -type f | sort)"
    test -d /var/log/libvirt/lxc && LIBVIRTD_LOG_FILES="$LIBVIRTD_LOG_FILES $(find -L /var/log/libvirt/lxc/ -type f | sort)"
fi

if ! rpm_verify libvirt-daemon; then
    echo "Skipped"
    exit 0
fi

if systemctl is-active --quiet libvirtd.service; then
    log_cmd $OF "virsh version"
    log_cmd $OF "virsh capabilities"
    log_cmd $OF "virsh domcapabilities"
    log_cmd $OF "virsh nodeinfo"
    log_cmd $OF "virsh nodedev-list"
    # print all known domains on default URI
    log_cmd $OF "virsh list --all"
    # dump configuration info of active domains on default URI
    for DOM in $(virsh list --name)
    do
        log_cmd $OF "virsh dumpxml $DOM"
        log_cmd $OF "virsh vcpuinfo $DOM"
        log_cmd $OF "virsh dominfo $DOM"
        log_cmd $OF "virsh domjobinfo $DOM"
        log_cmd $OF "virsh dommemstat $DOM"
        log_cmd $OF "virsh snapshot-list $DOM"
    done
    # dump configuration info of inactive domains on default URI
    for DOM in $(virsh list --name --inactive)
    do
        log_cmd $OF "virsh dumpxml $DOM"
        log_cmd $OF "virsh snapshot-list $DOM"
    done
    # for LXC domains we have to explicitly specify the URI
    if rpm_installed libvirt-daemon-driver-lxc; then
        for DOM in $(virsh -c lxc:/// list --name --all); do
            log_cmd $OF "virsh -c lxc:/// dumpxml $DOM"
            log_cmd $OF "virsh -c lxc:/// dominfo $DOM"
        done
    fi

    # dump active networks, interfaces and storage pools
    log_cmd $OF "virsh net-list"
    log_cmd $OF "virsh iface-list"
    log_cmd $OF "virsh pool-list"
fi

# dump libvirtd-related conf files
conf_files $OF "$LIBVIRTD_CONF_FILES"

# dump persistent VM-related conf files
conf_files $OF "$PERSISTENT_VM_CONF_FILES"

# dump active VM-related conf files
conf_files $OF "$ACTIVE_VM_CONF_FILES"

# dump hook conf files
test -d /etc/libvirt/hooks && FILES="$(find -L /etc/libvirt/hooks/ -type f | sort)"
conf_files $OF "$FILES"

# dump all log files
log_files $OF 0 "$LIBVIRTD_LOG_FILES"
openSUSE Build Service is sponsored by