[libnbd PATCH] nbdsh: Add test of handling globals in -c
by Eric Blake
Test that we can script the read of a specific pattern from
nbdkit. Also, test that we can concatenate global functions through
consecutive -c. This test fails if commit d6cbd130 is reverted.
---
sh/Makefile.am | 5 ++++-
sh/test-dump.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
create mode 100755 sh/test-dump.sh
diff --git a/sh/Makefile.am b/sh/Makefile.am
index 2eab987..50cd395 100644
--- a/sh/Makefile.am
+++ b/sh/Makefile.am
@@ -21,6 +21,7 @@ EXTRA_DIST = \
nbdsh.pod \
examples/LICENSE-FOR-EXAMPLES \
examples/hexdump.sh \
+ test-dump.sh \
test-help.sh \
test-version.sh \
$(NULL)
@@ -51,7 +52,9 @@ TESTS = \
if HAVE_NBDKIT
-TESTS +=
+TESTS += \
+ test-dump.sh \
+ $(NULL)
endif HAVE_NBDKIT
diff --git a/sh/test-dump.sh b/sh/test-dump.sh
new file mode 100755
index 0000000..2d4e261
--- /dev/null
+++ b/sh/test-dump.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+# nbd client library in userspace
+# Copyright (C) 2019 Red Hat Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test interaction with nbdkit, and for correct global handling over -c.
+nbdkit --exit-with-parent --version || exit 77
+
+sock=`mktemp -u /tmp/nbdsh.XXXXXX`
+pidfile=test-dump.pid
+trap 'status=$?; rm -f $sock $pidfile; exit $status' INT QUIT TERM EXIT ERR
+nbdkit -v -P $pidfile --exit-with-parent -U $sock pattern size=1m &
+
+# Wait for the pidfile to appear.
+for i in {1..60}; do
+ if test -f "$pidfile"; then
+ break
+ fi
+ sleep 1
+done
+if ! test -f "$pidfile"; then
+ echo "$0: nbdkit PID file $pidfile was not created"
+ exit 1
+fi
+
+nbdsh --connect "nbd+unix://?socket=$sock" \
+ -c '
+def size():
+ return h.get_size()
+' \
+ -c 'assert 1024*1024 == size()' \
+ -c 'assert h.pread(8, 8) == b"\x00\x00\x00\x00\x00\x00\x00\x08"'
--
2.21.0
5 years, 2 months
[p2v PATCH] tests: require virt-v2v for functional tests
by Pino Toscano
virt-v2v is definitely used by the functional tests that run virt-p2v,
so check for it, and require it for running those tests.
Reported by Rich.
---
m4/p2v-tests.m4 | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/m4/p2v-tests.m4 b/m4/p2v-tests.m4
index f679bc4..7de356d 100644
--- a/m4/p2v-tests.m4
+++ b/m4/p2v-tests.m4
@@ -25,11 +25,12 @@ AC_ARG_ENABLE([gnulib-tests],
AM_CONDITIONAL([ENABLE_GNULIB_TESTS],[test "x$ENABLE_GNULIB_TESTS" = "xyes"])
AC_MSG_RESULT([$ENABLE_GNULIB_TESTS])
-dnl Check libguestfs tools (needed for create the test images).
+dnl Check libguestfs tools.
AC_CHECK_PROG([GUESTFISH],[guestfish],[guestfish],[no])
AC_CHECK_PROG([VIRT_BUILDER],[virt-builder],[virt-builder],[no])
+AC_CHECK_PROG([VIRT_V2V],[virt-v2v],[virt-v2v],[no])
AM_CONDITIONAL([HAVE_LIBGUESTFS],
- [test "x$GUESTFISH" != "xno" && test "x$VIRT_BUILDER" != "xno"])
+ [test "x$GUESTFISH" != "xno" && test "x$VIRT_BUILDER" != "xno" && test "x$VIRT_V2V" != "xno"])
dnl Check for valgrind
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
--
2.21.0
5 years, 2 months
[p2v PATCH] Fix FSF address
by Pino Toscano
Adjust license headers to use the current FSF postal address.
Spotted by Rpmlint.
---
launch-virt-p2v | 2 +-
p2v.ks.in | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/launch-virt-p2v b/launch-virt-p2v
index 925aa6d..5e46f42 100755
--- a/launch-virt-p2v
+++ b/launch-virt-p2v
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# This normally runs from systemd which deals with logging.
diff --git a/p2v.ks.in b/p2v.ks.in
index 32f3665..9fa637a 100644
--- a/p2v.ks.in
+++ b/p2v.ks.in
@@ -13,7 +13,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Generated by virt-p2v-make-kickstart __PACKAGE_VERSION_FULL__
--
2.21.0
5 years, 2 months
[PATCH libnbd 1/2] nbd_connect_tcp: Try to return errno from underlying connect(2) call.
by Richard W.M. Jones
When we make a TCP connection we have to make multiple underlying
connect(2) calls, once for each address returned by getaddrinfo.
Unfortunately this meant that we lost the errno from any of these
calls:
$ nbdsh -c 'h.connect_tcp ("localhost", "nbd")'
nbd.Error: nbd_connect_tcp: connect: localhost:nbd: could not connect to remote host
This commit saves the errno from the first failed connect(2):
$ ./run nbdsh -c 'h.connect_tcp ("localhost", "nbd")'
nbd.Error: nbd_connect_tcp: connect: localhost:nbd: could not connect to remote host: Connection refused (ECONNREFUSED)
---
generator/states-connect.c | 12 ++++++++++--
lib/internal.h | 1 +
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/generator/states-connect.c b/generator/states-connect.c
index 9e2e1d4..e9b3582 100644
--- a/generator/states-connect.c
+++ b/generator/states-connect.c
@@ -128,6 +128,8 @@ disable_nagle (int sock)
h->result = NULL;
}
+ h->connect_errno = 0;
+
memset (&h->hints, 0, sizeof h->hints);
h->hints.ai_family = AF_UNSPEC;
h->hints.ai_socktype = SOCK_STREAM;
@@ -160,7 +162,8 @@ disable_nagle (int sock)
* Save errno from most recent connect(2) call. XXX
*/
SET_NEXT_STATE (%^START);
- set_error (0, "connect: %s:%s: could not connect to remote host",
+ set_error (h->connect_errno,
+ "connect: %s:%s: could not connect to remote host",
h->hostname, h->port);
return -1;
}
@@ -182,6 +185,8 @@ disable_nagle (int sock)
if (connect (fd, h->rp->ai_addr, h->rp->ai_addrlen) == -1) {
if (errno != EINPROGRESS) {
+ if (h->connect_errno == 0)
+ h->connect_errno = errno;
SET_NEXT_STATE (%NEXT_ADDRESS);
return 0;
}
@@ -203,8 +208,11 @@ disable_nagle (int sock)
/* This checks the status of the original connect call. */
if (status == 0)
SET_NEXT_STATE (%^MAGIC.START);
- else
+ else {
+ if (h->connect_errno == 0)
+ h->connect_errno = status;
SET_NEXT_STATE (%NEXT_ADDRESS);
+ }
return 0;
CONNECT_TCP.NEXT_ADDRESS:
diff --git a/lib/internal.h b/lib/internal.h
index a48edff..ccaca32 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -188,6 +188,7 @@ struct nbd_handle {
char *hostname, *port;
struct addrinfo hints;
struct addrinfo *result, *rp;
+ int connect_errno;
/* When sending metadata contexts, this is used. */
size_t querynum;
--
2.23.0
5 years, 2 months
[libnbd PATCH] nbdsh: Start adding unit tests
by Eric Blake
Ultimately, I'd like to add a unit test covering our recent fix for
handling globals from consecutive -c, but let's start with a simple
test that --help output is sane. Sanity includes a mention of the man
page for more details (similar to nbdkit --help, although I couldn't
figure out how to make python's argparse output that sentence last).
---
python/nbdsh.py | 3 ++-
sh/Makefile.am | 9 ++++++---
sh/test-help.sh | 32 ++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 4 deletions(-)
create mode 100755 sh/test-help.sh
diff --git a/python/nbdsh.py b/python/nbdsh.py
index 553e632..117c824 100644
--- a/python/nbdsh.py
+++ b/python/nbdsh.py
@@ -23,7 +23,8 @@ def shell():
import nbd
- description = '''Network Block Device (NBD) shell'''
+ description = '''Network Block Device (NBD) shell. Please read the
+ nbdsh(1) manual page for full usage.'''
parser = argparse.ArgumentParser (prog='nbdsh', description=description)
parser.add_argument ('--connect',
help="connect to NBD URI")
diff --git a/sh/Makefile.am b/sh/Makefile.am
index 2e04e46..2e9a047 100644
--- a/sh/Makefile.am
+++ b/sh/Makefile.am
@@ -21,6 +21,7 @@ EXTRA_DIST = \
nbdsh.pod \
examples/LICENSE-FOR-EXAMPLES \
examples/hexdump.sh \
+ test-help.sh \
$(NULL)
if HAVE_PYTHON
@@ -40,8 +41,10 @@ nbdsh.1: nbdsh.pod $(top_builddir)/podwrapper.pl
endif HAVE_POD
-if HAVE_NBDKIT
-
TESTS_ENVIRONMENT = LIBNBD_DEBUG=1
LOG_COMPILER = $(top_builddir)/run
-TESTS =
+TESTS = test-help.sh
+
+if HAVE_NBDKIT
+
+TESTS +=
endif HAVE_NBDKIT
diff --git a/sh/test-help.sh b/sh/test-help.sh
new file mode 100755
index 0000000..6ed1c9c
--- /dev/null
+++ b/sh/test-help.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# nbd client library in userspace
+# Copyright (C) 2019 Red Hat Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test that nbdsh --help looks sane.
+
+fail=0
+output=$(nbdsh --help)
+if [ $? != 0 ]; then
+ echo "$0: unexpected exit status"
+ fail=1
+fi
+if [[ ! ( "$output" =~ "usage:" && "$output" =~ "manual page" ) ]]; then
+ echo "$0: unexpected output"
+ fail=1
+fi
+echo "$output"
+exit $fail
--
2.21.0
5 years, 2 months
[PATCH nbdkit] python: Drop support for Python 2.
by Richard W.M. Jones
This patch proposes to drop support for Python 2 in nbdkit.
Rather than abruptly drop it everywhere, my proposal is that we point
people to nbdkit 1.14 (the current stable version) if they want to
continue with Python 2 plugins, while gently reminding them of the
upcoming Python 2.7 end of life announcement.
Libnbd never supported Python 2. Libguestfs in theory supports
Python 2 but I dropped the bindings from Fedora back in March so it's
basically never tested now. Libvirt also started to prefer Python 3
over Python 2 back in March.
Rich.
5 years, 2 months
[nbdkit PATCH 0/2] Make client fallback testing easier
by Eric Blake
This is similar to the recent --no-sr option - it's a change that is
unlikely to ever be used except by someone testing whether a client is
compliant to the protocol, but in that niche case, it can be quite
handy (it's a lot nicer to be able to purposefully cripple a server
from the command line than from a one-off compile, when testing if a
client's fallback for a spec-compliant but older server is correct).
I'm planning on writing a counterpart patch for libnbd to allow the
user to mask out bits that the client does not reply with (so you can
choose to cripple the protocol from either the server or the client
side, to see how the other side reacts, similar to the recently-added
nbd_set_request_structured_replies).
I'm open to naming suggestions on the command-line option.
Eric Blake (2):
server: Skip option haggling from client lacking fixed newstyle
server: Add --mask-handshake option for integration testing
docs/nbdkit-protocol.pod | 25 ++++++++++++++++++-----
docs/synopsis.txt | 2 +-
server/internal.h | 1 +
server/options.h | 2 ++
server/main.c | 30 ++++++++++++++++++----------
server/protocol-handshake-newstyle.c | 14 +++++++++++--
6 files changed, 55 insertions(+), 19 deletions(-)
--
2.21.0
5 years, 2 months
[PATCH nbdkit] tests: Convert some tests to use nbdsh instead of qemu-io.
by Richard W.M. Jones
Very much a work in progress as there are still many tests using
qemu-io which are candidates for conversion.
You'll notice at the end of test-full.sh that the new test has some
duplicated code which looks as if it ought to be refactored into a
Python function. When I tried to do that, I got loads of strange
Python problems which may indicate bugs in nbdsh itself or problems
with my understanding of how Python works, but I wasn't sure how to
fix it. The current implementation works.
Rich.
5 years, 2 months
[PATCH 0/2] Remove virt-p2v from libguestfs
by Pino Toscano
Now that virt-p2v has its own repository [1] and releases [2], it is
time to remove it from libguestfs.
[1] https://github.com/libguestfs/virt-p2v
[2] http://download.libguestfs.org/virt-p2v/
Pino Toscano (2):
Remove virt-p2v
Remove remaining virt-p2v bits
.gitignore | 4 -
Makefile.am | 7 +-
bash/Makefile.am | 4 -
bash/virt-alignment-scan | 18 -
common/miniexpect/Makefile.am | 51 -
common/miniexpect/README | 31 -
common/miniexpect/miniexpect.c | 489 ----
common/miniexpect/miniexpect.h | 110 -
common/miniexpect/miniexpect.pod | 496 ----
configure.ac | 18 +-
contrib/README | 3 -
docs/C_SOURCE_FILES | 2 -
docs/guestfs-building.pod | 55 +-
docs/guestfs-hacking.pod | 83 -
generator/authors.ml | 9 -
generator/authors.mli | 1 -
generator/main.ml | 2 -
installcheck.sh.in | 3 -
m4/guestfs-v2v.m4 | 52 +-
p2v/.gitignore | 49 -
p2v/Makefile.am | 376 ---
p2v/contrib/aux-scripts/do-build.sh | 196 --
p2v/contrib/build-p2v-iso.sh | 155 --
...BLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch | 54 -
...-5-ONLY-QEMU-NBD-1.4-HAS-NO-f-OPTION.patch | 34 -
p2v/contrib/test-p2v-iso.sh | 63 -
p2v/conversion.c | 668 -----
p2v/cpuid.c | 222 --
p2v/dependencies.m4 | 181 --
p2v/generate-p2v-authors.pl | 54 -
p2v/generate-p2v-config.pl | 915 -------
p2v/gui-gtk2-compat.h | 117 -
p2v/gui-gtk3-compat.h | 140 -
p2v/gui.c | 2295 -----------------
p2v/inhibit.c | 154 --
p2v/issue | 16 -
p2v/kernel-cmdline.c | 196 --
p2v/kernel.c | 158 --
p2v/kiwi-config.sh | 73 -
p2v/kiwi-config.xml.in | 92 -
p2v/launch-virt-p2v | 51 -
p2v/main.c | 583 -----
p2v/nbd.c | 840 ------
p2v/p2v.h | 136 -
p2v/p2v.ks.in | 193 --
p2v/p2v.service | 38 -
p2v/physical-xml.c | 304 ---
p2v/rtc.c | 165 --
p2v/ssh.c | 1203 ---------
p2v/test-virt-p2v-cmdline.sh | 53 -
p2v/test-virt-p2v-docs.sh | 24 -
p2v/test-virt-p2v-nbdkit.sh | 59 -
p2v/test-virt-p2v-pxe.sh | 96 -
p2v/test-virt-p2v-pxe.sshd_config.in | 43 -
p2v/test-virt-p2v-scp.sh | 62 -
p2v/test-virt-p2v-ssh.sh | 61 -
p2v/test-virt-p2v.sh | 57 -
p2v/utils.c | 256 --
p2v/virt-p2v-make-disk.in | 267 --
p2v/virt-p2v-make-disk.pod | 218 --
p2v/virt-p2v-make-kickstart.in | 241 --
p2v/virt-p2v-make-kickstart.pod | 339 ---
p2v/virt-p2v-make-kiwi.in | 233 --
p2v/virt-p2v-make-kiwi.pod | 184 --
p2v/virt-p2v.pod | 757 ------
p2v/whole-file.c | 95 -
po-docs/language.mk | 3 -
po-docs/podfiles | 6 -
po/POTFILES | 1 -
run.in | 7 -
70 files changed, 6 insertions(+), 14215 deletions(-)
delete mode 100644 common/miniexpect/Makefile.am
delete mode 100644 common/miniexpect/README
delete mode 100644 common/miniexpect/miniexpect.c
delete mode 100644 common/miniexpect/miniexpect.h
delete mode 100644 common/miniexpect/miniexpect.pod
delete mode 100644 p2v/.gitignore
delete mode 100644 p2v/Makefile.am
delete mode 100644 p2v/contrib/aux-scripts/do-build.sh
delete mode 100755 p2v/contrib/build-p2v-iso.sh
delete mode 100644 p2v/contrib/patches/0001-RHEL-5-ONLY-DISABLE-AUTOMATIC-REMOTE-PORT-ALLOCATION.patch
delete mode 100644 p2v/contrib/patches/0002-RHEL-5-ONLY-QEMU-NBD-1.4-HAS-NO-f-OPTION.patch
delete mode 100755 p2v/contrib/test-p2v-iso.sh
delete mode 100644 p2v/conversion.c
delete mode 100644 p2v/cpuid.c
delete mode 100644 p2v/dependencies.m4
delete mode 100755 p2v/generate-p2v-authors.pl
delete mode 100755 p2v/generate-p2v-config.pl
delete mode 100644 p2v/gui-gtk2-compat.h
delete mode 100644 p2v/gui-gtk3-compat.h
delete mode 100644 p2v/gui.c
delete mode 100644 p2v/inhibit.c
delete mode 100644 p2v/issue
delete mode 100644 p2v/kernel-cmdline.c
delete mode 100644 p2v/kernel.c
delete mode 100755 p2v/kiwi-config.sh
delete mode 100644 p2v/kiwi-config.xml.in
delete mode 100755 p2v/launch-virt-p2v
delete mode 100644 p2v/main.c
delete mode 100644 p2v/nbd.c
delete mode 100644 p2v/p2v.h
delete mode 100644 p2v/p2v.ks.in
delete mode 100644 p2v/p2v.service
delete mode 100644 p2v/physical-xml.c
delete mode 100644 p2v/rtc.c
delete mode 100644 p2v/ssh.c
delete mode 100755 p2v/test-virt-p2v-cmdline.sh
delete mode 100755 p2v/test-virt-p2v-docs.sh
delete mode 100755 p2v/test-virt-p2v-nbdkit.sh
delete mode 100755 p2v/test-virt-p2v-pxe.sh
delete mode 100644 p2v/test-virt-p2v-pxe.sshd_config.in
delete mode 100755 p2v/test-virt-p2v-scp.sh
delete mode 100755 p2v/test-virt-p2v-ssh.sh
delete mode 100755 p2v/test-virt-p2v.sh
delete mode 100644 p2v/utils.c
delete mode 100644 p2v/virt-p2v-make-disk.in
delete mode 100644 p2v/virt-p2v-make-disk.pod
delete mode 100644 p2v/virt-p2v-make-kickstart.in
delete mode 100644 p2v/virt-p2v-make-kickstart.pod
delete mode 100644 p2v/virt-p2v-make-kiwi.in
delete mode 100644 p2v/virt-p2v-make-kiwi.pod
delete mode 100644 p2v/virt-p2v.pod
delete mode 100644 p2v/whole-file.c
--
2.21.0
5 years, 2 months