diff --git a/0001-common-sparse-Fix-include-directory-for-nbdkit-plugi.patch b/0001-common-sparse-Fix-include-directory-for-nbdkit-plugi.patch index 5d7e960..7bc9092 100644 --- a/0001-common-sparse-Fix-include-directory-for-nbdkit-plugi.patch +++ b/0001-common-sparse-Fix-include-directory-for-nbdkit-plugi.patch @@ -1,7 +1,7 @@ From 9aa3a2a229e1dc3936e0295b05e151b4ef9a8826 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 27 Aug 2018 12:17:33 +0100 -Subject: [PATCH] common/sparse: Fix include directory for nbdkit-plugin.h. +Subject: [PATCH 1/6] common/sparse: Fix include directory for nbdkit-plugin.h. Fixes commit 5986c3063ee1d2f28a33d01006bc31b596b4d5f6. --- diff --git a/0002-data-memory-Small-refinements-to-the-man-pages.patch b/0002-data-memory-Small-refinements-to-the-man-pages.patch new file mode 100644 index 0000000..fdbef8f --- /dev/null +++ b/0002-data-memory-Small-refinements-to-the-man-pages.patch @@ -0,0 +1,52 @@ +From 087cd104e7fcbd48db66e1a4f4b134ae2e456842 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Aug 2018 12:45:50 +0100 +Subject: [PATCH 2/6] data, memory: Small refinements to the man pages. + +--- + plugins/data/nbdkit-data-plugin.pod | 3 +++ + plugins/memory/nbdkit-memory-plugin.pod | 7 ++++--- + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/plugins/data/nbdkit-data-plugin.pod b/plugins/data/nbdkit-data-plugin.pod +index 27a7850..c174abb 100644 +--- a/plugins/data/nbdkit-data-plugin.pod ++++ b/plugins/data/nbdkit-data-plugin.pod +@@ -28,6 +28,9 @@ image, possibly followed by zeroes (using the C parameter to pad + the image to the full size), or use the C parameter creatively + to make mostly sparse disk images. + ++The C parameter can specify any virtual size up to the maximum ++supported by nbdkit (C<2⁶³-1> bytes). ++ + =head1 EXAMPLES + + =over 4 +diff --git a/plugins/memory/nbdkit-memory-plugin.pod b/plugins/memory/nbdkit-memory-plugin.pod +index 0493d8d..bc1fecc 100644 +--- a/plugins/memory/nbdkit-memory-plugin.pod ++++ b/plugins/memory/nbdkit-memory-plugin.pod +@@ -13,7 +13,8 @@ single disk image in virtual memory, and discards it when nbdkit + exits. + + All nbdkit clients will see the same disk content, initially all +-zeroes. ++zeroes. This plugin can be used for testing or where you don't care ++about the final content of the disk image. + + The disk image is stored in memory using a sparse array. The + allocated parts of the disk image cannot be larger than physical RAM +@@ -26,8 +27,8 @@ maximum supported by nbdkit (C<2⁶³-1> bytes). This limit is tested + when nbdkit is compiled, and it should work on all platforms and + architectures supported by nbdkit. + +-This can be used for testing where you don't care about the final +-content of the disk image. ++If you want an in-memory disk image preinitialized with some data, ++look at L instead. + + =head1 PARAMETERS + +-- +2.18.0 + diff --git a/0003-memory-Document-how-to-preload-disk-images-into-the-.patch b/0003-memory-Document-how-to-preload-disk-images-into-the-.patch new file mode 100644 index 0000000..ebbf5b2 --- /dev/null +++ b/0003-memory-Document-how-to-preload-disk-images-into-the-.patch @@ -0,0 +1,44 @@ +From 7544ba9c12edc462799969129f49f0a1b76a6ef1 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Aug 2018 13:48:21 +0100 +Subject: [PATCH 3/6] memory: Document how to preload disk images into the + plugin. + +--- + plugins/memory/nbdkit-memory-plugin.pod | 20 ++++++++++++++++++-- + 1 file changed, 18 insertions(+), 2 deletions(-) + +diff --git a/plugins/memory/nbdkit-memory-plugin.pod b/plugins/memory/nbdkit-memory-plugin.pod +index bc1fecc..d5ea8ba 100644 +--- a/plugins/memory/nbdkit-memory-plugin.pod ++++ b/plugins/memory/nbdkit-memory-plugin.pod +@@ -27,8 +27,24 @@ maximum supported by nbdkit (C<2⁶³-1> bytes). This limit is tested + when nbdkit is compiled, and it should work on all platforms and + architectures supported by nbdkit. + +-If you want an in-memory disk image preinitialized with some data, +-look at L instead. ++=head2 Preloading data ++ ++If you want an in-memory disk image preinitialized with a small amount ++of data specified on the command line, look at ++L instead. ++ ++If you want to preload a large amount of data (eg. a disk image) into ++the memory plugin, use L: ++ ++ $ rm -f pid ++ $ nbdkit -P pid memory size=10G ++ ++ # wait for nbdkit to become ready to accept connections: ++ $ while [ ! -f pid ]; do sleep 1; done ++ ++ # preload Fedora disk image: ++ $ virt-builder fedora-28 --size=10G ++ $ qemu-img convert -p -n fedora-28.img nbd:localhost:10809 + + =head1 PARAMETERS + +-- +2.18.0 + diff --git a/0004-data-Fix-this-plugin-to-work-with-64-bit-offsets.patch b/0004-data-Fix-this-plugin-to-work-with-64-bit-offsets.patch new file mode 100644 index 0000000..d2e083b --- /dev/null +++ b/0004-data-Fix-this-plugin-to-work-with-64-bit-offsets.patch @@ -0,0 +1,58 @@ +From 5afc6acd0719ed5b5c4e48763237efe9230fb8a7 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Aug 2018 16:18:26 +0100 +Subject: [PATCH 4/6] data: Fix this plugin to work with 64 bit offsets. + +It can now handle 64 bit offsets on both 32 and 64 bit platforms. +--- + plugins/data/data.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/plugins/data/data.c b/plugins/data/data.c +index e61e3be..3d27227 100644 +--- a/plugins/data/data.c ++++ b/plugins/data/data.c +@@ -35,6 +35,8 @@ + + #include + #include ++#include ++#include + #include + + #if defined(HAVE_GNUTLS) && defined(HAVE_GNUTLS_BASE64_DECODE2) +@@ -107,25 +109,23 @@ read_base64 (const char *value) + static int + read_data (const char *value) + { +- size_t offset = 0; ++ int64_t offset = 0; + size_t i, len = strlen (value); + + for (i = 0; i < len; ++i) { +- int j, n; ++ int64_t j; ++ int n; + char c; + +- /* XXX Using the %i type specifier limits this plugin to creating +- * 32 bit data (even on 64 bit platforms). +- */ +- if (sscanf (&value[i], " @%i%n", &j, &n) == 1) { +- if (j == -1) { ++ if (sscanf (&value[i], " @%" SCNi64 "%n", &j, &n) == 1) { ++ if (j < 0) { + nbdkit_error ("data parameter @OFFSET must not be negative"); + return -1; + } + i += n; + offset = j; + } +- else if (sscanf (&value[i], " %i%n", &j, &n) == 1) { ++ else if (sscanf (&value[i], " %" SCNi64 "%n", &j, &n) == 1) { + if (j < 0 || j > 255) { + nbdkit_error ("data parameter BYTE must be in the range 0..255"); + return -1; +-- +2.18.0 + diff --git a/0005-data-Permit-whitespace-at-the-end-of-the-data-string.patch b/0005-data-Permit-whitespace-at-the-end-of-the-data-string.patch new file mode 100644 index 0000000..fb31dce --- /dev/null +++ b/0005-data-Permit-whitespace-at-the-end-of-the-data-string.patch @@ -0,0 +1,29 @@ +From f6d1419f36905965ec5ccb43236617639ea21c7f Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Aug 2018 18:52:51 +0100 +Subject: [PATCH 5/6] data: Permit whitespace at the end of the data string. + +--- + plugins/data/data.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/plugins/data/data.c b/plugins/data/data.c +index 3d27227..0925233 100644 +--- a/plugins/data/data.c ++++ b/plugins/data/data.c +@@ -141,6 +141,12 @@ read_data (const char *value) + return -1; + offset++; + } ++ /* We have to have a rule to skip just whitespace so that ++ * whitespace is permitted at the end of the string. ++ */ ++ else if (sscanf (&value[i], " %n", &n) == 0) { ++ i += n; ++ } + else { + nbdkit_error ("data parameter: parsing error at offset %zu", i); + return -1; +-- +2.18.0 + diff --git a/0006-data-Add-example-of-partitioned-7-EB-disk-and-test.patch b/0006-data-Add-example-of-partitioned-7-EB-disk-and-test.patch new file mode 100644 index 0000000..6b6f136 --- /dev/null +++ b/0006-data-Add-example-of-partitioned-7-EB-disk-and-test.patch @@ -0,0 +1,235 @@ +From 2c548ffcf2745f23a504d646f64a20c984bc2e32 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 27 Aug 2018 18:48:51 +0100 +Subject: [PATCH 6/6] data: Add example of partitioned 7 EB disk, and test. + +--- + plugins/data/nbdkit-data-plugin.pod | 48 ++++++++++- + tests/Makefile.am | 2 + + tests/test-data-7E.sh | 128 ++++++++++++++++++++++++++++ + 3 files changed, 177 insertions(+), 1 deletion(-) + create mode 100755 tests/test-data-7E.sh + +diff --git a/plugins/data/nbdkit-data-plugin.pod b/plugins/data/nbdkit-data-plugin.pod +index c174abb..5d66f43 100644 +--- a/plugins/data/nbdkit-data-plugin.pod ++++ b/plugins/data/nbdkit-data-plugin.pod +@@ -56,7 +56,7 @@ base64 decoding of C), followed by S<1M - 3 bytes> of zeroes. + @0x1fe 0x55 0xaa" \ + size=1M + +-The last example was created by running: ++This example was created by running: + + $ rm -f disk + $ truncate -s 1M disk +@@ -75,6 +75,52 @@ The last example was created by running: + and then translating the disk data and offsets into the C + string (see L). + ++=item Create a 7 EB (exabyte) disk with one empty GPT-formatted partition: ++ ++The data plugin supports huge sparse virtual disks, up to the maximum ++size supported by nbdkit itself (S<2⁶³-1 bytes> = ++S<8 exabytes - 1 byte>). These cause all sorts of problems for ++software and so make excellent test cases. To partition such a huge ++disk requires the GPT (GUID Partition Table) format since MBR is ++limited to just 2 TB. ++ ++ nbdkit data data=" ++ @0x1c0 2 0 0xee 0xfe 0xff 0xff 0x01 0 0 0 0xff 0xff 0xff 0xff ++ @0x1fe 0x55 0xaa ++ @0x200 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 ++ 0 0 1 0 0x5c 0 0 0 ++ 0x9b 0xe5 0x6a 0xc5 0 0 0 0 1 0 0 0 0 0 0 0 ++ 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 0x22 0 0 0 0 0 0 0 ++ 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f ++ 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c 2 0 0 0 0 0 0 0 ++ 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 ++ @0x400 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 ++ 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 ++ 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c ++ 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 ++ 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 ++ @0x6fffffffffffbe00 ++ 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 ++ 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 ++ 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c ++ 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 ++ 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 ++ @0x6ffffffffffffe00 ++ 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 ++ 0 0 1 0 0x5c 0 0 0 ++ 0x6c 0x76 0xa1 0xa0 0 0 0 0 ++ 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 1 0 0 0 0 0 0 0 0x22 0 0 0 0 0 0 0 ++ 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f ++ 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c ++ 0xdf 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 ++ " size=7E ++ + =back + + =head1 PARAMETERS +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 1dbfd32..aa7c0e2 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -48,6 +48,7 @@ EXTRA_DIST = \ + test-captive.sh \ + test-cow.sh \ + test-cxx.sh \ ++ test-data-7E.sh \ + test-data-base64.sh \ + test-data-raw.sh \ + test-debug-flags.sh \ +@@ -281,6 +282,7 @@ endif HAVE_GUESTFISH + # data plugin test. + LIBGUESTFS_TESTS += test-data + TESTS += \ ++ test-data-7E.sh \ + test-data-base64.sh \ + test-data-raw.sh + +diff --git a/tests/test-data-7E.sh b/tests/test-data-7E.sh +new file mode 100755 +index 0000000..8327511 +--- /dev/null ++++ b/tests/test-data-7E.sh +@@ -0,0 +1,128 @@ ++#!/usr/bin/env bash ++# nbdkit ++# Copyright (C) 2018 Red Hat Inc. ++# All rights reserved. ++# ++# Redistribution and use in source and binary forms, with or without ++# modification, are permitted provided that the following conditions are ++# met: ++# ++# * Redistributions of source code must retain the above copyright ++# notice, this list of conditions and the following disclaimer. ++# ++# * Redistributions in binary form must reproduce the above copyright ++# notice, this list of conditions and the following disclaimer in the ++# documentation and/or other materials provided with the distribution. ++# ++# * Neither the name of Red Hat nor the names of its contributors may be ++# used to endorse or promote products derived from this software without ++# specific prior written permission. ++# ++# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ++# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ++# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A ++# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR ++# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ++# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ++# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++# SUCH DAMAGE. ++ ++# Test the data plugin creating a 7 EB partitioned disk, and ++# the partition filter on top. ++ ++set -e ++set -x ++ ++files="data-7E.out data-7E.pid data-7E.sock" ++rm -f $files ++ ++# Test that qemu-io works ++if ! qemu-io --help >/dev/null; then ++ echo "$0: missing or broken qemu-io" ++ exit 77 ++fi ++ ++# Run nbdkit. ++nbdkit -P data-7E.pid -U data-7E.sock \ ++ --filter=partition \ ++ data size=7E partition=1 \ ++ data=" ++ @0x1c0 2 0 0xee 0xfe 0xff 0xff 0x01 0 0 0 0xff 0xff 0xff 0xff ++ @0x1fe 0x55 0xaa ++ @0x200 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 ++ 0 0 1 0 0x5c 0 0 0 ++ 0x9b 0xe5 0x6a 0xc5 0 0 0 0 1 0 0 0 0 0 0 0 ++ 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 0x22 0 0 0 0 0 0 0 ++ 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f ++ 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c 2 0 0 0 0 0 0 0 ++ 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 ++ @0x400 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 ++ 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 ++ 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c ++ 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 ++ 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 ++ @0x6fffffffffffbe00 ++ 0xaf 0x3d 0xc6 0x0f 0x83 0x84 0x72 0x47 ++ 0x8e 0x79 0x3d 0x69 0xd8 0x47 0x7d 0xe4 ++ 0xd5 0x19 0x46 0x95 0xe3 0x82 0xa8 0x4c ++ 0x95 0x82 0x7a 0xbe 0x1c 0xfc 0x62 0x90 ++ 0x80 0 0 0 0 0 0 0 0x80 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0 0 0 0 0 0 0 0 0x70 0 0x31 0 0 0 0 0 ++ @0x6ffffffffffffe00 ++ 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54 ++ 0 0 1 0 0x5c 0 0 0 ++ 0x6c 0x76 0xa1 0xa0 0 0 0 0 ++ 0xff 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 1 0 0 0 0 0 0 0 0x22 0 0 0 0 0 0 0 ++ 0xde 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x72 0xb6 0x9e 0x0c 0x6b 0x76 0xb0 0x4f ++ 0xb3 0x94 0xb2 0xf1 0x61 0xec 0xdd 0x3c ++ 0xdf 0xff 0xff 0xff 0xff 0xff 0x37 0 ++ 0x80 0 0 0 0x80 0 0 0 0x79 0x8a 0xd0 0x7e 0 0 0 0 ++ " ++ ++# We may have to wait a short time for the pid file to appear. ++for i in `seq 1 10`; do ++ if test -f data-7E.pid; then ++ break ++ fi ++ sleep 1 ++done ++if ! test -f data-7E.pid; then ++ echo "$0: PID file was not created" ++ exit 1 ++fi ++ ++pid="$(cat data-7E.pid)" ++ ++# Kill the nbdkit process on exit. ++cleanup () ++{ ++ status=$? ++ trap '' INT QUIT TERM EXIT ERR ++ echo $0: cleanup: exit code $status ++ ++ kill $pid ++ rm -f $files ++ ++ exit $status ++} ++trap cleanup INT QUIT TERM EXIT ERR ++ ++# Since we're reading the empty first partition, any read returns zeroes. ++qemu-io -r -f raw 'nbd+unix://?socket=data-7E.sock' \ ++ -c 'r -v 498 16' | grep -E '^[[:xdigit:]]+:' > data-7E.out ++if [ "$(cat data-7E.out)" != "000001f2: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................" ] ++then ++ echo "$0: unexpected pattern:" ++ cat data-7E.out ++ exit 1 ++fi ++ ++# The cleanup() function is called implicitly on exit. +-- +2.18.0 + diff --git a/nbdkit.spec b/nbdkit.spec index 38da7a0..720845f 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -32,7 +32,7 @@ Name: nbdkit Version: 1.5.10 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NBD server License: BSD @@ -46,6 +46,11 @@ Source2: libguestfs.keyring %endif Patch1: 0001-common-sparse-Fix-include-directory-for-nbdkit-plugi.patch +Patch2: 0002-data-memory-Small-refinements-to-the-man-pages.patch +Patch3: 0003-memory-Document-how-to-preload-disk-images-into-the-.patch +Patch4: 0004-data-Fix-this-plugin-to-work-with-64-bit-offsets.patch +Patch5: 0005-data-Permit-whitespace-at-the-end-of-the-data-string.patch +Patch6: 0006-data-Add-example-of-partitioned-7-EB-disk-and-test.patch %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool @@ -952,9 +957,9 @@ popd %changelog -* Mon Aug 27 2018 Richard W.M. Jones - 1.5.10-2 +* Mon Aug 27 2018 Richard W.M. Jones - 1.5.10-3 - New upstream version 1.5.10. -- Add upstream patch after 1.5.10 to fix build. +- Add upstream patches after 1.5.10. * Sun Aug 26 2018 Richard W.M. Jones - 1.5.9-2 - New upstream version 1.5.9.