[PATCH libnbd] Add outline framework for Go language bindings (golang).
by Richard W.M. Jones
This simply compiles, passes tests, but is only able open a handle.
This commit does not contain the full bindings.
---
Makefile.am | 2 +
configure.ac | 32 +++++
generator/GoLang.ml | 116 ++++++++++++++++++
generator/GoLang.mli | 19 +++
generator/Makefile.am | 2 +
generator/generator.ml | 3 +
golang/Makefile.am | 58 +++++++++
golang/config-test.go | 34 +++++
golang/examples/LICENSE-FOR-EXAMPLES | 38 ++++++
golang/examples/Makefile.am | 21 ++++
golang/run-tests.sh | 24 ++++
golang/src/libguestfs.org/libnbd/.gitignore | 1 +
.../libnbd/libnbd_010_load_test.go | 25 ++++
.../libnbd/libnbd_020_create_test.go | 29 +++++
run.in | 17 +++
15 files changed, 421 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index bf2db68..a9f13ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,6 +43,8 @@ SUBDIRS = \
ocaml \
ocaml/examples \
ocaml/tests \
+ golang \
+ golang/examples \
interop \
fuzzing \
bash \
diff --git a/configure.ac b/configure.ac
index 9fd284b..36617fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -403,6 +403,34 @@ AS_IF([test "x$enable_python" != "xno"],[
AM_CONDITIONAL([HAVE_PYTHON],
[test "x$PYTHON" != "xno" && test "x$have_python_module" = "x1" ])
+dnl Golang.
+AC_ARG_ENABLE([golang],
+ AS_HELP_STRING([--disable-golang], [disable Go language bindings]),
+ [],
+ [enable_golang=yes])
+AS_IF([test "x$enable_golang" != "xno"],[
+ AC_CHECK_PROG([GOLANG],[go],[go],[no])
+ AS_IF([test "x$GOLANG" != "xno"],[
+ AC_MSG_CHECKING([if $GOLANG is usable])
+ AS_IF([$GOLANG run $srcdir/golang/config-test.go 2>&AS_MESSAGE_LOG_FD],[
+ AC_MSG_RESULT([yes])
+
+ # Substitute some golang environment.
+ GOOS=`$GOLANG env GOOS`
+ GOARCH=`$GOLANG env GOARCH`
+ GOROOT=`$GOLANG env GOROOT`
+ AC_SUBST([GOOS])
+ AC_SUBST([GOARCH])
+ AC_SUBST([GOROOT])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([golang ($GOLANG) is installed but not usable])
+ GOLANG=no
+ ])
+ ])
+],[GOLANG=no])
+AM_CONDITIONAL([HAVE_GOLANG],[test "x$GOLANG" != "xno"])
+
dnl Produce output files.
AC_CONFIG_HEADERS([config.h])
@@ -423,6 +451,8 @@ AC_CONFIG_FILES([Makefile
fuse/Makefile
fuzzing/Makefile
generator/Makefile
+ golang/Makefile
+ golang/examples/Makefile
include/Makefile
interop/Makefile
lib/Makefile
@@ -472,6 +502,8 @@ feature "Bash tab completion .................... " \
echo
echo "Language bindings:"
echo
+feature "Go ..................................... " \
+ test "x$HAVE_GOLANG_TRUE" = "x"
feature "OCaml .................................. " \
test "x$HAVE_OCAML_TRUE" = "x"
feature "Python ................................. " \
diff --git a/generator/GoLang.ml b/generator/GoLang.ml
new file mode 100644
index 0000000..b33e7b1
--- /dev/null
+++ b/generator/GoLang.ml
@@ -0,0 +1,116 @@
+(* nbd client library in userspace: generator
+ * Copyright (C) 2013-2020 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
+ *)
+
+(* Go language bindings. *)
+
+open Printf
+
+open API
+open Utils
+
+let generate_golang_libnbd_go () =
+ generate_header CStyle;
+
+ pr "\
+package libnbd
+
+/*
+#cgo CFLAGS:
+#cgo LDFLAGS: -lnbd
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include \"libnbd.h\"
+*/
+import \"C\"
+
+import (
+ \"fmt\"
+ \"runtime\"
+ \"syscall\"
+)
+
+/* Handle. */
+type Libnbd struct {
+ h *C.struct_nbd_handle
+}
+
+/* Convert handle to string (just for debugging). */
+func (h *Libnbd) String () string {
+ return \"&Libnbd{}\"
+}
+
+/* Create a new handle. */
+func Create () (*Libnbd, error) {
+ c_h, err := C.nbd_create ()
+ if c_h == nil {
+ return nil, err
+ }
+ h := &Libnbd{h : c_h}
+ // Finalizers aren't guaranteed to run, but try having one anyway ...
+ runtime.SetFinalizer (h, (*Libnbd).Close)
+ return h, nil
+
+}
+
+/* All functions return ([result,] LibnbdError). */
+type LibnbdError struct {
+ Op string // operation which failed
+ Errmsg string // string (nbd_get_error)
+ Errno syscall.Errno // errno (nbd_get_errno)
+}
+
+func (e *LibnbdError) String() string {
+ if e.Errno != 0 {
+ return fmt.Sprintf (\"%%s: %%s\", e.Op, e.Errmsg);
+ } else {
+ return fmt.Sprintf (\"%%s: %%s: %%s\", e.Op, e.Errmsg, e.Errno);
+ }
+}
+
+/* Implement the error interface */
+func (e *LibnbdError) Error() string {
+ return e.String()
+}
+
+func get_error (op string) *LibnbdError {
+ // NB: DO NOT try to free c_errmsg!
+ c_errmsg := C.nbd_get_error ()
+ errmsg := C.GoString (c_errmsg)
+
+ errno := syscall.Errno (C.nbd_get_errno ())
+
+ return &LibnbdError{ Op : op, Errmsg : errmsg, Errno : errno }
+}
+
+func closed_handle_error (op string) *LibnbdError {
+ return &LibnbdError{ Op : op, Errmsg : \"handle is closed\",
+ Errno : syscall.Errno (0) }
+}
+
+/* Close the handle. */
+func (h *Libnbd) Close () *LibnbdError {
+ if h.h == nil {
+ return closed_handle_error (\"close\")
+ }
+ C.nbd_close (h.h)
+ h.h = nil
+ return nil
+}
+
+";
diff --git a/generator/GoLang.mli b/generator/GoLang.mli
new file mode 100644
index 0000000..b8ec1b5
--- /dev/null
+++ b/generator/GoLang.mli
@@ -0,0 +1,19 @@
+(* nbd client library in userspace: generator
+ * Copyright (C) 2013-2020 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
+ *)
+
+val generate_golang_libnbd_go : unit -> unit
diff --git a/generator/Makefile.am b/generator/Makefile.am
index e499ca8..0389d70 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -57,6 +57,8 @@ sources = \
Python.ml \
OCaml.mli \
OCaml.ml \
+ GoLang.mli \
+ GoLang.ml \
generator.ml \
$(NULL)
diff --git a/generator/generator.ml b/generator/generator.ml
index 1c97492..817c032 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -55,3 +55,6 @@ let () =
output_to "ocaml/NBD.mli" OCaml.generate_ocaml_nbd_mli;
output_to "ocaml/NBD.ml" OCaml.generate_ocaml_nbd_ml;
output_to "ocaml/nbd-c.c" OCaml.generate_ocaml_nbd_c;
+
+ output_to "golang/src/libguestfs.org/libnbd/libnbd.go"
+ GoLang.generate_golang_libnbd_go;
diff --git a/golang/Makefile.am b/golang/Makefile.am
new file mode 100644
index 0000000..47234ff
--- /dev/null
+++ b/golang/Makefile.am
@@ -0,0 +1,58 @@
+# nbd client library in userspace
+# Copyright (C) 2013-2020 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
+
+include $(top_srcdir)/subdir-rules.mk
+
+# http://golang.org/doc/code.html#Organization
+pkg = libguestfs.org/libnbd
+
+source_files = \
+ src/$(pkg)/libnbd.go \
+ src/$(pkg)/libnbd_*_test.go
+
+generator_built = \
+ $(source_files)
+
+EXTRA_DIST = \
+ src/$(pkg)/.gitignore \
+ $(generator_built) \
+ config-test.go \
+ run-tests.sh
+
+if HAVE_GOLANG
+
+golangpkgdir = $(GOROOT)/pkg/$(GOOS)_$(GOARCH)/$(pkg)
+golangsrcdir = $(GOROOT)/src/pkg/$(pkg)
+
+golangpkg_DATA = \
+ pkg/$(GOOS)_$(GOARCH)/$(pkg).a
+
+pkg/$(GOOS)_$(GOARCH)/$(pkg).a: src/$(pkg)/libnbd.go
+ $(top_builddir)/run $(GOLANG) install $(pkg)
+
+golangsrc_DATA = $(source_files)
+
+TESTS_ENVIRONMENT = pkg=$(pkg) LIBNBD_DEBUG=1
+LOG_COMPILER = $(top_builddir)/run
+TESTS = run-tests.sh
+
+endif
+
+CLEANFILES += src/$(pkg)/*~
+
+clean-local:
+ rm -rf pkg
diff --git a/golang/config-test.go b/golang/config-test.go
new file mode 100644
index 0000000..e104c71
--- /dev/null
+++ b/golang/config-test.go
@@ -0,0 +1,34 @@
+/* libnbd Go configuration test
+ * Copyright (C) 2013-2020 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* This is called from ./configure to check that golang works
+ * and is above the minimum required version.
+ */
+
+package main
+
+func main() {
+ /* XXX Check for minimum runtime.Version() >= "go1.1.1"
+ * Unfortunately go version numbers are not easy to parse.
+ * They have the 3 formats "goX.Y.Z", "release.rN" or
+ * "weekly.YYYY-MM-DD". The latter two formats are mostly
+ * useless, and the first one is hard to parse. See also
+ * cmpGoVersion in
+ * http://web.archive.org/web/20130402235148/http://golang.org/src/cmd/go/ge...
+ */
+}
diff --git a/golang/examples/LICENSE-FOR-EXAMPLES b/golang/examples/LICENSE-FOR-EXAMPLES
new file mode 100644
index 0000000..4986466
--- /dev/null
+++ b/golang/examples/LICENSE-FOR-EXAMPLES
@@ -0,0 +1,38 @@
+The files in the golang/examples/ directory are licensed under this
+very permissive BSD license. This means that you can copy, use, adapt
+and modify them without any significant restrictions. You can also
+combine them with proprietary code or include them in code that is
+distributed under other open source licenses.
+
+----------------------------------------------------------------------
+
+libnbd examples
+Copyright (C) 2013-2020 Red Hat Inc.
+
+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.
diff --git a/golang/examples/Makefile.am b/golang/examples/Makefile.am
new file mode 100644
index 0000000..90498ab
--- /dev/null
+++ b/golang/examples/Makefile.am
@@ -0,0 +1,21 @@
+# nbd client library in userspace
+# Copyright (C) 2013-2020 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
+
+include $(top_srcdir)/subdir-rules.mk
+
+EXTRA_DIST = \
+ LICENSE-FOR-EXAMPLES
diff --git a/golang/run-tests.sh b/golang/run-tests.sh
new file mode 100755
index 0000000..a155819
--- /dev/null
+++ b/golang/run-tests.sh
@@ -0,0 +1,24 @@
+#!/bin/sh -
+# nbd client library in userspace
+# Copyright (C) 2013-2020 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
+
+set -e
+
+# The -count=1 parameter is the "idiomatic way to bypass test caching".
+# https://golang.org/doc/go1.10#test
+# The -v option enables verbose output.
+$GOLANG test -count=1 -v $pkg
diff --git a/golang/src/libguestfs.org/libnbd/.gitignore b/golang/src/libguestfs.org/libnbd/.gitignore
new file mode 100644
index 0000000..a2ce7eb
--- /dev/null
+++ b/golang/src/libguestfs.org/libnbd/.gitignore
@@ -0,0 +1 @@
+/libnbd.go
diff --git a/golang/src/libguestfs.org/libnbd/libnbd_010_load_test.go b/golang/src/libguestfs.org/libnbd/libnbd_010_load_test.go
new file mode 100644
index 0000000..24cfe66
--- /dev/null
+++ b/golang/src/libguestfs.org/libnbd/libnbd_010_load_test.go
@@ -0,0 +1,25 @@
+/* libnbd golang tests
+ * Copyright (C) 2013-2020 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package libnbd
+
+import "testing"
+
+func Test010Load (t *testing.T) {
+ /* Nothing - just test that the library can be linked to. */
+}
diff --git a/golang/src/libguestfs.org/libnbd/libnbd_020_create_test.go b/golang/src/libguestfs.org/libnbd/libnbd_020_create_test.go
new file mode 100644
index 0000000..752bcf4
--- /dev/null
+++ b/golang/src/libguestfs.org/libnbd/libnbd_020_create_test.go
@@ -0,0 +1,29 @@
+/* libnbd golang tests
+ * Copyright (C) 2013-2020 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+package libnbd
+
+import "testing"
+
+func Test020Create (t *testing.T) {
+ h, err := Create ()
+ if err != nil {
+ t.Errorf ("could not create handle: %s", err)
+ }
+ h.Close ()
+}
diff --git a/run.in b/run.in
index 0411c85..9ffece5 100755
--- a/run.in
+++ b/run.in
@@ -78,6 +78,23 @@ export PYTHONPATH
prepend CAML_LD_LIBRARY_PATH "$b/ocaml"
export CAML_LD_LIBRARY_PATH
+# For golang.
+export GOLANG="@GOLANG@"
+prepend GOPATH "$b/golang"
+export GOPATH
+if [ -z "$CGO_CFLAGS" ]; then
+ CGO_CFLAGS="-I$s/include -I$b"
+else
+ CGO_CFLAGS="$CGO_CFLAGS -I$s/include -I$b"
+fi
+export CGO_CFLAGS
+if [ -z "$CGO_LDFLAGS" ]; then
+ CGO_LDFLAGS="-L$b/lib/.libs"
+else
+ CGO_LDFLAGS="$CGO_LDFLAGS -L$b/lib/.libs"
+fi
+export CGO_LDFLAGS
+
# This is a cheap way to find some use-after-free and uninitialized
# read problems when using glibc.
export MALLOC_CHECK_=1
--
2.25.0
4 years, 9 months
[PATCH nbdkit] New tmpdisk plugin.
by Richard W.M. Jones
Unfinished (needs tests). This is my attempt to make a
"remote tmpfs" plugin as outlined in this prior email:
https://www.redhat.com/archives/libguestfs/2020-March/msg00134.html
Although it would be possible to construct something a bit like this
using existing plugins and filters (perhaps with some new features in
those filters) I think it may be nicer to have a dedicated plugin for
this, as it makes the documentation simpler to understand and allows
us to implement unique features. In particular notice that this
plugin only deals with temporary disks so deliberately ignores
flush/FUA, which should make it nice and fast.
Rich.
4 years, 9 months
[nbdkit PATCH v2] eval: Rebuild hard link if git breaks it
by Eric Blake
Commit 39b40750dd works if you rely on 'make clean' after a git
update, but not if you rely on incremental 'make'. Git likes to
update files by creating new inodes, which strands hard links. We
could either use symlinks, or as done here, add a dependency to force
the hard links to be rebuilt as needed.
Fixes: 45b4877fde
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
plugins/eval/Makefile.am | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/plugins/eval/Makefile.am b/plugins/eval/Makefile.am
index abbe17a0..da2e7b39 100644
--- a/plugins/eval/Makefile.am
+++ b/plugins/eval/Makefile.am
@@ -1,5 +1,5 @@
# nbdkit
-# Copyright (C) 2017-2019 Red Hat Inc.
+# Copyright (C) 2017-2020 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -37,14 +37,16 @@ plugin_LTLIBRARIES = nbdkit-eval-plugin.la
# This plugin shares most of the same sources as nbdkit-sh-plugin. In
# RHEL 7 we cannot add the C files from ../sh directly to SOURCES
-# because subdir-objects is broken. Instead we create hard links to
+# because subdir-objects is broken. Instead we create symlinks to
# them.
BUILT_SOURCES = \
call.c \
methods.c \
$(NULL)
-$(BUILT_SOURCES):
- ln -f ../sh/$@
+call.c: ../sh/call.c
+ ln -f -s ../sh/$@
+methods.c: ../sh/methods.c
+ ln -f -s ../sh/$@
CLEANFILES += $(BUILT_SOURCES)
nbdkit_eval_plugin_la_SOURCES = \
--
2.25.1
4 years, 9 months
[nbdkit PATCH] eval: Rebuild hard link if git breaks it
by Eric Blake
Commit 39b40750dd works if you use 'make clean', but not if you rely
on incremental builds. Git likes to update files by creating new
inodes, which strands hard links. We could either use symlinks, or as
done here, add a dependency to force the hard links to be rebuilt as
needed.
Fixes: 45b4877fde
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
plugins/eval/Makefile.am | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/eval/Makefile.am b/plugins/eval/Makefile.am
index abbe17a0..19de6c0d 100644
--- a/plugins/eval/Makefile.am
+++ b/plugins/eval/Makefile.am
@@ -1,5 +1,5 @@
# nbdkit
-# Copyright (C) 2017-2019 Red Hat Inc.
+# Copyright (C) 2017-2020 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -43,7 +43,7 @@ BUILT_SOURCES = \
call.c \
methods.c \
$(NULL)
-$(BUILT_SOURCES):
+$(BUILT_SOURCES): ../sh/call.c ../sh/methods.c
ln -f ../sh/$@
CLEANFILES += $(BUILT_SOURCES)
--
2.25.1
4 years, 9 months
[p2v PATCH 1/3] Add kickstart URLs for RHEL 8
by Pino Toscano
Both BaseOS and AppStream are needed.
---
virt-p2v-make-kickstart.in | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/virt-p2v-make-kickstart.in b/virt-p2v-make-kickstart.in
index 779ba62..cbbfb8a 100644
--- a/virt-p2v-make-kickstart.in
+++ b/virt-p2v-make-kickstart.in
@@ -176,6 +176,16 @@ repo --name=rhel6_${minor}_server_optional --baseurl=$baseurl/Server/optional/$a
repos="$repos
repo --name=rhel7_${minor}_server --baseurl=$baseurl/Server/$arch/os $proxy
repo --name=rhel7_${minor}_server_optional --baseurl=$baseurl/Server-optional/$arch/os $proxy
+"
+ ;;
+ rhel-8.*)
+ minor=$( echo "$repo" | sed 's/rhel-[0-9]*\.\([0-9]*\)/\1/' )
+ baseurl=http://download.devel.redhat.com/released/RHEL-8/8.$minor.0
+ # '$basearch' cannot be used in kickstart, so:
+ arch=`uname -m`
+ repos="$repos
+repo --name=rhel8_${minor}_0_baseos --baseurl=$baseurl/BaseOS/$arch/os $proxy
+repo --name=rhel8_${minor}_0_appstream --baseurl=$baseurl/AppStream/$arch/os $proxy
"
;;
*)
--
2.24.1
4 years, 9 months
[nbdkit] Serving "temporary disks" over NBD
by Richard W.M. Jones
(This email is largely me just thinking aloud ... So ideas welcome!)
For the RISC-V builders (http://fedora.riscv.rocks) I'm using an NBD
disk to host the heavily used /var/lib/mock build directory. This is
because the build machines have only SD-cards as local disk and SD is
both slow and unreliable.
The builders (NBD clients) are set up with an /etc/rc.d/rc.local file
which runs these commands on boot:
modprobe nbd
nbd-client -b 512 nbd.server.example.com 10809 /dev/nbd0
mount /dev/nbd0 /var/lib/mock
The /var/lib/mock directory is essentially temporary and doesn't need
to persist across boots or even mounts. Ideally every time the client
connects over NBD we'd get a fresh ext4 filesystem. Also note as
there are multiple clients they must all see a freshly created,
independent view of the disk.
At the moment I'm using nbdkit as the server, but:
(1) There is a separate server and port for each builder (client).
"10809" in the command above is actually a variable port number
depending on the client.
(2) The filesystem is actually persistent because I'm using regular
nbdkit-file-plugin backed by a block device.
(3) The filesystems are very large (100G), much larger than the
available memory on the server. So they have to be backed by the
server's filesystem rather than being RAM disks. (This is a
round-about way of saying that nbdkit-memory-plugin cannot be used).
Funnily enough nbd-server despite being very inflexible in many ways
actually makes this particular use-case easy because of the nbd-server -c
option:
https://github.com/NetworkBlockDevice/nbd/blob/cb20c16354cccf4698fde74c42...
Of course I could very easily write a custom plugin just for this
purpose, but could we do something in upstream nbdkit to make it easier?
Currently the cow filter (unlike nbd-server -c) serves identical
content to all clients. Adding a new option to make it serve a new
COW to each client is possible but not an easy change to make.
Or a new COW filter which works more like nbd-server -c?
An upstream custom plugin which implements this as a special case?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
4 years, 9 months
[PATCH libnbd 1/3] tests: Don't use <config.h> in simple compile tests.
by Richard W.M. Jones
For these simple compile tests where we want to ensure that a basic
external program could be compiled using libnbd, we shouldn't include
<config.h>. This is because we want to test here that <libnbd.h> can
stand alone, without needing anything defined by the GNU autotools
infrastructure.
Of course we can use <config.h> in other test programs where we aren't
evaluating if <libnbd.h> works standalone.
---
tests/compile-ansi-c.c | 2 --
tests/compile-cxx.cpp | 2 --
tests/compile.c | 2 --
3 files changed, 6 deletions(-)
diff --git a/tests/compile-ansi-c.c b/tests/compile-ansi-c.c
index 0d48618..82e1976 100644
--- a/tests/compile-ansi-c.c
+++ b/tests/compile-ansi-c.c
@@ -20,8 +20,6 @@
* compiler.
*/
-#include <config.h>
-
#include <stdio.h>
#include <stdlib.h>
diff --git a/tests/compile-cxx.cpp b/tests/compile-cxx.cpp
index 4c8447c..f24d409 100644
--- a/tests/compile-cxx.cpp
+++ b/tests/compile-cxx.cpp
@@ -22,8 +22,6 @@
#error "this test should be compiled with a C++ compiler"
#endif
-#include <config.h>
-
#include <iostream>
#include <cstdlib>
diff --git a/tests/compile.c b/tests/compile.c
index d7ef98c..b23cf81 100644
--- a/tests/compile.c
+++ b/tests/compile.c
@@ -18,8 +18,6 @@
/* Compile, open and close a handle. */
-#include <config.h>
-
#include <stdio.h>
#include <stdlib.h>
--
2.25.0
4 years, 9 months
nbdkit Assertion `h->can_flush == 1' failed on Arch
by Richard W.M. Jones
https://aur.archlinux.org/packages/nbdkit/#comment-733981 reports that
tests-parallel-nbd.sh hangs. Looking at the log file from the test
reveals:
nbdkit: backend.c:523: backend_flush: Assertion `h->can_flush == 1' failed.
I've attached the full log. If you want to see other logs from the
run (probably not relevant) then download
https://svenne.dk/nbdkit-20200315/nbdkit-logs-20200315.tar.gz
I believe the assertion comes from calling flush when can_flush
previously returned false, but also I don't quite understand why the
server is doing this.
However I think the wider problem is that the reporter is using the
non-libnbd "standalone" nbd plugin. I basically never test this any
longer. I wonder if we should think about either having a way to
routinely test it despite libnbd being installed, or simply dropping
it?
I will ask the reporter if they can try installing libnbd.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
4 years, 9 months
[PATCH libguestfs 0/3] daemon: Fix various commands which break on NTFS-3g compressed files.
by Richard W.M. Jones
https://bugzilla.redhat.com/show_bug.cgi?id=1811539
Commands including virt-diff which read extended attributes will
sometimes fail on NTFS filesystems that are using system compressed.
The reason is complex, see comment 5 of the bug linked above.
This patch filters out the troublesome xattr. For justification, see
the comment I added in patch 3.
Patch 1 & 2 are refactoring.
I was on the verge of rewriting the whole file in OCaml, but OCaml
doesn't have access to the relevant system calls so it would have been
a bunch more work and not necessarily any simpler.
Thanks: Yongkui Guo for identifying the bug.
Rich.
4 years, 9 months
[PATCH common] options: Require libguestfs >= 1.42.
by Richard W.M. Jones
Libguestfs itself is obviously now >= 1.42. In virt-v2v we made a
similar change upstream to require libguestfs >= 1.42. Therefore the
ifdefs are no longer required.
---
options/decrypt.c | 5 -----
options/options.c | 4 ----
2 files changed, 9 deletions(-)
diff --git a/options/decrypt.c b/options/decrypt.c
index 683cf5ed4..32ef29fd6 100644
--- a/options/decrypt.c
+++ b/options/decrypt.c
@@ -85,12 +85,7 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
if (type && STREQ (type, "crypto_LUKS")) {
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
-
-#ifdef GUESTFS_HAVE_LUKS_UUID
CLEANUP_FREE char *uuid = guestfs_luks_uuid (g, partitions[i]);
-#else
- const char *uuid = NULL;
-#endif
CLEANUP_FREE_STRING_LIST char **keys = get_keys (ks, partitions[i], uuid);
assert (guestfs_int_count_strings (keys) > 0);
diff --git a/options/options.c b/options/options.c
index abdcbae5b..63221ea32 100644
--- a/options/options.c
+++ b/options/options.c
@@ -140,12 +140,10 @@ add_drives_handle (guestfs_h *g, struct drv *drv, size_t drive_index)
ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_DISCARD_BITMASK;
ad_optargs.discard = drv->a.discard;
}
-#ifdef GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK
if (drv->a.blocksize) {
ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK;
ad_optargs.blocksize = drv->a.blocksize;
}
-#endif
r = guestfs_add_drive_opts_argv (g, drv->a.filename, &ad_optargs);
if (r == -1)
@@ -179,12 +177,10 @@ add_drives_handle (guestfs_h *g, struct drv *drv, size_t drive_index)
ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_SECRET_BITMASK;
ad_optargs.secret = drv->uri.password;
}
-#ifdef GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK
if (drv->uri.blocksize) {
ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK;
ad_optargs.blocksize = drv->uri.blocksize;
}
-#endif
r = guestfs_add_drive_opts_argv (g, drv->uri.path, &ad_optargs);
if (r == -1)
--
2.25.0
4 years, 9 months