Skip to content

Commit

Permalink
Reduce the libvirt logging verbosity (not needed for qemu vms)
Browse files Browse the repository at this point in the history
We do this by importing these modules conditionally within the
modules of shared qemu and livbirt vm usage.

Signed-off-by: Plamen Dimitrov <[email protected]>
  • Loading branch information
pevogam committed Jul 13, 2023
1 parent e20d6f4 commit aa423ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@
from virttest import storage
from virttest import utils_libguestfs
from virttest import qemu_storage
from virttest import utils_libvirtd
from virttest import data_dir
from virttest import utils_net
from virttest import nfs
from virttest import libvirt_vm
from virttest import virsh
from virttest import utils_test
from virttest import utils_iptables
from virttest import utils_package
Expand Down Expand Up @@ -1135,6 +1133,7 @@ def preprocess(test, params, env):
migrate_setup.migrate_pre_setup(dest_uri, params)
# Map hostname and IP address of the hosts to avoid virsh
# to error out of resolving
from virttest import virsh
hostname_ip = {str(virsh.hostname()): params['local_ip']}
session = test_setup.remote_session(params)
_, remote_hostname = session.cmd_status_output('hostname')
Expand Down Expand Up @@ -1269,6 +1268,7 @@ def preprocess(test, params, env):
if not params.get("hugepage_path"):
params["hugepage_path"] = h.hugepage_path
if vm_type == "libvirt":
from virttest import utils_libvirtd
if libvirtd_inst is None:
libvirtd_inst = utils_libvirtd.Libvirtd()
libvirtd_inst.restart()
Expand Down Expand Up @@ -1744,6 +1744,7 @@ def postprocess(test, params, env):
h = test_setup.HugePageConfig(params)
h.cleanup()
if vm_type == "libvirt":
from virttest import utils_libvirtd
if libvirtd_inst is None:
libvirtd_inst = utils_libvirtd.Libvirtd()
libvirtd_inst.restart()
Expand Down Expand Up @@ -1781,6 +1782,7 @@ def postprocess(test, params, env):
LOG.error(details)

if vm_type == "libvirt":
from virttest import utils_libvirtd
if params.get("setup_libvirt_polkit") == "yes":
try:
pol = test_setup.LibvirtPolkitConfig(params)
Expand Down Expand Up @@ -2053,6 +2055,7 @@ def store_vm_info(vm, log_filename, info_cmd='registers',
LOG.warn(err)
return False
elif vmtype == "libvirt":
from virttest import virsh
try:
result = virsh.qemu_monitor_command(vm.name,
"info %s" % info_cmd,
Expand Down
1 change: 1 addition & 0 deletions virttest/utils_libvirtd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, service_name=None, session=None, all_daemons=False):
self.daemons = []
self.service_list = []

# we only import this module conditionally to make this warning always applicable
if LIBVIRTD is None:
LOG.warning("Libvirtd service is not available in host, "
"utils_libvirtd module will not function normally")
Expand Down
1 change: 1 addition & 0 deletions virttest/virsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
try:
VIRSH_EXEC = path.find_command("virsh")
except path.CmdNotFoundError:
# we only import this module conditionally to make this warning always applicable
logging.getLogger('avocado.app').warning(
"Virsh executable not set or found on path, virsh module will not "
"function normally")
Expand Down

0 comments on commit aa423ce

Please sign in to comment.