236 lines
8.6 KiB
Diff
236 lines
8.6 KiB
Diff
From 2c548ffcf2745f23a504d646f64a20c984bc2e32 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
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<MTIz>), 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<data>
|
|
string (see L</DATA FORMAT>).
|
|
|
|
+=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 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x76 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
|
|
|