Nova: Fix libvirtd PID check and error reporting

Prevent false positive container exit from recycled libvirtd PID.

Clarify error log message and fix exit code typo.

Closes-Bug: #1711480
Change-Id: I47a7fdcb40b5c8153cf428e6863b618301abfd7c
This commit is contained in:
Craig Anderson 2017-08-22 19:59:24 +00:00
parent b06fab9c07
commit 1080c9e5be

View File

@ -19,8 +19,10 @@ limitations under the License.
set -ex
if [[ -f /var/run/libvirtd.pid ]]; then
test -d /proc/$(< /var/run/libvirtd.pid) && \
( echo "Libvirtd daemon is running" && exit 10 )
LIBVIRTD_PID="$(< /var/run/libvirtd.pid)"
test -d "/proc/$LIBVIRTD_PID" && \
test 'libvirtd' = "$(< /proc/$LIBVIRTD_PID/comm)" && \
( echo "ERROR: Libvirtd daemon is already running" && exit 1 )
fi
rm -f /var/run/libvirtd.pid