From 389035428cd636ea772cd6eab15c708c1ed5826a Mon Sep 17 00:00:00 2001 From: imxcc Date: Fri, 9 Jul 2021 15:26:08 +0800 Subject: [PATCH 1/3] tests: fix stat mocking with Fedora rawhide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLibC has a really complicated way of dealing with the 'stat' function historically, which means our mocks in turn have to look at four different possible functions to replace, stat, stat64, __xstat, __xstat64. In Fedora 33 and earlier: - libvirt.so links to __xstat64 - libc.so library exports stat, stat64, __xstat, __xstat64 - sys/stat.h header exposes stat and __xstat In Fedora 34 rawhide: - libvirt.so links to stat64 - libc.so library exports stat, stat64, __xstat, __xstat64 - sys/stat.h header exposes stat Historically we only looked at the exported symbols from libc.so to decide which to mock. In F34 though we must not consider __xstat / __xstat64 though because they only existance for binary compatibility. Newly built binaries won't reference them. Thus we must introduce a header file check into our logic for deciding which symbol to mock. We must ignore the __xstat / __xstat64 symbols if they don't appear in the sys/stat.h header, even if they appear in libc.so Signed-off-by: Daniel P. Berrangé Reviewed-by: Michal Privoznik Signed-off-by: Peng Liang Signed-off-by: imxcc --- ...fix-stat-mocking-with-Fedora-rawhide.patch | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 tests-fix-stat-mocking-with-Fedora-rawhide.patch diff --git a/tests-fix-stat-mocking-with-Fedora-rawhide.patch b/tests-fix-stat-mocking-with-Fedora-rawhide.patch new file mode 100644 index 0000000..ec33b29 --- /dev/null +++ b/tests-fix-stat-mocking-with-Fedora-rawhide.patch @@ -0,0 +1,135 @@ +From 7da32d9655a074995de29fc6c1ac7bcd5aa6bfe6 Mon Sep 17 00:00:00 2001 +From: imxcc +Date: Fri, 9 Jul 2021 15:26:08 +0800 +Subject: [PATCH] tests: fix stat mocking with Fedora rawhide +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GLibC has a really complicated way of dealing with the 'stat' function +historically, which means our mocks in turn have to look at four +different possible functions to replace, stat, stat64, __xstat, +__xstat64. + +In Fedora 33 and earlier: + + - libvirt.so links to __xstat64 + - libc.so library exports stat, stat64, __xstat, __xstat64 + - sys/stat.h header exposes stat and __xstat + +In Fedora 34 rawhide: + + - libvirt.so links to stat64 + - libc.so library exports stat, stat64, __xstat, __xstat64 + - sys/stat.h header exposes stat + +Historically we only looked at the exported symbols from libc.so to +decide which to mock. + +In F34 though we must not consider __xstat / __xstat64 though because +they only existance for binary compatibility. Newly built binaries +won't reference them. + +Thus we must introduce a header file check into our logic for deciding +which symbol to mock. We must ignore the __xstat / __xstat64 symbols +if they don't appear in the sys/stat.h header, even if they appear +in libc.so + +Signed-off-by: Daniel P. Berrangé +Reviewed-by: Michal Privoznik +Signed-off-by: Peng Liang +Signed-off-by: imxcc +--- + configure.ac | 1 + + tests/virmockstathelpers.c | 58 ++++++++++++++++++++++---------------- + 2 files changed, 35 insertions(+), 24 deletions(-) + +diff --git a/configure.ac b/configure.ac +index e565437062..cb62e5aac8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -396,6 +396,7 @@ AC_CHECK_HEADERS([\ + dnl Check whether endian provides handy macros. + AC_CHECK_DECLS([htole64], [], [], [[#include ]]) + AC_CHECK_FUNCS([stat stat64 __xstat __xstat64 lstat lstat64 __lxstat __lxstat64]) ++AC_CHECK_DECLS([stat, stat64, __xstat, __xstat64, lstat, lstat64, __lxstat, __lxstat64], [], [], [[#include ]]) + + AC_CHECK_TYPE([struct ifreq], + [AC_DEFINE([HAVE_STRUCT_IFREQ],[1], +diff --git a/tests/virmockstathelpers.c b/tests/virmockstathelpers.c +index ba26e7bd45..5118ffc731 100644 +--- a/tests/virmockstathelpers.c ++++ b/tests/virmockstathelpers.c +@@ -69,35 +69,45 @@ + * - If __xstat & __xstat64 exist, then stat & stat64 will not exist + * as symbols in the library, so the latter should not be mocked. + * ++ * - If __xstat exists in the library, but not the header than it ++ * it is just there for binary back compat and should not be ++ * mocked ++ * + * The same all applies to lstat() + */ + + ++#if !HAVE_DECL___XSTAT ++# if defined(HAVE_STAT) && !defined(_FILE_OFFSET_BITS) || defined(__APPLE__) ++# define MOCK_STAT ++# endif ++# if defined(HAVE_STAT64) ++# define MOCK_STAT64 ++# endif ++#else /* HAVE_DECL___XSTAT */ ++# if defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS) ++# define MOCK___XSTAT ++# endif ++# if defined(HAVE___XSTAT64) ++# define MOCK___XSTAT64 ++# endif ++#endif /* HAVE_DECL___XSTAT */ + +-#if defined(HAVE_STAT) && !defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS) +-# define MOCK_STAT +-#endif +-#if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64) +-# define MOCK_STAT64 +-#endif +-#if defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS) +-# define MOCK___XSTAT +-#endif +-#if defined(HAVE___XSTAT64) +-# define MOCK___XSTAT64 +-#endif +-#if defined(HAVE_LSTAT) && !defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS) +-# define MOCK_LSTAT +-#endif +-#if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64) +-# define MOCK_LSTAT64 +-#endif +-#if defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS) +-# define MOCK___LXSTAT +-#endif +-#if defined(HAVE___LXSTAT64) +-# define MOCK___LXSTAT64 +-#endif ++#if !HAVE_DECL___LXSTAT ++# if defined(HAVE_LSTAT) && !defined(_FILE_OFFSET_BITS) || defined(__APPLE__) ++# define MOCK_LSTAT ++# endif ++# if defined(HAVE_LSTAT64) ++# define MOCK_LSTAT64 ++# endif ++#else /* HAVE_DECL___LXSTAT */ ++# if defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS) ++# define MOCK___LXSTAT ++# endif ++# if defined(HAVE___LXSTAT64) ++# define MOCK___LXSTAT64 ++# endif ++#endif /* HAVE_DECL___LXSTAT */ + + #ifdef MOCK_STAT + static int (*real_stat)(const char *path, struct stat *sb); +-- +2.27.0 + -- Gitee From e51f6bf7a4e4e54925fee84f377298d643fd8480 Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Tue, 13 Jul 2021 21:28:00 +0800 Subject: [PATCH 2/3] spec: Update patch and changelog with !30 tests: fix stat mocking with Fedora rawhide(for glibc 2.33) !30 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests: fix stat mocking with Fedora rawhide Signed-off-by: Daniel P. Berrangé Signed-off-by: Peng Liang Signed-off-by: imxcc --- libvirt.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt.spec b/libvirt.spec index 18f0029..6bdac99 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -180,6 +180,7 @@ Patch0063: libvirt-Add-retry-support-for-error-policy.patch Patch0064: qemu-Support-retry-BLOCK_IO_ERROR-event.patch Patch0065: add-phytium-2000plus-and-s2500-support-on-arm-archit.patch Patch0066: libvirt-conf-Set-default-values-of-retry-fileds.patch +Patch0067: tests-fix-stat-mocking-with-Fedora-rawhide.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -1914,6 +1915,9 @@ exit 0 %changelog +* Tue Jul 13 2021 imxcc +- tests: fix stat mocking with Fedora rawhide + * Fri Mar 19 2021 Jiajie Li - libvirt.spec: remove dtrace for aarch64 OS -- Gitee From 24ad023f156ebd2a8033321dd586fdaf511862ff Mon Sep 17 00:00:00 2001 From: Chen Qun Date: Tue, 13 Jul 2021 21:28:00 +0800 Subject: [PATCH 3/3] spec: Update release version with !30 increase release verison by one Signed-off-by: Chen Qun --- libvirt.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt.spec b/libvirt.spec index 6bdac99..91da9c7 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -105,7 +105,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.2.0 -Release: 18 +Release: 19 License: LGPLv2+ URL: https://libvirt.org/ -- Gitee