qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Laszlo Ersek <lersek@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 07/12] Add 'debug-threads' suboption to --name
Date: Tue, 4 Mar 2014 15:03:20 +0200	[thread overview]
Message-ID: <1393937889-14553-8-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1393937889-14553-1-git-send-email-mst@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Add flag storage to qemu-thread-* to store the namethreads flag

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 include/qemu/thread.h    | 1 +
 util/qemu-thread-posix.c | 7 +++++++
 util/qemu-thread-win32.c | 8 ++++++++
 vl.c                     | 9 +++++++++
 qemu-options.hx          | 7 +++++--
 5 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 3e32c65..bf1e110 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -59,5 +59,6 @@ void *qemu_thread_join(QemuThread *thread);
 void qemu_thread_get_self(QemuThread *thread);
 bool qemu_thread_is_self(QemuThread *thread);
 void qemu_thread_exit(void *retval);
+void qemu_thread_naming(bool enable);
 
 #endif
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 37dd298..0fa6c81 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -27,6 +27,13 @@
 #include "qemu/thread.h"
 #include "qemu/atomic.h"
 
+static bool name_threads;
+
+void qemu_thread_naming(bool enable)
+{
+    name_threads = enable;
+}
+
 static void error_exit(int err, const char *msg)
 {
     fprintf(stderr, "qemu: %s: %s\n", msg, strerror(err));
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 27a5217..e42cb77 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -16,6 +16,14 @@
 #include <assert.h>
 #include <limits.h>
 
+static bool name_threads;
+
+void qemu_thread_naming(bool enable)
+{
+    /* But note we don't actually name them on Windows yet */
+    name_threads = enable;
+}
+
 static void error_exit(int err, const char *msg)
 {
     char *pstr;
diff --git a/vl.c b/vl.c
index 5026e7a..a9b05cc 100644
--- a/vl.c
+++ b/vl.c
@@ -548,6 +548,12 @@ static QemuOptsList qemu_name_opts = {
             .name = "process",
             .type = QEMU_OPT_STRING,
             .help = "Sets the name of the QEMU process, as shown in top etc",
+        }, {
+            .name = "debug-threads",
+            .type = QEMU_OPT_BOOL,
+            .help = "When enabled, name the individual threads; defaults off.\n"
+                    "NOTE: The thread names are for debugging and not a\n"
+                    "stable API.",
         },
         { /* End of list */ }
     },
@@ -1007,6 +1013,9 @@ static void parse_name(QemuOpts *opts)
 {
     const char *proc_name;
 
+    if (qemu_opt_get(opts, "debug-threads")) {
+        qemu_thread_naming(qemu_opt_get_bool(opts, "debug-threads", false));
+    }
     qemu_name = qemu_opt_get(opts, "guest");
 
     proc_name = qemu_opt_get(opts, "process");
diff --git a/qemu-options.hx b/qemu-options.hx
index 56e5fdf..068da2d 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -328,9 +328,11 @@ possible drivers and properties, use @code{-device help} and
 ETEXI
 
 DEF("name", HAS_ARG, QEMU_OPTION_name,
-    "-name string1[,process=string2]\n"
+    "-name string1[,process=string2][,debug-threads=on|off]\n"
     "                set the name of the guest\n"
-    "                string1 sets the window title and string2 the process name (on Linux)\n",
+    "                string1 sets the window title and string2 the process name (on Linux)\n"
+    "                When debug-threads is enabled, individual threads are given a separate name (on Linux)\n"
+    "                NOTE: The thread names are for debugging and not a stable API.\n",
     QEMU_ARCH_ALL)
 STEXI
 @item -name @var{name}
@@ -339,6 +341,7 @@ Sets the @var{name} of the guest.
 This name will be displayed in the SDL window caption.
 The @var{name} will also be used for the VNC server.
 Also optionally set the top visible process name in Linux.
+Naming of individual threads can also be enabled on Linux to aid debugging.
 ETEXI
 
 DEF("uuid", HAS_ARG, QEMU_OPTION_uuid,
-- 
MST

  parent reply	other threads:[~2014-03-04 13:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 13:03 [Qemu-devel] [PULL 00/12] acpi,pc,pci,virtio,memory bug fixes Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 01/12] acpi-build: append description for non-hotplug Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 02/12] acpi-test-data: update expected files Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 03/12] virtio-net: remove function calls from assert Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 04/12] memory_region_present: return false if address is not found in child MemoryRegion Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 05/12] PCIE: fix regression with coldplugged multifunction device Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 06/12] Rework --name to use QemuOpts Michael S. Tsirkin
2014-03-04 13:03 ` Michael S. Tsirkin [this message]
2014-03-04 13:03 ` [Qemu-devel] [PULL 08/12] Add a 'name' parameter to qemu_thread_create Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 09/12] MAINTAINERS: drop an out of date address Michael S. Tsirkin
2014-03-04 16:05   ` Andreas Färber
2014-03-04 16:13     ` Paolo Bonzini
2014-03-04 13:03 ` [Qemu-devel] [PULL 10/12] acpi-build: partially revert dac1e93093f9306c114f410785c99aa5261539b4 Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 11/12] acpi-test: retain both asl and aml files on failure Michael S. Tsirkin
2014-03-04 13:03 ` [Qemu-devel] [PULL 12/12] acpi-test: issue errors instead of warnings when possible Michael S. Tsirkin
2014-03-04 13:07 ` [Qemu-devel] [PULL 00/12] acpi,pc,pci,virtio,memory bug fixes Peter Maydell
2014-03-04 13:11   ` Michael S. Tsirkin
2014-03-06 21:43 ` Michael S. Tsirkin
2014-03-06 21:56   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393937889-14553-8-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=dgilbert@redhat.com \
    --cc=lersek@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).