From 1c44b857a0ff592904181c176cc526cd34aa344c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 31 Jul 2019 10:06:34 +0100 Subject: [PATCH] Add upstream patch to deal with qemu-img 4.1 output change. --- ...commodate-qemu-img-4.1-output-change.patch | 146 ++++++++++++++++++ nbdkit.spec | 8 +- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 0001-tests-Accommodate-qemu-img-4.1-output-change.patch diff --git a/0001-tests-Accommodate-qemu-img-4.1-output-change.patch b/0001-tests-Accommodate-qemu-img-4.1-output-change.patch new file mode 100644 index 0000000..7b02f79 --- /dev/null +++ b/0001-tests-Accommodate-qemu-img-4.1-output-change.patch @@ -0,0 +1,146 @@ +From 902f2203f0bc38de25dffd885ca837fe59e4a3fb Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Tue, 30 Jul 2019 15:58:06 -0500 +Subject: [PATCH] tests: Accommodate qemu-img 4.1 output change + +Where qemu-img 4.0 used to say 'virtual size: 100M', the 4.1 release +now says 'virtual size: 100 MiB'. Similarly, '5.0G' turned into '5 +GiB'. But rather than worry about potential future changes to the +human-readable output, we can just use --output=json (at which point +we no longer even have to force qemu-img to the C locale, which we +were not even doing consistently). It might be slightly more robust +to find our specific information using jq, but for now a grep of the +output json is still reliable enough for our needs. + +If the '\b' is a problem on BSD, we could use '([, ]|$)' instead. Or +that's where jq would make it easier to parse off a given number +without worrying about what comes after the number. + +Signed-off-by: Eric Blake +--- + tests/test-ip.sh | 10 ++++++---- + tests/test-nbd-tls-psk.sh | 6 +++--- + tests/test-nbd-tls.sh | 6 +++--- + tests/test-tls-psk.sh | 7 +++---- + tests/test-tls.sh | 7 +++---- + tests/test-truncate3.sh | 4 ++-- + 6 files changed, 20 insertions(+), 20 deletions(-) + +diff --git a/tests/test-ip.sh b/tests/test-ip.sh +index 636d3d3..a0f1862 100755 +--- a/tests/test-ip.sh ++++ b/tests/test-ip.sh +@@ -57,15 +57,17 @@ kill -s 0 $pid + # Check we can connect over the IPv4 loopback interface. + ipv4_lo="$(ip -o -4 addr show scope host)" + if test -n "$ipv4_lo"; then +- qemu-img info --image-opts "file.driver=nbd,file.host=127.0.0.1,file.port=$port" > ipv4.out ++ qemu-img info --output=json \ ++ --image-opts "file.driver=nbd,file.host=127.0.0.1,file.port=$port" > ipv4.out + cat ipv4.out +- grep -sq "^virtual size: 100M" ipv4.out ++ grep -sq '"virtual-size": *104857600\b' ipv4.out + fi + + # Check we can connect over the IPv6 loopback interface. + ipv6_lo="$(ip -o -6 addr show scope host)" + if test -n "$ipv6_lo"; then +- qemu-img info --image-opts "file.driver=nbd,file.host=::1,file.port=$port" > ipv6.out ++ qemu-img info --output=json \ ++ --image-opts "file.driver=nbd,file.host=::1,file.port=$port" > ipv6.out + cat ipv6.out +- grep -sq "^virtual size: 100M" ipv6.out ++ grep -sq '"virtual-size": *104857600\b' ipv6.out + fi +diff --git a/tests/test-nbd-tls-psk.sh b/tests/test-nbd-tls-psk.sh +index d0bbc46..82822d1 100755 +--- a/tests/test-nbd-tls-psk.sh ++++ b/tests/test-nbd-tls-psk.sh +@@ -73,9 +73,9 @@ LIBNBD_DEBUG=1 start_nbdkit -P "$pid2" -U "$sock2" --tls=off \ + nbd tls=require tls-psk=keys.psk tls-username=qemu socket="$sock1" + + # Run unencrypted client +-LANG=C qemu-img info -f raw "nbd+unix:///?socket=$sock2" > nbd-tls-psk.out ++qemu-img info --output=json -f raw "nbd+unix:///?socket=$sock2" > nbd-tls-psk.out + + cat nbd-tls-psk.out + +-grep -sq "^file format: raw" nbd-tls-psk.out +-grep -sq "^virtual size: 100M" nbd-tls-psk.out ++grep -sq '"format": *"raw"' nbd-tls-psk.out ++grep -sq '"virtual-size": *104857600\b' nbd-tls-psk.out +diff --git a/tests/test-nbd-tls.sh b/tests/test-nbd-tls.sh +index af824d2..c4f4fac 100755 +--- a/tests/test-nbd-tls.sh ++++ b/tests/test-nbd-tls.sh +@@ -74,9 +74,9 @@ LIBNBD_DEBUG=1 start_nbdkit -P "$pid2" -U "$sock2" --tls=off \ + nbd tls=require tls-certificates="$pkidir" socket="$sock1" + + # Run unencrypted client +-LANG=C qemu-img info -f raw "nbd+unix:///?socket=$sock2" > nbd-tls.out ++qemu-img info --output=json -f raw "nbd+unix:///?socket=$sock2" > nbd-tls.out + + cat nbd-tls.out + +-grep -sq "^file format: raw" nbd-tls.out +-grep -sq "^virtual size: 100M" nbd-tls.out ++grep -sq '"format": *"raw"' nbd-tls.out ++grep -sq '"virtual-size": *104857600\b' nbd-tls.out +diff --git a/tests/test-tls-psk.sh b/tests/test-tls-psk.sh +index 393f589..a4ecb60 100755 +--- a/tests/test-tls-psk.sh ++++ b/tests/test-tls-psk.sh +@@ -72,12 +72,11 @@ start_nbdkit -P tls-psk.pid -p $port -n \ + --tls=require --tls-psk=keys.psk example1 + + # Run qemu-img against the server. +-LANG=C \ +-qemu-img info \ ++qemu-img info --output=json \ + --object "tls-creds-psk,id=tls0,endpoint=client,dir=$PWD" \ + --image-opts "file.driver=nbd,file.host=localhost,file.port=$port,file.tls-creds=tls0" > tls-psk.out + + cat tls-psk.out + +-grep -sq "^file format: raw" tls-psk.out +-grep -sq "^virtual size: 100M" tls-psk.out ++grep -sq '"format": *"raw"' tls-psk.out ++grep -sq '"virtual-size": *104857600\b' tls-psk.out +diff --git a/tests/test-tls.sh b/tests/test-tls.sh +index 70d40ae..2718e55 100755 +--- a/tests/test-tls.sh ++++ b/tests/test-tls.sh +@@ -65,12 +65,11 @@ start_nbdkit -P tls.pid -p $port -n --tls=require \ + --tls-certificates="$pkidir" example1 + + # Run qemu-img against the server. +-LANG=C \ +-qemu-img info \ ++qemu-img info --output=json \ + --object "tls-creds-x509,id=tls0,endpoint=client,dir=$pkidir" \ + --image-opts "file.driver=nbd,file.host=localhost,file.port=$port,file.tls-creds=tls0" > tls.out + + cat tls.out + +-grep -sq "^file format: raw" tls.out +-grep -sq "^virtual size: 100M" tls.out ++grep -sq '"format": *"raw"' tls.out ++grep -sq '"virtual-size": *104857600\b' tls.out +diff --git a/tests/test-truncate3.sh b/tests/test-truncate3.sh +index 0a7fba8..885d58f 100755 +--- a/tests/test-truncate3.sh ++++ b/tests/test-truncate3.sh +@@ -50,8 +50,8 @@ start_nbdkit -P truncate3.pid -U $sock \ + pattern 5G \ + round-up=512 + +-LANG=C qemu-img info nbd:unix:$sock > truncate3.out +-if ! grep "virtual size: 5.0G" truncate3.out; then ++qemu-img info --output=json nbd:unix:$sock > truncate3.out ++if ! grep '"virtual-size": *5368709120' truncate3.out; then + echo "$0: unexpected output from truncate3 regression test:" + cat truncate3.out + exit 1 +-- +2.22.0 + diff --git a/nbdkit.spec b/nbdkit.spec index 6863ce2..407f46a 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -28,7 +28,7 @@ Name: nbdkit Version: 1.13.7 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NBD server License: BSD @@ -41,6 +41,9 @@ Source1: http://libguestfs.org/download/nbdkit/%{source_directory}/%{name Source2: libguestfs.keyring %endif +# Upstream patch to deal with qemu-img 4.1 output change. +Patch1: 0001-tests-Accommodate-qemu-img-4.1-output-change.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif @@ -839,6 +842,9 @@ make %{?_smp_mflags} check || { %changelog +* Wed Jul 31 2019 Richard W.M. Jones - 1.13.7-2 +- Add upstream patch to deal with qemu-img 4.1 output change. + * Tue Jul 30 2019 Richard W.M. Jones - 1.13.7-1 - New upstream version 1.13.7.