From 16321f13c9736ce4f0ba39f2889d4b8c2d54a16c Mon Sep 17 00:00:00 2001 From: Renata Ravanelli Date: Fri, 13 Dec 2019 14:08:12 +0000 Subject: [PATCH] Issue #1264 : Libvirt check should only look for socket --- Makefile.am | 1 + config.py.in | 2 ++ utils.py | 15 +++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2278308f4..e02c5f7cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,6 +116,7 @@ do_substitution = \ -e 's,[@]datadir[@],$(datadir),g' \ -e 's,[@]sysconfdir[@],$(sysconfdir),g' \ -e 's,[@]localstatedir[@],$(localstatedir),g' \ + -e 's,[@]runstatedir[@],$(runstatedir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ -e 's,[@]wokdir[@],$(wokdir),g' \ -e 's,[@]kimchidir[@],$(kimchidir),g' \ diff --git a/config.py.in b/config.py.in index d407841b7..8cef5c590 100644 --- a/config.py.in +++ b/config.py.in @@ -37,6 +37,8 @@ __release__ = "@kimchirelease@" # Storage pool constant for read-only pool types READONLY_POOL_TYPE = ['iscsi', 'scsi', 'mpath'] +def get_libvirt_path(): + return os.path.join("@runstatedir@", 'libvirt') def get_kimchi_version(): return "-".join([__version__, __release__]) diff --git a/utils.py b/utils.py index b2f5bbf0d..d6698ae72 100644 --- a/utils.py +++ b/utils.py @@ -22,6 +22,7 @@ import os import re import sqlite3 +import stat import time import urllib from http.client import HTTPConnection @@ -262,11 +263,17 @@ def get_next_clone_name(all_names, basename, name_suffix='', ts=False): def is_libvirtd_up(): """ - Checks if libvirtd.service is up. + Checks if libvirt is up. """ - cmd = ['systemctl', 'is-active', 'libvirtd.service'] - output, error, rc = run_command(cmd, silent=True) - return True if output == 'active\n' else False + path = os.path.join(config.get_libvirt_path(), 'libvirt-sock') + try: + mode = os.stat(path).st_mode + if stat.S_ISSOCK(mode): + return True + except: + pass + + return False def is_s390x():