When debug-threads is enabled, individual threads are given a separate name (on Linux) Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1140121 Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- src/qemu/libvirtd_qemu.aug | 1 + src/qemu/qemu.conf | 6 ++++++ src/qemu/qemu_command.c | 14 ++++++++++---- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index b6f6dc4..8a5e656 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -69,6 +69,7 @@ module Libvirtd_qemu = | bool_entry "clear_emulator_capabilities" | str_entry "bridge_helper" | bool_entry "set_process_name" + | bool_entry "set_debug_threads_name" | int_entry "max_processes" | int_entry "max_files" | str_entry "stdio_handler" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 4fa5e8a..12800e9 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -380,6 +380,12 @@ # #set_process_name = 1 +# If enabled, QEMU will name the individual QEMU threads to be +# helpful, e.g. 'CPU/KVM 0' or 'migration'. these show up in top once +# the H key is pressed, and also show up in a core dump, making it +# easy to figure out which thread is which. +# +#set_debug_threads_name = 0 # If max_processes is set to a positive integer, libvirt will use # it to set the maximum number of processes that can be run by qemu diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 000c29d..8c95181 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7081,6 +7081,7 @@ qemuBuildCommandLine(virConnectPtr conn, virBuffer boot_buf = VIR_BUFFER_INITIALIZER; char *boot_order_str = NULL, *boot_opts_str = NULL; virBuffer fdc_opts = VIR_BUFFER_INITIALIZER; + virBuffer name_opts = VIR_BUFFER_INITIALIZER; char *fdc_opts_str = NULL; int bootCD = 0, bootFloppy = 0, bootDisk = 0, bootHostdevNet = 0; @@ -7106,13 +7107,18 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddEnvPassCommon(cmd); virCommandAddArg(cmd, "-name"); + virBufferAsprintf(&name_opts, "%s", def->name); if (cfg->setProcessName && virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS)) { - virCommandAddArgFormat(cmd, "%s,process=qemu:%s", - def->name, def->name); - } else { - virCommandAddArg(cmd, def->name); + virBufferAsprintf(&name_opts, ",process=qemu:%s", def->name); + } + if (cfg->setDebugThreadsName && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_DEBUG_THREADS)) { + virBufferAddLit(&name_opts, ",debug-threads=on"); } + if (virBufferCheckError(&name_opts) < 0) + goto error; + virCommandAddArg(cmd, virBufferContentAndReset(&name_opts)); if (!standalone) virCommandAddArg(cmd, "-S"); /* freeze CPU */ diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 77ef4fe..c827d71 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -794,6 +794,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_BOOL("clear_emulator_capabilities", cfg->clearEmulatorCapabilities); GET_VALUE_BOOL("allow_disk_format_probing", cfg->allowDiskFormatProbing); GET_VALUE_BOOL("set_process_name", cfg->setProcessName); + GET_VALUE_BOOL("set_debug_threads_name", cfg->setDebugThreadsName); GET_VALUE_ULONG("max_processes", cfg->maxProcesses); GET_VALUE_ULONG("max_files", cfg->maxFiles); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a714b84..0869bfd 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -143,6 +143,7 @@ struct _virQEMUDriverConfig { bool clearEmulatorCapabilities; bool allowDiskFormatProbing; bool setProcessName; + bool setDebugThreadsName; int maxProcesses; int maxFiles; diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in index 8bec743..bf11ef9 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -59,6 +59,7 @@ module Test_libvirtd_qemu = { "bridge_helper" = "/usr/libexec/qemu-bridge-helper" } { "clear_emulator_capabilities" = "1" } { "set_process_name" = "1" } +{ "set_debug_threads_name" = "0" } { "max_processes" = "0" } { "max_files" = "0" } { "mac_filter" = "1" } -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list