From: Yunping Zheng <[email protected]> this patch add systemtap tracing support when running qemu-kvm after apply this patch,you can using 'stap' commands to tracing qemu process.the test.debugdir/systemtap.log will record all the log info of stap. using 'enable_systemtap_tracing = yes' to enable this,default is not enable.before using this patch, your host must support stap. (it means you must installed systemstap and kernel-debuginfo on your host) when you using this, you must assign a stap script using "stap_scripts_file" option. like: - boot: stap_scripts_file = /home/yunzheng/qemu-kvm.stp enable_systemtap_tracing = yes
Signed-off-by: Yunping Zheng <[email protected]> --- client/virt/env_process.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/client/virt/env_process.py b/client/virt/env_process.py index 8a98d0c..763c186 100644 --- a/client/virt/env_process.py +++ b/client/virt/env_process.py @@ -3,6 +3,7 @@ from autotest.client import utils from autotest.client.shared import error import aexpect, kvm_monitor, ppm_utils, test_setup, virt_vm, kvm_vm import libvirt_vm, video_maker, utils_misc, storage, kvm_storage +import utils_misc import remote, ovirt try: @@ -15,7 +16,7 @@ except ImportError: _screendump_thread = None _screendump_thread_termination_event = None - +systemtap_trac_sub = None def preprocess_image(test, params, image_name): """ @@ -194,6 +195,25 @@ def postprocess_vm(test, params, env, name): logging.debug("Param 'kill_vm' specified, killing VM") vm.destroy(gracefully = params.get("kill_vm_gracefully") == "yes") +def systemtap_tracing_qemu(systemtap_scripts, systemtap_log): + """ + Tracing the qemu process using systemtap tools. + """ + _sub = None + stap_support_cmd = "sudo stap -e 'probe begin { log(\"Support\") exit() }'" + if re.findall("Support", utils.system_output(stap_support_cmd)): + if os.path.isfile(systemtap_scripts): + logging.info("Stap process Tracing qemu now") + _sub = aexpect.Tail("%s %s" % ("sudo stap", systemtap_scripts), + output_func = utils_misc.log_line, + output_params = (systemtap_log,)) + else: + raise error.TestError("Script '%s' not exist, Checking it please" + % systemtap_scripts) + else: + raise error.TestError("Seems your host not support 'stap'") + + return _sub def process_command(test, params, env, command, command_timeout, command_noncritical): @@ -407,6 +427,22 @@ def preprocess(test, params, env): image_obj = kvm_storage.QemuImg(params, test.bindir, image) image_obj.clone_image(params, vm_name, image, test.bindir) + #Execute stap tracing + if params.get("enable_systemtap_tracing", "no") == "yes": + stap_scripts_base_path = utils_misc.get_path(test.bindir, + "scripts/systemtap") + if params.get("stap_scripts_file"): + stap_scripts_path = params.get("stap_scripts_file") + else: + stap_scripts_path = params.get("type") + ".stp" + + stap_scripts_file = utils_misc.get_path(stap_scripts_base_path, + stap_scripts_path) + stap_log_file = utils_misc.get_path(test.debugdir, "systemtap.log") + global systemtap_trac_sub + systemtap_trac_sub = systemtap_tracing_qemu(stap_scripts_file, + stap_log_file) + # Preprocess all VMs and images if params.get("not_preprocess","no") == "no": process(test, params, env, preprocess_image, preprocess_vm) @@ -435,6 +471,12 @@ def postprocess(test, params, env): # Postprocess all VMs and images process(test, params, env, postprocess_image, postprocess_vm, vm_first=True) + # Terminate the systemtap thread + global systemtap_trac_sub + if systemtap_trac_sub: + logging.debug("Terminating systemtap thread") + systemtap_trac_sub.close() + # Terminate the screendump thread global _screendump_thread, _screendump_thread_termination_event if _screendump_thread is not None: -- 1.7.11.4 _______________________________________________ Autotest-kernel mailing list [email protected] https://www.redhat.com/mailman/listinfo/autotest-kernel
