From 9a27bfdfb50f42b27acf6998f95721461fc0706a Mon Sep 17 00:00:00 2001 Message-ID: <9a27bfdfb50f42b27acf6998f95721461fc0706a.1738937224.git.jdenemar@redhat.com> From: Peter Krempa Date: Mon, 27 Jan 2025 17:42:34 +0100 Subject: [PATCH] build: Bump minimum glib2 version to 2.66.0 Per our supported platforms the minimum available versions are: CentOS Stream 9: 2.68.4 Debian 11: 2.66.8 Fedora 39: 2.78.6 openSUSE Leap 15.6: 2.78.6 Ubuntu 22.04: 2.72.4 FreeBSD ports: 2.80.5 macOS homebrew: 2.82.4 macOS macports: 2.78.4 Bump to 2.66 which is limited by Debian 11. While ideally we'd bump to 2.68 which would give us 'g_strv_builder' and friends 2.66 is enough for g_ptr_array_steal() which can be used to emulate the former with almost no extra code. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina (cherry picked from commit 420c39d6bd66ccf4841878882f5a3e9e47103ebb) https://issues.redhat.com/browse/RHEL-76802 --- libvirt.spec.in | 2 +- meson.build | 2 +- src/libvirt_private.syms | 4 -- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_monitor.c | 2 +- src/util/glibcompat.c | 94 ---------------------------------------- src/util/glibcompat.h | 18 -------- src/util/vireventglib.c | 12 ++--- 8 files changed, 10 insertions(+), 126 deletions(-) diff --git a/meson.build b/meson.build index 89ac1594cb..d3e2c939ea 100644 --- a/meson.build +++ b/meson.build @@ -998,7 +998,7 @@ else endif endif -glib_version = '2.58.0' +glib_version = '2.66.0' glib_dep = dependency('glib-2.0', version: '>=' + glib_version) gobject_dep = dependency('gobject-2.0', version: '>=' + glib_version) if host_machine.system() == 'windows' diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c931003fad..43e2dfb9cd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1871,10 +1871,6 @@ virStorageSourceUpdatePhysicalSize; # util/glibcompat.h -vir_g_fsync; -vir_g_source_unref; -vir_g_strdup_printf; -vir_g_strdup_vprintf; vir_g_string_replace; diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 22359f8518..43fca86f10 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -448,7 +448,7 @@ qemuAgentUnregister(qemuAgent *agent) { if (agent->watch) { g_source_destroy(agent->watch); - vir_g_source_unref(agent->watch, agent->context); + g_source_unref(agent->watch); agent->watch = NULL; } } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 73f37d26eb..79bd91b539 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -745,7 +745,7 @@ qemuMonitorUnregister(qemuMonitor *mon) { if (mon->watch) { g_source_destroy(mon->watch); - vir_g_source_unref(mon->watch, mon->context); + g_source_unref(mon->watch); mon->watch = NULL; } } diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 98dcfab389..bcb666992a 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -63,100 +63,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#undef g_fsync -#undef g_strdup_printf -#undef g_strdup_vprintf - - -/* Drop when min glib >= 2.63.0 */ -gint -vir_g_fsync(gint fd) -{ -#ifdef G_OS_WIN32 - return _commit(fd); -#else - return fsync(fd); -#endif -} - - -/* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf() - * abort on OOM. It's fixed in glib's upstream. Provide our own - * implementation until the fix gets distributed. */ -char * -vir_g_strdup_printf(const char *msg, ...) -{ - va_list args; - char *ret; - va_start(args, msg); - ret = g_strdup_vprintf(msg, args); - if (!ret) - abort(); - va_end(args); - return ret; -} - - -char * -vir_g_strdup_vprintf(const char *msg, va_list args) -{ - char *ret; - ret = g_strdup_vprintf(msg, args); - if (!ret) - abort(); - return ret; -} - - -/* - * If the last reference to a GSource is released in a non-main - * thread we're exposed to a race condition that causes a - * crash: - * - * https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1358 - * - * Thus we're using an idle func to release our ref... - * - * ...but this imposes a significant performance penalty on - * I/O intensive workloads which are sensitive to the iterations - * of the event loop, so avoid the workaround if we know we have - * new enough glib. - * - * The function below is used from a header file definition. - * - * Drop when min glib >= 2.64.0 - */ -#if GLIB_CHECK_VERSION(2, 64, 0) -void vir_g_source_unref(GSource *src, GMainContext *ctx G_GNUC_UNUSED) -{ - g_source_unref(src); -} -#else - -static gboolean -virEventGLibSourceUnrefIdle(gpointer data) -{ - GSource *src = data; - - g_source_unref(src); - - return FALSE; -} - -void vir_g_source_unref(GSource *src, GMainContext *ctx) -{ - GSource *idle = g_idle_source_new(); - - g_source_set_callback(idle, virEventGLibSourceUnrefIdle, src, NULL); - - g_source_attach(idle, ctx); - - g_source_unref(idle); -} - -#endif - - /** * Adapted (to pass syntax check) from 'g_string_replace' from * glib-2.81.1. Drop once minimum glib is bumped to 2.68. diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 474ff95bc5..a3d01089e6 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -42,24 +42,6 @@ #endif /* GLib < 2.67.0 */ - -gint vir_g_fsync(gint fd); -char *vir_g_strdup_printf(const char *msg, ...) - G_GNUC_PRINTF(1, 2); -char *vir_g_strdup_vprintf(const char *msg, va_list args) - G_GNUC_PRINTF(1, 0); - -#if !GLIB_CHECK_VERSION(2, 64, 0) -# define g_strdup_printf vir_g_strdup_printf -# define g_strdup_vprintf vir_g_strdup_vprintf -#endif - -#undef g_fsync -#define g_fsync vir_g_fsync - -void vir_g_source_unref(GSource *src, GMainContext *ctx); - - /* Drop once we require glib-2.68 at minimum */ guint vir_g_string_replace(GString *string, diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c index 023dc37445..6c54f62123 100644 --- a/src/util/vireventglib.c +++ b/src/util/vireventglib.c @@ -213,7 +213,7 @@ virEventGLibHandleUpdate(int watch, if (data->source != NULL) { VIR_DEBUG("Removed old handle source=%p", data->source); g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); } data->source = virEventGLibAddSocketWatch( @@ -227,7 +227,7 @@ virEventGLibHandleUpdate(int watch, VIR_DEBUG("Removed old handle source=%p", data->source); g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); data->source = NULL; data->events = 0; } @@ -276,7 +276,7 @@ virEventGLibHandleRemove(int watch) if (data->source != NULL) { g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); data->source = NULL; data->events = 0; } @@ -409,7 +409,7 @@ virEventGLibTimeoutUpdate(int timer, if (interval >= 0) { if (data->source != NULL) { g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); } data->interval = interval; @@ -419,7 +419,7 @@ virEventGLibTimeoutUpdate(int timer, goto cleanup; g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); data->source = NULL; } @@ -468,7 +468,7 @@ virEventGLibTimeoutRemove(int timer) if (data->source != NULL) { g_source_destroy(data->source); - vir_g_source_unref(data->source, NULL); + g_source_unref(data->source); data->source = NULL; } -- 2.48.1