From aa423ce0206eafb7fca5665b6acfbfab29024348 Mon Sep 17 00:00:00 2001 From: Plamen Dimitrov Date: Sat, 1 Aug 2015 02:33:16 +0200 Subject: [PATCH] Reduce the libvirt logging verbosity (not needed for qemu vms) We do this by importing these modules conditionally within the modules of shared qemu and livbirt vm usage. Signed-off-by: Plamen Dimitrov --- virttest/env_process.py | 7 +++++-- virttest/utils_libvirtd.py | 1 + virttest/virsh.py | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/virttest/env_process.py b/virttest/env_process.py index b6aefdaec75..1aff7529068 100644 --- a/virttest/env_process.py +++ b/virttest/env_process.py @@ -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 @@ -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') @@ -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() @@ -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() @@ -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) @@ -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, diff --git a/virttest/utils_libvirtd.py b/virttest/utils_libvirtd.py index 0642338b468..c1256ece45e 100644 --- a/virttest/utils_libvirtd.py +++ b/virttest/utils_libvirtd.py @@ -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") diff --git a/virttest/virsh.py b/virttest/virsh.py index 822c798a22a..5a476633e90 100644 --- a/virttest/virsh.py +++ b/virttest/virsh.py @@ -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")