[libguestfs] Enable debugging messages in parallel virt-alignment-scan, virt-df in order to debug possible race c
Richard W.M. Jones
rjones at fedoraproject.org
Tue Sep 3 11:55:59 UTC 2013
commit 84b1660786a1703ee8a19210bde3946247ee29e6
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Tue Sep 3 12:55:01 2013 +0100
Enable debugging messages in parallel virt-alignment-scan, virt-df
in order to debug possible race condition seen in Koji.
...allel-Compile-debugging-messages-in-alway.patch | 107 ++++++++++++++++++++
libguestfs.spec | 10 ++-
2 files changed, 116 insertions(+), 1 deletions(-)
---
diff --git a/0001-virt-df-parallel-Compile-debugging-messages-in-alway.patch b/0001-virt-df-parallel-Compile-debugging-messages-in-alway.patch
new file mode 100644
index 0000000..122c57e
--- /dev/null
+++ b/0001-virt-df-parallel-Compile-debugging-messages-in-alway.patch
@@ -0,0 +1,107 @@
+From d512fb4a1a98be294d11d5de88eabcfc2be8e964 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones at redhat.com>
+Date: Tue, 3 Sep 2013 12:44:25 +0100
+Subject: [PATCH] virt-df: parallel: Compile debugging messages in always.
+
+Enable debugging messages whenever LIBGUESTFS_DEBUG=1 / -v option, so
+that we can track down possible race condition seen in Koji.
+---
+ df/parallel.c | 26 ++++++++++++++++++--------
+ 1 file changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/df/parallel.c b/df/parallel.c
+index a06e370..1a47b34 100644
+--- a/df/parallel.c
++++ b/df/parallel.c
+@@ -42,8 +42,6 @@
+
+ #if defined(HAVE_LIBVIRT)
+
+-#define DEBUG_PARALLEL 0
+-
+ /* Maximum number of threads we would ever run. Note this should not
+ * be > 20, unless libvirt is modified to increase the maximum number
+ * of clients.
+@@ -70,6 +68,7 @@ static void thread_failure (const char *fn, int err);
+ static void *worker_thread (void *arg);
+
+ struct thread_data {
++ size_t thread_num; /* Thread number. */
+ int trace, verbose; /* Flags from the options_handle. */
+ work_fn work;
+ int r; /* Used to store the error status. */
+@@ -96,6 +95,7 @@ start_threads (size_t option_P, guestfs_h *options_handle, work_fn work)
+ pthread_t threads[nr_threads];
+
+ for (i = 0; i < nr_threads; ++i) {
++ thread_data[i].thread_num = i;
+ if (options_handle) {
+ thread_data[i].trace = guestfs_get_trace (options_handle);
+ thread_data[i].verbose = guestfs_get_verbose (options_handle);
+@@ -137,6 +137,9 @@ worker_thread (void *thread_data_vp)
+
+ thread_data->r = 0;
+
++ if (thread_data->verbose)
++ printf ("thread %zu starting\n", thread_data->thread_num);
++
+ while (1) {
+ size_t i; /* The current domain we're working on. */
+ FILE *fp;
+@@ -146,6 +149,9 @@ worker_thread (void *thread_data_vp)
+ int err;
+
+ /* Take the next domain from the list. */
++ if (thread_data->verbose)
++ printf ("thread %zu waiting to get work\n", thread_data->thread_num);
++
+ err = pthread_mutex_lock (&take_mutex);
+ if (err != 0) {
+ thread_failure ("pthread_mutex_lock", err);
+@@ -163,8 +169,8 @@ worker_thread (void *thread_data_vp)
+ if (i >= nr_domains) /* Work finished. */
+ break;
+
+- if (DEBUG_PARALLEL)
+- printf ("thread taking domain %zu\n", i);
++ if (thread_data->verbose)
++ printf ("thread %zu taking domain %zu\n", thread_data->thread_num, i);
+
+ fp = open_memstream (&output, &output_len);
+ if (fp == NULL) {
+@@ -195,6 +201,10 @@ worker_thread (void *thread_data_vp)
+ /* Retire this domain. We have to retire domains in order, which
+ * may mean waiting for another thread to finish here.
+ */
++ if (thread_data->verbose)
++ printf ("thread %zu waiting to retire domain %zu\n",
++ thread_data->thread_num, i);
++
+ err = pthread_mutex_lock (&retire_mutex);
+ if (err != 0) {
+ thread_failure ("pthread_mutex_lock", err);
+@@ -210,8 +220,8 @@ worker_thread (void *thread_data_vp)
+ }
+ }
+
+- if (DEBUG_PARALLEL)
+- printf ("thread retiring domain %zu\n", i);
++ if (thread_data->verbose)
++ printf ("thread %zu retiring domain %zu\n", thread_data->thread_num, i);
+
+ /* Retire domain. */
+ printf ("%s", output);
+@@ -227,8 +237,8 @@ worker_thread (void *thread_data_vp)
+ }
+ }
+
+- if (DEBUG_PARALLEL)
+- printf ("thread exiting\n");
++ if (thread_data->verbose)
++ printf ("thread %zu exiting\n", thread_data->thread_num);
+
+ return &thread_data->r;
+ }
+--
+1.8.3.1
+
diff --git a/libguestfs.spec b/libguestfs.spec
index 76e31c5..8e72936 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -12,13 +12,15 @@ Summary: Access and modify virtual machine disk images
Name: libguestfs
Epoch: 1
Version: 1.23.20
-Release: 4%{?dist}
+Release: 5%{?dist}
License: LGPLv2+
# Source and patches.
URL: http://libguestfs.org/
Source0: http://libguestfs.org/download/1.23-development/%{name}-%{version}.tar.gz
+Patch1: 0001-virt-df-parallel-Compile-debugging-messages-in-alway.patch
+
# Basic build requirements:
BuildRequires: perl(Pod::Simple)
BuildRequires: perl(Pod::Man)
@@ -558,6 +560,8 @@ for %{name}.
%prep
%setup -q
+%patch1 -p1
+
if [ "$(getenforce | tr '[A-Z]' '[a-z]')" != "disabled" ]; then
# For sVirt to work, the local temporary directory we use in the
# tests must be labelled the same way as /tmp.
@@ -947,6 +951,10 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/libguestfs
%changelog
+* Tue Sep 3 2013 Richard W.M. Jones <rjones at redhat.com> - 1:1.23.20-5
+- Enable debugging messages in parallel virt-alignment-scan, virt-df
+ in order to debug possible race condition seen in Koji.
+
* Mon Sep 2 2013 Richard W.M. Jones <rjones at redhat.com> - 1:1.23.20-4
- Rebuild now that RHBZ#1003495 is supposed to be fixed.
More information about the scm-commits
mailing list