#!/bin/bash

# TODO(SamYaple): Tweak libvirt.conf rather than change permissions.
# Fix permissions for libvirt
# Do not remove unless CentOS has been validated
if [[ -c /dev/kvm ]]; then
    if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
        chmod 660 /dev/kvm
        if [[ "$(uname -m)" == "aarch64" ]]; then
            chown root:kvm /dev/kvm
        else
            chown root:qemu /dev/kvm
        fi
    else
        chmod 666 /dev/kvm
        chown root:kvm /dev/kvm
    fi
fi

# Mount xenfs for libxl to work
if [[ $(lsmod | grep xenfs) ]]; then
    mount -t xenfs xenfs /proc/xen
fi

if [[ ! -d "/var/log/kolla/libvirt" ]]; then
    mkdir -p /var/log/kolla/libvirt
    touch /var/log/kolla/libvirt/libvirtd.log
    chmod 644 /var/log/kolla/libvirt/libvirtd.log
fi
if [[ $(stat -c %a /var/log/kolla/libvirt) != "755" ]]; then
    chmod 755 /var/log/kolla/libvirt
    chmod 644 /var/log/kolla/libvirt/libvirtd.log
fi

#!/bin/bash

# TODO(SamYaple): Tweak libvirt.conf rather than change permissions.
# Fix permissions for libvirt
# Do not remove unless CentOS has been validated
if [[ -c /dev/kvm ]]; then
    chmod 660 /dev/kvm
    chown root:qemu /dev/kvm
fi

# Mount xenfs for libxl to work
if [[ $(lsmod | grep xenfs) ]]; then
    mount -t xenfs xenfs /proc/xen
fi

if [[ ! -d "/var/log/kolla/libvirt" ]]; then
    mkdir -p /var/log/kolla/libvirt
    touch /var/log/kolla/libvirt/libvirtd.log
    chmod 644 /var/log/kolla/libvirt/libvirtd.log
fi
if [[ $(stat -c %a /var/log/kolla/libvirt) != "755" ]]; then
    chmod 755 /var/log/kolla/libvirt
    chmod 644 /var/log/kolla/libvirt/libvirtd.log
fi

Revert "nova-libvirt: fix kvm permission issue"
Revert "nova-libvirt: fix kvm permission issue"

This is not needed. If we make sure qemu use nova user.
Because nova user in group qemu.

See comment #7 of bug #1715356:
The root cause for this issue is that qemu not run with nova user on
debian.
If we set qemu running with nova user with this patch:
https://review.openstack.org/#/c/525891/
Then we need to revert commit f1b98a4925826333cf22dafe15ef755066c51d48.

This reverts commit f1b98a4925826333cf22dafe15ef755066c51d48.
Closes-bug: #1715356
Depends-on: I36720af0c7d3dd7c69d2404843f54c0991aea1bb

Change-Id: I62fbcf9e4ee5c3170c96576698f4ae8b66db1b74
