Rebase to new stable branch version 1.46.1

resolves: rhbz#2011711
Fix usage of strerror_r which caused corrupted error messages
resolves: rhbz#2030396
This commit is contained in:
Richard W.M. Jones 2021-12-09 19:34:34 +00:00
parent d41847e5f9
commit e0c7084adb
13 changed files with 30 additions and 252 deletions

View File

@ -1,153 +0,0 @@
From e2f8db27d0af5217eb5d0487e0713309559d4489 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Tue, 21 Sep 2021 21:29:39 +0200
Subject: [PATCH] Go bindings: fix "C array of strings" -- char** -- allocation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The current "arg_string_list" and "free_string_list" implementations go
back to commit b6f01f32606d ("Add Go (language) bindings.", 2013-07-03).
There are two problems with them:
- "free_string_list" doesn't actually free anything,
- at the *first* such g.Internal_test() call site that passes an
Ostringlist member inside the Optargs argument, namely:
> g.Internal_test ("abc",
> string_addr ("def"),
> []string{},
> false,
> 0,
> 0,
> "123",
> "456",
> []byte{'a', 'b', 'c', '\000', 'a', 'b', 'c'},
> &guestfs.OptargsInternal_test{Ostringlist_is_set: true,
> Ostringlist: []string{}
> }
> )
the "golang/run-bindtests" case crashes:
> panic: runtime error: cgo argument has Go pointer to Go pointer
>
> goroutine 1 [running]:
> libguestfs.org/guestfs.(*Guestfs).Internal_test.func7(0xc000018180,
> 0xadfb60, 0xadfb80, 0xc000010048, 0x0, 0x0, 0x0, 0xae3e10, 0xae3e30,
> 0xade3a0, ...)
> golang/src/libguestfs.org/guestfs/guestfs.go:6729 +0xa9
> libguestfs.org/guestfs.(*Guestfs).Internal_test(0xc000018180, 0x4ee3a5,
> 0x3, 0xc000061be8, 0xc000061af8, 0x0, 0x0, 0xc000061a00, 0x0, 0x0, ...)
> golang/src/libguestfs.org/guestfs/guestfs.go:6729 +0x3c9
> main.main()
> golang/bindtests/bindtests.go:77 +0x151e
> exit status 2
> FAIL run-bindtests (exit status: 1)
In Daniel P. Berrangé's words [1],
> You're allowed to pass a Go pointer to C via CGo, but the memory that
> points to is not allowed to contained further Go pointers. So the struct
> fields must strictly use a C pointer.
One pattern to solve the problem has been shown on stackoverflow [2].
Thus, rewrite the "arg_string_list" and "free_string_list" functions
almost entirely in C, following that example.
While this approach is not the most idiomatic Go, as a solution exists
without C helper functions [3], it should still be acceptable, at least as
an incremental improvement, for letting "golang/run-bindtests" pass.
[1] https://listman.redhat.com/archives/libguestfs/2021-September/msg00118.html
[2] https://stackoverflow.com/questions/35924545/golang-cgo-panic-runtime-error-cgo-argument-has-go-pointer-to-go-pointer
[3] https://listman.redhat.com/archives/libguestfs/2021-September/msg00106.html
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Richard W.M. Jones" <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20210921192939.32468-1-lersek@redhat.com>
Tested-by: "Richard W.M. Jones" <rjones@redhat.com>
Acked-by: "Richard W.M. Jones" <rjones@redhat.com>
---
generator/golang.ml | 47 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/generator/golang.ml b/generator/golang.ml
index d328abe4e..0d6a92367 100644
--- a/generator/golang.ml
+++ b/generator/golang.ml
@@ -52,6 +52,40 @@ _go_guestfs_create_flags (unsigned flags)
{
return guestfs_create_flags (flags);
}
+
+// Passing a Go pointer to C via CGo is allowed, but the memory that points to
+// is not allowed to contain further Go pointers. The helper functions below
+// are one way to implement this, although the same can be achieved purely in
+// Go as well. See the discussion here:
+// <https://listman.redhat.com/archives/libguestfs/2021-September/msg00101.html>.
+typedef char *pChar;
+
+pChar *allocStringArray (size_t nmemb)
+{
+ pChar *array;
+
+ array = malloc (sizeof (pChar) * (nmemb + 1));
+ array[nmemb] = NULL;
+ return array;
+}
+
+void storeString (pChar *array, size_t idx, pChar string)
+{
+ array[idx] = string;
+}
+
+void freeStringArray (pChar *array)
+{
+ pChar *position;
+ pChar string;
+
+ position = array;
+ while ((string = *position) != NULL) {
+ free (string);
+ position++;
+ }
+ free (array);
+}
*/
import \"C\"
@@ -148,12 +182,11 @@ func (g *Guestfs) Close () *GuestfsError {
* C strings and golang []string.
*/
func arg_string_list (xs []string) **C.char {
- r := make ([]*C.char, 1 + len (xs))
+ r := C.allocStringArray (C.size_t (len (xs)))
for i, x := range xs {
- r[i] = C.CString (x)
+ C.storeString (r, C.size_t (i), C.CString (x));
}
- r[len (xs)] = nil
- return &r[0]
+ return (**C.char) (r)
}
func count_string_list (argv **C.char) int {
@@ -167,11 +200,7 @@ func count_string_list (argv **C.char) int {
}
func free_string_list (argv **C.char) {
- for *argv != nil {
- //C.free (*argv)
- argv = (**C.char) (unsafe.Pointer (uintptr (unsafe.Pointer (argv)) +
- unsafe.Sizeof (*argv)))
- }
+ C.freeStringArray ((*C.pChar) (argv))
}
func return_string_list (argv **C.char) []string {
--
2.31.1

View File

@ -1,4 +1,4 @@
From 3f6f2fb8f6997e5e993d0e493470323476f33243 Mon Sep 17 00:00:00 2001
From 336ecfab3bb1e14deea9ade891fb772e0698f8d8 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Fri, 1 Oct 2021 14:53:38 +0200
Subject: [PATCH] daemon/inspect_fs_unix: recognize modern Pardus GNU/Linux

View File

@ -1,4 +1,4 @@
From ab80c515bfd527e1609d4e5ffd7c6b18d5a202dc Mon Sep 17 00:00:00 2001
From 3db4dd1804b72575789a67f22a86d6085a141310 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Wed, 13 Oct 2021 18:30:23 +0200
Subject: [PATCH] daemon: inspection: Add support for Kylin (RHBZ#1995391).

View File

@ -1,4 +1,4 @@
From ed8c7ae81786c9de45fa320fe699dbd715f52d87 Mon Sep 17 00:00:00 2001
From 4ac1f94cd17b7e2cc301ae2d63dff25d4529f30b Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 21 Dec 2012 15:50:11 +0000
Subject: [PATCH] RHEL: Remove libguestfs live (RHBZ#798980).

View File

@ -1,33 +0,0 @@
From 63c9cd933af75ca759fa2f2bbdbb07a699df5b30 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 5 Oct 2021 20:51:19 +0100
Subject: [PATCH] m4/guestfs-ocaml.m4: Fix deprecated warning format
In OCaml 4.13:
Alert ocaml_deprecated_cli: Setting a warning with a sequence of lowercase or uppercase letters,
like 'CDEFLMPSUVYZX', is deprecated.
Use the equivalent signed form: +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3.
(cherry picked from
guestfs-tools commit fa4f59e1d99c08d7e0bae2a7cb54f254a6506d67)
---
m4/guestfs-ocaml.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4
index 4b8a44dee..d7f9462ea 100644
--- a/m4/guestfs-ocaml.m4
+++ b/m4/guestfs-ocaml.m4
@@ -232,7 +232,7 @@ EOF
])
dnl Flags we want to pass to every OCaml compiler call.
-OCAML_WARN_ERROR="-warn-error CDEFLMPSUVYZX+52-3"
+OCAML_WARN_ERROR="-warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3"
AC_SUBST([OCAML_WARN_ERROR])
OCAML_FLAGS="-g -annot $safe_string_option"
AC_SUBST([OCAML_FLAGS])
--
2.31.1

View File

@ -1,4 +1,4 @@
From dfd61ba102e4de9e7fb00106e0e73aa2cc4e11fd Mon Sep 17 00:00:00 2001
From f0dce483f0d4bc49c6df6d056f3f4321754fa32d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Jul 2013 18:31:53 +0100
Subject: [PATCH] RHEL: Remove 9p APIs from RHEL (RHBZ#921710).
@ -17,7 +17,7 @@ Subject: [PATCH] RHEL: Remove 9p APIs from RHEL (RHBZ#921710).
diff --git a/daemon/9p.c b/daemon/9p.c
deleted file mode 100644
index 743a96abd..000000000
index 9a3a5cfdf..000000000
--- a/daemon/9p.c
+++ /dev/null
@@ -1,182 +0,0 @@
@ -129,14 +129,14 @@ index 743a96abd..000000000
-
- /* Check readdir didn't fail */
- if (errno != 0) {
- reply_with_perror ("readdir: /sys/block");
- reply_with_perror ("readdir: " BUS_PATH);
- closedir (dir);
- return NULL;
- }
-
- /* Close the directory handle */
- if (closedir (dir) == -1) {
- reply_with_perror ("closedir: /sys/block");
- reply_with_perror ("closedir: " BUS_PATH);
- return NULL;
- }
-
@ -228,7 +228,7 @@ index 6a97d8b0e..896314e7e 100644
daemon/actions.h
daemon/augeas.c
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 5933282dc..c6ffa2f6a 100644
index 226fb860a..05320fcd3 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -6157,27 +6157,6 @@ This returns true iff the device exists and contains all zero bytes.

View File

@ -1,4 +1,4 @@
From 01e9dd07579f6852ab94b215c66d6d7bd0cb022d Mon Sep 17 00:00:00 2001
From bf090c70aae831b2827b262bd93d1d0fd60850e6 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 29 Jul 2013 14:47:56 +0100
Subject: [PATCH] RHEL: Disable unsupported remote drive protocols
@ -220,7 +220,7 @@ index 21d424984..ddabeb639 100755
rm test-add-uri.out
rm test-add-uri.img
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index c6ffa2f6a..91dce1db5 100644
index 05320fcd3..155d739fe 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -297,29 +297,6 @@ F<filename> is interpreted as a local file or device.

View File

@ -1,4 +1,4 @@
From 85adb673dd4705faaac3194d131f2c40bb7a1c78 Mon Sep 17 00:00:00 2001
From fca6730bb7f4f82414061e50df173b35e00bad8f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 19 Sep 2014 13:38:20 +0100
Subject: [PATCH] RHEL: Remove User-Mode Linux (RHBZ#1144197).

View File

@ -1,4 +1,4 @@
From 36b483bb8150a09c7fa6aecb25bf5524fe2e7b93 Mon Sep 17 00:00:00 2001
From ce2e49114bde6edc4a14648ee51adbbf199aa482 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 7 Jul 2015 09:28:03 -0400
Subject: [PATCH] RHEL: Reject use of libguestfs-winsupport features except for

View File

@ -1,4 +1,4 @@
From 94995cf9710042557dd5ca86695be13b5ffa50d4 Mon Sep 17 00:00:00 2001
From bf0d0053627df26cb3d3d96563856e6b7fb34b32 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 Jun 2021 15:29:11 +0100
Subject: [PATCH] RHEL: Create /etc/crypto-policies/back-ends/opensslcnf.config

View File

@ -1,31 +0,0 @@
From 5c67c45b98e8471596d5fb08da76956581ab135d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 22 Nov 2021 15:09:41 +0000
Subject: [PATCH] xfs: Document lazy-counters setting cannot be changed in XFS
version 5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2024022
(cherry picked from commit e7f72ab146b9c2aaee92a600a1fcbefb0202d41c)
---
generator/actions_core.ml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 91dce1db5..155d739fe 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -7600,7 +7600,10 @@ can modify parameters.
Some of the parameters of a mounted filesystem can be examined
and modified using the C<guestfs_xfs_info> and
-C<guestfs_xfs_growfs> calls." };
+C<guestfs_xfs_growfs> calls.
+
+Beginning with XFS version 5, it is no longer possible to modify
+the lazy-counters setting (ie. C<lazycounter> parameter has no effect)." };
{ defaults with
name = "xfs_repair"; added = (1, 19, 36);
--
2.31.1

View File

@ -56,8 +56,8 @@
Summary: Access and modify virtual machine disk images
Name: libguestfs
Epoch: 1
Version: 1.46.0
Release: 5%{?dist}
Version: 1.46.1
Release: 1%{?dist}
License: LGPLv2+
# Build only for architectures that have a kernel
@ -95,17 +95,14 @@ Source8: copy-patches.sh
# https://github.com/libguestfs/libguestfs/commits/rhel-9.0.0
# Patches.
Patch0001: 0001-Go-bindings-fix-C-array-of-strings-char-allocation.patch
Patch0002: 0002-daemon-inspect_fs_unix-recognize-modern-Pardus-GNU-L.patch
Patch0003: 0003-m4-guestfs-ocaml.m4-Fix-deprecated-warning-format.patch
Patch0004: 0004-RHEL-Remove-libguestfs-live-RHBZ-798980.patch
Patch0005: 0005-RHEL-Remove-9p-APIs-from-RHEL-RHBZ-921710.patch
Patch0006: 0006-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
Patch0007: 0007-RHEL-Remove-User-Mode-Linux-RHBZ-1144197.patch
Patch0008: 0008-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0009: 0009-RHEL-Create-etc-crypto-policies-back-ends-opensslcnf.patch
Patch0010: 0010-daemon-inspection-Add-support-for-Kylin-RHBZ-1995391.patch
Patch0011: 0011-xfs-Document-lazy-counters-setting-cannot-be-changed.patch
Patch0001: 0001-daemon-inspect_fs_unix-recognize-modern-Pardus-GNU-L.patch
Patch0002: 0002-daemon-inspection-Add-support-for-Kylin-RHBZ-1995391.patch
Patch0003: 0003-RHEL-Remove-libguestfs-live-RHBZ-798980.patch
Patch0004: 0004-RHEL-Remove-9p-APIs-from-RHEL-RHBZ-921710.patch
Patch0005: 0005-RHEL-Disable-unsupported-remote-drive-protocols-RHBZ.patch
Patch0006: 0006-RHEL-Remove-User-Mode-Linux-RHBZ-1144197.patch
Patch0007: 0007-RHEL-Reject-use-of-libguestfs-winsupport-features-ex.patch
Patch0008: 0008-RHEL-Create-etc-crypto-policies-back-ends-opensslcnf.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool, gettext-devel
@ -1145,19 +1142,17 @@ rm ocaml/html/.gitignore
%changelog
* Tue Nov 23 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.46.0-5
* Thu Dec 09 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.46.1-1
- Rebase to new stable branch version 1.46.1
resolves: rhbz#2011711
- Add --enable-appliance-format-auto
- Add support for Kylin
- Document lazy-counters setting cannot be changed in XFS version 5
resolves: rhbz#2025944, rhbz#1995391, rhbz#2024022
* Fri Oct 29 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.46.0-4
- Require libvirt-daemon-driver-storage-core
resolves: rhbz#2018358
* Fri Oct 08 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.46.0-1
- Rebase to new stable branch version 1.46.0
resolves: rhbz#2011711
- Fix usage of strerror_r which caused corrupted error messages
resolves: rhbz#2030396
* Tue Sep 14 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.6-14
- Specify backing format for qemu 6.1

View File

@ -1,2 +1,2 @@
SHA512 (libguestfs-1.46.0.tar.gz) = 9b1670dff924e046ab82ff1ce6e25428d95b88700b507d4f1dd68a309641e376d14520c7b5aa5bbb81a6ba5c708ebcc46b6fe0970d903a3ed79e76d4ccdca614
SHA512 (libguestfs-1.46.0.tar.gz.sig) = d4c8e4629377d42e8e9f1cc88ad7885999c9ae94a2ee2e683960b397b1a92411c289bddb65d4c3c350915bba16c949011639614b9ec54037bf43833e917b7858
SHA512 (libguestfs-1.46.1.tar.gz) = 28749578f01585a050975adb0ecafcc85cfa3b8940804e7e6846d64f4eabe2a65ca5a6084fdb4b34c97e388c5e4ec98703d41e0768c85c830b9b651874ebe45d
SHA512 (libguestfs-1.46.1.tar.gz.sig) = e80a4979a261bc0b9b35d857c2a52dae1124eeea65969923cc2f9c63f077493b0ae2166ea763a1c7a7a2055a752b3a736d06b890925d9d3daf08b67348d96eb6