Rebase to new stable branch version 1.30.5
resolves: rhbz#2059289
Suppress excess messages from nbdkit-nbd-plugin
resolves: rhbz#2083498
Suppress incorrect VDDK error when converting guests from vCenter
resolves: rhbz#2083617
Backport new LUKS filter from 1.32.
Add new Python binding for nbdkit_parse_size from 1.32
Cherry-picked from Fedora:
Add new luks filter.
(Fedora commit 9588e5cbc7
)
This commit is contained in:
parent
c54cb3f9a4
commit
ad784282b6
@ -1,4 +1,4 @@
|
||||
From 04cf7c2aa8aa8ddc446f1571d2f98661ba8a8ca7 Mon Sep 17 00:00:00 2001
|
||||
From 90f0cb8f0495ccf71dd3bed89ccb95c0120b5ef7 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Fri, 15 Apr 2022 12:08:37 +0100
|
||||
Subject: [PATCH] ssh: Allow the remote file to be created
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 160601397d307f70586f1bc70111141855ff68ea Mon Sep 17 00:00:00 2001
|
||||
From af145808cecd18f6f80b672b5988ec1064f9b4a7 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sat, 16 Apr 2022 18:39:13 +0100
|
||||
Subject: [PATCH] readahead: Rewrite this filter so it prefetches using .cache
|
||||
|
@ -1,4 +1,4 @@
|
||||
From a9708db324eb1989680132813da20d5a4c5496a9 Mon Sep 17 00:00:00 2001
|
||||
From 5d679d01417a81a3a981520d2a0332e2370a2536 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 21 Apr 2022 16:14:46 +0100
|
||||
Subject: [PATCH] readahead: Fix test
|
||||
|
1817
0004-New-filter-luks.patch
Normal file
1817
0004-New-filter-luks.patch
Normal file
File diff suppressed because it is too large
Load Diff
96
0005-luks-Disable-filter-with-old-GnuTLS-in-Debian-10.patch
Normal file
96
0005-luks-Disable-filter-with-old-GnuTLS-in-Debian-10.patch
Normal file
@ -0,0 +1,96 @@
|
||||
From ddda62b9faef8cb2cdf4bc4b60bead34f0f143d5 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sun, 8 May 2022 12:13:39 +0100
|
||||
Subject: [PATCH] luks: Disable filter with old GnuTLS in Debian 10
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
On Debian 10:
|
||||
|
||||
luks.c: In function ‘parse_cipher_strings’:
|
||||
luks.c:574:26: error: ‘GNUTLS_CIPHER_AES_128_XTS’ undeclared (first use in this function); did you mean ‘GNUTLS_CIPHER_AES_128_CCM’?
|
||||
h->gnutls_cipher = GNUTLS_CIPHER_AES_128_XTS;
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
GNUTLS_CIPHER_AES_128_CCM
|
||||
luks.c:574:26: note: each undeclared identifier is reported only once for each function it appears in
|
||||
luks.c:577:26: error: ‘GNUTLS_CIPHER_AES_256_XTS’ undeclared (first use in this function); did you mean ‘GNUTLS_CIPHER_AES_256_CCM’?
|
||||
h->gnutls_cipher = GNUTLS_CIPHER_AES_256_XTS;
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
GNUTLS_CIPHER_AES_256_CCM
|
||||
luks.c: In function ‘try_passphrase_in_keyslot’:
|
||||
luks.c:728:7: error: implicit declaration of function ‘gnutls_pbkdf2’; did you mean ‘gnutls_prf’? [-Werror=implicit-function-declaration]
|
||||
r = gnutls_pbkdf2 (h->hash_alg, &key, &salt, ks->password_iterations,
|
||||
^~~~~~~~~~~~~
|
||||
gnutls_prf
|
||||
|
||||
Because gnutls_pbkdf2 is missing there's no chance of making this
|
||||
filter work on this platform so it's best to compile it out.
|
||||
|
||||
Fixes: commit 468919dce6c5eb57503eacac0f67e5dd87c58e6c
|
||||
(cherry picked from commit f9f67e483f4aad19ad6101163d32562f13504ca7)
|
||||
---
|
||||
configure.ac | 7 +++++--
|
||||
filters/luks/Makefile.am | 2 +-
|
||||
tests/Makefile.am | 2 +-
|
||||
3 files changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 2349b49e..05db668e 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -636,11 +636,14 @@ AS_IF([test "x$GNUTLS_LIBS" != "x"],[
|
||||
gnutls_certificate_set_known_dh_params \
|
||||
gnutls_group_get \
|
||||
gnutls_group_get_name \
|
||||
+ gnutls_pbkdf2 \
|
||||
gnutls_session_set_verify_cert \
|
||||
gnutls_srp_server_get_username \
|
||||
])
|
||||
LIBS="$old_LIBS"
|
||||
])
|
||||
+AM_CONDITIONAL([HAVE_GNUTLS_PBKDF2],
|
||||
+ [test "x$GNUTLS_LIBS" != "x" && test "x$ac_cv_func_gnutls_pbkdf2" = xyes])
|
||||
|
||||
AC_ARG_ENABLE([linuxdisk],
|
||||
[AS_HELP_STRING([--disable-linuxdisk],
|
||||
@@ -1498,8 +1501,8 @@ feature "ext2 ................................... " \
|
||||
test "x$HAVE_EXT2_TRUE" = "x"
|
||||
feature "gzip ................................... " \
|
||||
test "x$HAVE_ZLIB_TRUE" = "x"
|
||||
-feature "LUKS ................................... " \
|
||||
- test "x$HAVE_GNUTLS_TRUE" != "x"
|
||||
+feature "luks ................................... " \
|
||||
+ test "x$HAVE_GNUTLS_PBKDF2_TRUE" = "x"
|
||||
feature "xz ..................................... " \
|
||||
test "x$HAVE_LIBLZMA_TRUE" = "x"
|
||||
|
||||
diff --git a/filters/luks/Makefile.am b/filters/luks/Makefile.am
|
||||
index 30089621..622e5c3d 100644
|
||||
--- a/filters/luks/Makefile.am
|
||||
+++ b/filters/luks/Makefile.am
|
||||
@@ -33,7 +33,7 @@ include $(top_srcdir)/common-rules.mk
|
||||
|
||||
EXTRA_DIST = nbdkit-luks-filter.pod
|
||||
|
||||
-if HAVE_GNUTLS
|
||||
+if HAVE_GNUTLS_PBKDF2
|
||||
|
||||
filter_LTLIBRARIES = nbdkit-luks-filter.la
|
||||
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index fa66a112..ffeef097 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -1591,7 +1591,7 @@ EXTRA_DIST += \
|
||||
$(NULL)
|
||||
|
||||
# luks filter test.
|
||||
-if HAVE_GNUTLS
|
||||
+if HAVE_GNUTLS_PBKDF2
|
||||
TESTS += \
|
||||
test-luks-info.sh \
|
||||
test-luks-copy.sh \
|
||||
--
|
||||
2.31.1
|
||||
|
71
0006-luks-Various-fixes-for-Clang.patch
Normal file
71
0006-luks-Various-fixes-for-Clang.patch
Normal file
@ -0,0 +1,71 @@
|
||||
From 95f27197a7ea2d0fb0f19162152d0d72eeead752 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sun, 8 May 2022 12:30:09 +0100
|
||||
Subject: [PATCH] luks: Various fixes for Clang
|
||||
|
||||
With Clang:
|
||||
|
||||
luks.c:728:25: error: implicit conversion from enumeration type 'gnutls_digest_algorithm_t' to different enumeration type 'gnutls_mac_algorithm_t' [-Werror,-Wenum-conversion]
|
||||
r = gnutls_pbkdf2 (h->hash_alg, &key, &salt, ks->password_iterations,
|
||||
~~~~~~~~~~~~~ ~~~^~~~~~~~
|
||||
luks.c:764:25: error: implicit conversion from enumeration type 'gnutls_digest_algorithm_t' to different enumeration type 'gnutls_mac_algorithm_t' [-Werror,-Wenum-conversion]
|
||||
r = gnutls_pbkdf2 (h->hash_alg, &mkey, &msalt,
|
||||
~~~~~~~~~~~~~ ~~~^~~~~~~~
|
||||
luks.c:886:35: error: result of comparison of constant 18446744073709551615 with expression of type 'uint32_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
|
||||
if (ks->password_iterations > ULONG_MAX) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~
|
||||
|
||||
Fixes: commit 468919dce6c5eb57503eacac0f67e5dd87c58e6c
|
||||
(cherry picked from commit 87d488ede9101a2effc71cd1851bf4a4caa521d2)
|
||||
---
|
||||
filters/luks/luks.c | 13 ++++++-------
|
||||
1 file changed, 6 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/filters/luks/luks.c b/filters/luks/luks.c
|
||||
index 706a9bd2..cc619698 100644
|
||||
--- a/filters/luks/luks.c
|
||||
+++ b/filters/luks/luks.c
|
||||
@@ -693,6 +693,10 @@ key_material_length_in_sectors (struct handle *h, size_t i)
|
||||
static int
|
||||
try_passphrase_in_keyslot (nbdkit_next *next, struct handle *h, size_t i)
|
||||
{
|
||||
+ /* I believe this is supposed to be safe, looking at the GnuTLS
|
||||
+ * header file.
|
||||
+ */
|
||||
+ const gnutls_mac_algorithm_t mac = (gnutls_mac_algorithm_t) h->hash_alg;
|
||||
struct luks_keyslot *ks = &h->phdr.keyslot[i];
|
||||
size_t split_key_len;
|
||||
CLEANUP_FREE uint8_t *split_key = NULL;
|
||||
@@ -725,7 +729,7 @@ try_passphrase_in_keyslot (nbdkit_next *next, struct handle *h, size_t i)
|
||||
}
|
||||
|
||||
/* Hash the passphrase to make a possible masterkey. */
|
||||
- r = gnutls_pbkdf2 (h->hash_alg, &key, &salt, ks->password_iterations,
|
||||
+ r = gnutls_pbkdf2 (mac, &key, &salt, ks->password_iterations,
|
||||
masterkey, h->phdr.master_key_len);
|
||||
if (r != 0) {
|
||||
nbdkit_error ("gnutls_pbkdf2: %s", gnutls_strerror (r));
|
||||
@@ -761,7 +765,7 @@ try_passphrase_in_keyslot (nbdkit_next *next, struct handle *h, size_t i)
|
||||
/* Check if the masterkey is correct by comparing hash of the
|
||||
* masterkey with LUKS header.
|
||||
*/
|
||||
- r = gnutls_pbkdf2 (h->hash_alg, &mkey, &msalt,
|
||||
+ r = gnutls_pbkdf2 (mac, &mkey, &msalt,
|
||||
h->phdr.master_key_digest_iterations,
|
||||
key_digest, LUKS_DIGESTSIZE);
|
||||
if (r != 0) {
|
||||
@@ -883,11 +887,6 @@ luks_prepare (nbdkit_next *next, void *handle, int readonly)
|
||||
"points beyond the end of the disk", i);
|
||||
return -1;
|
||||
}
|
||||
- if (ks->password_iterations > ULONG_MAX) {
|
||||
- nbdkit_error ("bad LUKSv1 header: key slot %zu "
|
||||
- "iterations too large", i);
|
||||
- return -1;
|
||||
- }
|
||||
/*FALLTHROUGH*/
|
||||
case LUKS_KEY_DISABLED:
|
||||
break;
|
||||
--
|
||||
2.31.1
|
||||
|
43
0007-luks-Link-with-libcompat-on-Windows.patch
Normal file
43
0007-luks-Link-with-libcompat-on-Windows.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From 6c052a340d7452feae84845965fdc99542da2404 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sun, 8 May 2022 12:38:00 +0100
|
||||
Subject: [PATCH] luks: Link with libcompat on Windows
|
||||
|
||||
/usr/lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: ../../common/utils/.libs/libutils.a(libutils_la-full-rw.o): in function `full_pread':
|
||||
/builds/nbdkit/nbdkit/common/utils/full-rw.c:53: undefined reference to `pread'
|
||||
/usr/lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: ../../common/utils/.libs/libutils.a(libutils_la-full-rw.o): in function `full_pwrite':
|
||||
/builds/nbdkit/nbdkit/common/utils/full-rw.c:76: undefined reference to `pwrite'
|
||||
/usr/lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: ../../common/utils/.libs/libutils.a(libutils_la-vector.o): in function `generic_vector_reserve_page_aligned':
|
||||
/builds/nbdkit/nbdkit/common/utils/vector.c:112: undefined reference to `sysconf'
|
||||
/usr/lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: /builds/nbdkit/nbdkit/common/utils/vector.c:134: undefined reference to `posix_memalign'
|
||||
collect2: error: ld returned 1 exit status
|
||||
|
||||
Fixes: commit 468919dce6c5eb57503eacac0f67e5dd87c58e6c
|
||||
(cherry picked from commit 4a28c4c46aedf270929a62a1c5ecf2c1129cd456)
|
||||
---
|
||||
filters/luks/Makefile.am | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/filters/luks/Makefile.am b/filters/luks/Makefile.am
|
||||
index 622e5c3d..2688f696 100644
|
||||
--- a/filters/luks/Makefile.am
|
||||
+++ b/filters/luks/Makefile.am
|
||||
@@ -45,6 +45,7 @@ nbdkit_luks_filter_la_SOURCES = \
|
||||
nbdkit_luks_filter_la_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/common/include \
|
||||
+ -I$(top_srcdir)/common/replacements \
|
||||
-I$(top_srcdir)/common/utils \
|
||||
$(NULL)
|
||||
nbdkit_luks_filter_la_CFLAGS = \
|
||||
@@ -53,6 +54,7 @@ nbdkit_luks_filter_la_CFLAGS = \
|
||||
$(NULL)
|
||||
nbdkit_luks_filter_la_LIBADD = \
|
||||
$(top_builddir)/common/utils/libutils.la \
|
||||
+ $(top_builddir)/common/replacements/libcompat.la \
|
||||
$(IMPORT_LIBRARY_ON_WINDOWS) \
|
||||
$(GNUTLS_LIBS) \
|
||||
$(NULL)
|
||||
--
|
||||
2.31.1
|
||||
|
2096
0008-luks-Refactor-the-filter.patch
Normal file
2096
0008-luks-Refactor-the-filter.patch
Normal file
File diff suppressed because it is too large
Load Diff
101
0009-tests-luks-Reduce-time-taken-to-run-these-tests.patch
Normal file
101
0009-tests-luks-Reduce-time-taken-to-run-these-tests.patch
Normal file
@ -0,0 +1,101 @@
|
||||
From 64ce47cc59c062cf64cb7bf7a9861f4c5d767514 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Sun, 8 May 2022 18:05:45 +0100
|
||||
Subject: [PATCH] tests: luks: Reduce time taken to run these tests
|
||||
|
||||
Under valgrind they ran very slowly. Turns out valgrinding over
|
||||
GnuTLS hashing code is not pretty. About half the time seems to be
|
||||
taken opening the keyslot, and the rest copying the data.
|
||||
|
||||
This change reduces the time (under valgrind) from 15 minutes 45 seconds
|
||||
to about 6 mins 30 seconds.
|
||||
|
||||
(cherry picked from commit 7320ae5dba476171a024ca44b889b3474302dc40)
|
||||
---
|
||||
tests/test-luks-copy.sh | 18 +++++++++---------
|
||||
tests/test-luks-info.sh | 6 +++---
|
||||
2 files changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/tests/test-luks-copy.sh b/tests/test-luks-copy.sh
|
||||
index 99f300d0..01801811 100755
|
||||
--- a/tests/test-luks-copy.sh
|
||||
+++ b/tests/test-luks-copy.sh
|
||||
@@ -60,8 +60,8 @@ rm -f $encrypt_disk $plain_disk $pid $sock
|
||||
qemu-img create -f luks \
|
||||
--object secret,data=123456,id=sec0 \
|
||||
-o key-secret=sec0 \
|
||||
- $encrypt_disk 10M
|
||||
-truncate -s 10M $plain_disk
|
||||
+ $encrypt_disk 1M
|
||||
+truncate -s 1M $plain_disk
|
||||
qemu-img convert --target-image-opts -n \
|
||||
--object secret,data=123456,id=sec0 \
|
||||
$plain_disk \
|
||||
@@ -74,11 +74,11 @@ start_nbdkit -P $pid -U $sock \
|
||||
uri="nbd+unix:///?socket=$sock"
|
||||
|
||||
# Copy the whole disk out. It should be empty.
|
||||
-nbdcopy "$uri" $plain_disk
|
||||
+nbdcopy -C 1 "$uri" $plain_disk
|
||||
|
||||
if [ "$(hexdump -C $plain_disk)" != '00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
*
|
||||
-00a00000' ]; then
|
||||
+00100000' ]; then
|
||||
echo "$0: expected plaintext disk to be empty"
|
||||
exit 1
|
||||
fi
|
||||
@@ -88,14 +88,14 @@ fi
|
||||
nbdsh -u "$uri" \
|
||||
-c 'h.pwrite(b"1"*65536, 0)' \
|
||||
-c 'h.pwrite(b"2"*65536, 128*1024)' \
|
||||
- -c 'h.pwrite(b"3"*65536, 9*1024*1024)' \
|
||||
+ -c 'h.pwrite(b"3"*65536, 900*1024)' \
|
||||
-c 'buf = h.pread(65536, 0)' \
|
||||
-c 'assert buf == b"1"*65536' \
|
||||
-c 'buf = h.pread(65536, 65536)' \
|
||||
-c 'assert buf == bytearray(65536)' \
|
||||
-c 'buf = h.pread(65536, 128*1024)' \
|
||||
-c 'assert buf == b"2"*65536' \
|
||||
- -c 'buf = h.pread(65536, 9*1024*1024)' \
|
||||
+ -c 'buf = h.pread(65536, 900*1024)' \
|
||||
-c 'assert buf == b"3"*65536' \
|
||||
-c 'h.flush()'
|
||||
|
||||
@@ -115,11 +115,11 @@ if [ "$(hexdump -C $plain_disk)" != '00000000 31 31 31 31 31 31 31 31 31 31 31
|
||||
*
|
||||
00030000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
*
|
||||
-00900000 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 |3333333333333333|
|
||||
+000e1000 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 |3333333333333333|
|
||||
*
|
||||
-00910000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
+000f1000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
*
|
||||
-00a00000' ]; then
|
||||
+00100000' ]; then
|
||||
echo "$0: unexpected content"
|
||||
exit 1
|
||||
fi
|
||||
diff --git a/tests/test-luks-info.sh b/tests/test-luks-info.sh
|
||||
index 3eff657b..ef141ecd 100755
|
||||
--- a/tests/test-luks-info.sh
|
||||
+++ b/tests/test-luks-info.sh
|
||||
@@ -46,11 +46,11 @@ rm -f $disk $info
|
||||
qemu-img create -f luks \
|
||||
--object secret,data=123456,id=sec0 \
|
||||
-o key-secret=sec0 \
|
||||
- $disk 10M
|
||||
+ $disk 1M
|
||||
|
||||
nbdkit -U - file $disk --filter=luks passphrase=123456 \
|
||||
--run 'nbdinfo $uri' > $info
|
||||
cat $info
|
||||
|
||||
-# Check the size is 10M (so it doesn't include the LUKS header).
|
||||
-grep "10485760" $info
|
||||
+# Check the size is 1M (so it doesn't include the LUKS header).
|
||||
+grep "1048576" $info
|
||||
--
|
||||
2.31.1
|
||||
|
112
0010-Add-nbdkit.parse_size-Python-function.patch
Normal file
112
0010-Add-nbdkit.parse_size-Python-function.patch
Normal file
@ -0,0 +1,112 @@
|
||||
From e19ef7726379acf90dcff248e90813898266d2b4 Mon Sep 17 00:00:00 2001
|
||||
From: Nikolaus Rath <Nikolaus@rath.org>
|
||||
Date: Mon, 9 May 2022 10:04:30 +0100
|
||||
Subject: [PATCH] Add nbdkit.parse_size() Python function.
|
||||
|
||||
This enables Python plugins to parse sizes the same way as C plugins.
|
||||
|
||||
I'm not sure about the best way to test this - input is appreciated.
|
||||
|
||||
I'm not too happy with the way this code is tested. It workes, but putting the tests into
|
||||
test-python-plugin.py feels misplaced: this file is intended to support the unit tests in
|
||||
test_python.py, not run its own unit tests.
|
||||
|
||||
(cherry picked from commit 1b7d72542be68e254c1ef86ecb1a82b05c78ff63)
|
||||
---
|
||||
plugins/python/modfunctions.c | 21 +++++++++++++++++++++
|
||||
plugins/python/nbdkit-python-plugin.pod | 5 +++++
|
||||
tests/test-python-plugin.py | 19 +++++++++++++++++++
|
||||
3 files changed, 45 insertions(+)
|
||||
|
||||
diff --git a/plugins/python/modfunctions.c b/plugins/python/modfunctions.c
|
||||
index fffbaab2..46b0c904 100644
|
||||
--- a/plugins/python/modfunctions.c
|
||||
+++ b/plugins/python/modfunctions.c
|
||||
@@ -93,11 +93,32 @@ do_shutdown (PyObject *self, PyObject *args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
+/* nbdkit.parse_size */
|
||||
+static PyObject *
|
||||
+parse_size (PyObject *self, PyObject *args)
|
||||
+{
|
||||
+ const char *s;
|
||||
+ if (!PyArg_ParseTuple (args, "s", &s)) {
|
||||
+ PyErr_SetString (PyExc_TypeError, "Expected string, got something else");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ int64_t size = nbdkit_parse_size(s);
|
||||
+ if (size == -1) {
|
||||
+ PyErr_SetString (PyExc_ValueError, "Unable to parse string as size");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return PyLong_FromSize_t((size_t)size);
|
||||
+}
|
||||
+
|
||||
static PyMethodDef NbdkitMethods[] = {
|
||||
{ "debug", debug, METH_VARARGS,
|
||||
"Print a debug message" },
|
||||
{ "export_name", export_name, METH_VARARGS,
|
||||
"Return the optional export name negotiated with the client" },
|
||||
+ { "parse_size", parse_size, METH_VARARGS,
|
||||
+ "Parse human-readable size strings into bytes" },
|
||||
{ "set_error", set_error, METH_VARARGS,
|
||||
"Store an errno value prior to throwing an exception" },
|
||||
{ "shutdown", do_shutdown, METH_VARARGS,
|
||||
diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
|
||||
index 051b0237..ccc9406f 100644
|
||||
--- a/plugins/python/nbdkit-python-plugin.pod
|
||||
+++ b/plugins/python/nbdkit-python-plugin.pod
|
||||
@@ -131,6 +131,11 @@ Record C<err> as the reason you are about to throw an exception. C<err>
|
||||
should correspond to usual errno values, where it may help to
|
||||
C<import errno>.
|
||||
|
||||
+=head3 C<nbdkit.parse_size(str)>
|
||||
+
|
||||
+Parse a string (such as "100M") into a size in bytes. Wraps the
|
||||
+C<nbdkit_parse_size()> C function.
|
||||
+
|
||||
=head3 C<nbdkit.shutdown()>
|
||||
|
||||
Request asynchronous server shutdown.
|
||||
diff --git a/tests/test-python-plugin.py b/tests/test-python-plugin.py
|
||||
index 0b34d532..d4f379fc 100644
|
||||
--- a/tests/test-python-plugin.py
|
||||
+++ b/tests/test-python-plugin.py
|
||||
@@ -34,12 +34,31 @@
|
||||
import nbdkit
|
||||
import pickle
|
||||
import base64
|
||||
+import unittest
|
||||
|
||||
API_VERSION = 2
|
||||
|
||||
cfg = {}
|
||||
|
||||
|
||||
+# Not nice, but there doesn't seem to be a better way of putting this
|
||||
+class TestAPI(unittest.TestCase):
|
||||
+
|
||||
+ def test_parse_size(self):
|
||||
+ self.assertEqual(nbdkit.parse_size('511'), 511)
|
||||
+ self.assertEqual(nbdkit.parse_size('7k'), 7*1024)
|
||||
+ self.assertEqual(nbdkit.parse_size('17M'), 17*1024*1024)
|
||||
+
|
||||
+ with self.assertRaises(TypeError):
|
||||
+ nbdkit.parse_size(17)
|
||||
+
|
||||
+ with self.assertRaises(ValueError):
|
||||
+ nbdkit.parse_size('foo')
|
||||
+
|
||||
+
|
||||
+TestAPI().test_parse_size()
|
||||
+
|
||||
+
|
||||
def config(k, v):
|
||||
global cfg
|
||||
if k == "cfg":
|
||||
--
|
||||
2.31.1
|
||||
|
26
nbdkit.spec
26
nbdkit.spec
@ -52,7 +52,7 @@ ExclusiveArch: x86_64
|
||||
%global source_directory 1.30-stable
|
||||
|
||||
Name: nbdkit
|
||||
Version: 1.30.4
|
||||
Version: 1.30.5
|
||||
Release: 1%{?dist}
|
||||
Summary: NBD server
|
||||
|
||||
@ -81,6 +81,13 @@ Source3: copy-patches.sh
|
||||
Patch0001: 0001-ssh-Allow-the-remote-file-to-be-created.patch
|
||||
Patch0002: 0002-readahead-Rewrite-this-filter-so-it-prefetches-using.patch
|
||||
Patch0003: 0003-readahead-Fix-test.patch
|
||||
Patch0004: 0004-New-filter-luks.patch
|
||||
Patch0005: 0005-luks-Disable-filter-with-old-GnuTLS-in-Debian-10.patch
|
||||
Patch0006: 0006-luks-Various-fixes-for-Clang.patch
|
||||
Patch0007: 0007-luks-Link-with-libcompat-on-Windows.patch
|
||||
Patch0008: 0008-luks-Refactor-the-filter.patch
|
||||
Patch0009: 0009-tests-luks-Reduce-time-taken-to-run-these-tests.patch
|
||||
Patch0010: 0010-Add-nbdkit.parse_size-Python-function.patch
|
||||
|
||||
# For automatic RPM Provides generation.
|
||||
# See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html
|
||||
@ -550,6 +557,8 @@ nbdkit-limit-filter Limit nr clients that can connect concurrently.
|
||||
|
||||
nbdkit-log-filter Log all transactions to a file.
|
||||
|
||||
nbdkit-luks-filter Read and write LUKS-encrypted disks.
|
||||
|
||||
nbdkit-multi-conn-filter Enable, emulate or disable multi-conn.
|
||||
|
||||
nbdkit-nocache-filter Disable cache requests in the underlying plugin.
|
||||
@ -1048,6 +1057,7 @@ export LIBGUESTFS_TRACE=1
|
||||
%{_libdir}/%{name}/filters/nbdkit-ip-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-limit-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-log-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-luks-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-multi-conn-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-nocache-filter.so
|
||||
%{_libdir}/%{name}/filters/nbdkit-noextents-filter.so
|
||||
@ -1083,6 +1093,7 @@ export LIBGUESTFS_TRACE=1
|
||||
%{_mandir}/man1/nbdkit-ip-filter.1*
|
||||
%{_mandir}/man1/nbdkit-limit-filter.1*
|
||||
%{_mandir}/man1/nbdkit-log-filter.1*
|
||||
%{_mandir}/man1/nbdkit-luks-filter.1*
|
||||
%{_mandir}/man1/nbdkit-multi-conn-filter.1*
|
||||
%{_mandir}/man1/nbdkit-nocache-filter.1*
|
||||
%{_mandir}/man1/nbdkit-noextents-filter.1*
|
||||
@ -1180,8 +1191,8 @@ export LIBGUESTFS_TRACE=1
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Apr 26 2022 Richard W.M. Jones <rjones@redhat.com> - 1.30.4-1
|
||||
- Rebase to new stable branch version 1.30.4
|
||||
* Tue Apr 26 2022 Richard W.M. Jones <rjones@redhat.com> - 1.30.5-1
|
||||
- Rebase to new stable branch version 1.30.5
|
||||
resolves: rhbz#2059289
|
||||
- Add automatic provides generator and subpackage nbdkit-srpm-macros
|
||||
resolves: rhbz#2059291
|
||||
@ -1189,9 +1200,16 @@ export LIBGUESTFS_TRACE=1
|
||||
- Fix license of bash-completion subpackage
|
||||
- vddk: Fix use of uninitialized memory when computing block size
|
||||
resolves: rhbz#2066655
|
||||
- Skip vsock tests unless the vsock_loopback module is loaded (2069558)
|
||||
- Skip vsock tests unless the vsock_loopback module is loaded
|
||||
resolves: rhbz#2069558
|
||||
- Add support for ssh create remote file.
|
||||
- Suppress excess messages from nbdkit-nbd-plugin
|
||||
resolves: rhbz#2083498
|
||||
- Suppress incorrect VDDK error when converting guests from vCenter
|
||||
resolves: rhbz#2083617
|
||||
- Backport new readahead filter from 1.32.
|
||||
- Backport new LUKS filter from 1.32.
|
||||
- Add new Python binding for nbdkit_parse_size from 1.32
|
||||
|
||||
* Mon Jan 24 2022 Richard W.M. Jones <rjones@redhat.com> - 1.28.5-1
|
||||
- Rebase to new stable branch version 1.28.5
|
||||
|
4
sources
4
sources
@ -1,2 +1,2 @@
|
||||
SHA512 (nbdkit-1.30.4.tar.gz) = b2db6cde29b04fc73831a5f062b7b5d0a4ed2c3785ccefe81add4bc89cd62d5705b904922f53ea1fd4b0987c9aa2a0ef34fc58eefa804b37d424a44112fbf1b1
|
||||
SHA512 (nbdkit-1.30.4.tar.gz.sig) = ed8a60214274d88f418656b1b50d9eb5b73aa0ff18e36446cf21a6fe2c07ca72311fd745c5d99f94cb3676dba2ee3a768ab08a05cf9d0d24d8156c43118d57d6
|
||||
SHA512 (nbdkit-1.30.5.tar.gz) = 033f06a23f7f227acb8516994582c94033a35d11ff8d7db8ca310b73cf591ea1a4833dbfbaf58e653556a1bcf30cbca21494b7f9e61a1a8cafd566993b24a799
|
||||
SHA512 (nbdkit-1.30.5.tar.gz.sig) = c8e342ff168b3308b888658f2958a2ccfd2e2b37664f65d3a71feb495085bd60834b4142103c6cf51e83b5d08f2815ab392b5afe5077b9a8fbfee9218db9bdf1
|
||||
|
Loading…
Reference in New Issue
Block a user