From 1e34a8f91962a9a85ee6fc1478754736a5c36ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 10 Mar 2016 20:46:39 +0100 Subject: [PATCH] qemu: enable debug threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Jiri Denemark --- src/qemu/qemu_command.c | 34 ++++++++++++++----- .../qemuxml2argv-debug-threads.args | 22 ++++++++++++ .../qemuxml2argv-debug-threads.xml | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-debug-threads.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-debug-threads.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ee064794ca..bf39a458bc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5332,6 +5332,30 @@ qemuAppendKeyWrapMachineParms(virBuffer *buf, virQEMUCapsPtr qemuCaps, return true; } +static int +qemuBuildNameCommandLine(virCommandPtr cmd, + virQEMUDriverConfigPtr cfg, + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) +{ + virBuffer buf = VIR_BUFFER_INITIALIZER; + + virCommandAddArg(cmd, "-name"); + + virBufferAsprintf(&buf, "%s", def->name); + + if (cfg->setProcessName && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_PROCESS)) + virBufferAsprintf(&buf, ",process=qemu:%s", def->name); + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NAME_DEBUG_THREADS)) + virBufferAddLit(&buf, ",debug-threads=on"); + + virCommandAddArgBuffer(cmd, &buf); + + return 0; +} + static int qemuBuildMachineCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -7192,14 +7216,8 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddEnvPassCommon(cmd); - virCommandAddArg(cmd, "-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); - } + if (qemuBuildNameCommandLine(cmd, cfg, def, qemuCaps) < 0) + goto error; if (!standalone) virCommandAddArg(cmd, "-S"); /* freeze CPU */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.args b/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.args new file mode 100644 index 0000000000..2ad6fcfad5 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1,debug-threads=on \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.xml b/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.xml new file mode 100644 index 0000000000..bfdd1aa5ca --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-debug-threads.xml @@ -0,0 +1,34 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + A description of the test machine. + + A test of qemu's minimal configuration. + This test also tests the description and title elements. + + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4f6291dd52..e15da3738d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1893,6 +1893,8 @@ mymain(void) VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS, NONE); + DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); + qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;