From b865a8529b8748a8571ea847750f3e2c0a5d491b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 4 Feb 2015 18:58:20 +0000 Subject: [PATCH] Upstream patch to fix performance regression in virt-builder (RHBZ#1188866). - Change the way Python double-build is done so we only have to apply patches in one place. --- ...e-performance-regression-in-pxzcat-R.patch | 63 +++++++++++++++++++ libguestfs.spec | 21 +++++-- 2 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 0001-builder-Fix-large-performance-regression-in-pxzcat-R.patch diff --git a/0001-builder-Fix-large-performance-regression-in-pxzcat-R.patch b/0001-builder-Fix-large-performance-regression-in-pxzcat-R.patch new file mode 100644 index 0000000..18e436f --- /dev/null +++ b/0001-builder-Fix-large-performance-regression-in-pxzcat-R.patch @@ -0,0 +1,63 @@ +From ff1cf989fd49cfb82db428e66034c7b2d6bebe8a Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 4 Feb 2015 13:17:40 +0000 +Subject: [PATCH] builder: Fix large performance regression in pxzcat + (RHBZ#1188866). + +Commit 9135129b0f6e8eb171131ea0f7d729a960b74cb3 changed +two stack buffers to pointers: + +- uint8_t buf[BUFFER_SIZE]; +- unsigned char outbuf[BUFFER_SIZE]; ++ CLEANUP_FREE uint8_t *buf = NULL; ++ CLEANUP_FREE uint8_t *outbuf = NULL; + +but we were still using sizeof buf to calculate the size of the +buffer. sizeof buf == 8 so the original code which used large buffers +for reading/writing the file changed to using 8 byte buffers. +--- + builder/pxzcat-c.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/builder/pxzcat-c.c b/builder/pxzcat-c.c +index bd4c0a8..0bbd296 100644 +--- a/builder/pxzcat-c.c ++++ b/builder/pxzcat-c.c +@@ -640,14 +640,14 @@ worker_thread (void *vp) + strm.next_in = NULL; + strm.avail_in = 0; + strm.next_out = outbuf; +- strm.avail_out = sizeof outbuf; ++ strm.avail_out = BUFFER_SIZE; + + for (;;) { + lzma_action action = LZMA_RUN; + + if (strm.avail_in == 0) { + strm.next_in = buf; +- n = pread (global->fd, buf, sizeof buf, position); ++ n = pread (global->fd, buf, BUFFER_SIZE, position); + if (n == -1) { + perror (global->filename); + return &state->status; +@@ -661,7 +661,7 @@ worker_thread (void *vp) + r = lzma_code (&strm, action); + + if (strm.avail_out == 0 || r == LZMA_STREAM_END) { +- size_t wsz = sizeof outbuf - strm.avail_out; ++ size_t wsz = BUFFER_SIZE - strm.avail_out; + + /* Don't write if the block is all zero, to preserve output file + * sparseness. However we have to update oposition. +@@ -675,7 +675,7 @@ worker_thread (void *vp) + oposition += wsz; + + strm.next_out = outbuf; +- strm.avail_out = sizeof outbuf; ++ strm.avail_out = BUFFER_SIZE; + } + + if (r == LZMA_STREAM_END) +-- +2.1.0 + diff --git a/libguestfs.spec b/libguestfs.spec index d101104..076e931 100644 --- a/libguestfs.spec +++ b/libguestfs.spec @@ -25,13 +25,16 @@ Summary: Access and modify virtual machine disk images Name: libguestfs Epoch: 1 Version: 1.29.24 -Release: 1%{?dist} +Release: 2%{?dist} License: LGPLv2+ # Source and patches. URL: http://libguestfs.org/ Source0: http://libguestfs.org/download/1.29-development/%{name}-%{version}.tar.gz +# Upstream patch to fix performance regression in virt-builder (RHBZ#1188866). +Patch0001: 0001-builder-Fix-large-performance-regression-in-pxzcat-R.patch + # Basic build requirements: BuildRequires: perl(Pod::Simple) BuildRequires: perl(Pod::Man) @@ -746,13 +749,18 @@ for %{name}. %prep +%setup -q + +%patch0001 -p1 + # For Python 3 we must build libguestfs twice. This creates: # %{name}-%{version}/ # %{name}-%{version}/python3/ # with a second copy of the sources in the python3 subdir. -%setup -q -%setup -q -T -D -a 0 -mv %{name}-%{version} python3 +pushd .. +cp -a %{name}-%{version} tmp-python3 +mv tmp-python3 %{name}-%{version}/python3 +popd if [ "$(getenforce | tr '[A-Z]' '[a-z]')" != "disabled" ]; then # For sVirt to work, the local temporary directory we use in the @@ -1283,6 +1291,11 @@ popd %changelog +* Wed Feb 04 2015 Richard W.M. Jones - 1:1.29.24-2 +- Upstream patch to fix performance regression in virt-builder (RHBZ#1188866). +- Change the way Python double-build is done so we only have to + apply patches in one place. + * Tue Feb 03 2015 Richard W.M. Jones - 1:1.29.24-1 - New upstream version 1.29.24. - Add Python 3 bindings.