1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-02-01 09:47:20 +03:00

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 <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2025-01-27 17:42:34 +01:00
parent 62b961d64c
commit 420c39d6bd
8 changed files with 10 additions and 126 deletions

View File

@ -357,7 +357,7 @@ BuildRequires: gcc
%if %{with_libxl} %if %{with_libxl}
BuildRequires: xen-devel BuildRequires: xen-devel
%endif %endif
BuildRequires: glib2-devel >= 2.58 BuildRequires: glib2-devel >= 2.66
BuildRequires: libxml2-devel BuildRequires: libxml2-devel
BuildRequires: readline-devel BuildRequires: readline-devel
BuildRequires: pkgconfig(bash-completion) >= 2.0 BuildRequires: pkgconfig(bash-completion) >= 2.0

View File

@ -1009,7 +1009,7 @@ else
endif endif
endif endif
glib_version = '2.58.0' glib_version = '2.66.0'
glib_dep = dependency('glib-2.0', version: '>=' + glib_version) glib_dep = dependency('glib-2.0', version: '>=' + glib_version)
gobject_dep = dependency('gobject-2.0', version: '>=' + glib_version) gobject_dep = dependency('gobject-2.0', version: '>=' + glib_version)
if host_machine.system() == 'windows' if host_machine.system() == 'windows'

View File

@ -1879,10 +1879,6 @@ virStorageSourceUpdatePhysicalSize;
# util/glibcompat.h # util/glibcompat.h
vir_g_fsync;
vir_g_source_unref;
vir_g_strdup_printf;
vir_g_strdup_vprintf;
vir_g_string_replace; vir_g_string_replace;

View File

@ -448,7 +448,7 @@ qemuAgentUnregister(qemuAgent *agent)
{ {
if (agent->watch) { if (agent->watch) {
g_source_destroy(agent->watch); g_source_destroy(agent->watch);
vir_g_source_unref(agent->watch, agent->context); g_source_unref(agent->watch);
agent->watch = NULL; agent->watch = NULL;
} }
} }

View File

@ -745,7 +745,7 @@ qemuMonitorUnregister(qemuMonitor *mon)
{ {
if (mon->watch) { if (mon->watch) {
g_source_destroy(mon->watch); g_source_destroy(mon->watch);
vir_g_source_unref(mon->watch, mon->context); g_source_unref(mon->watch);
mon->watch = NULL; mon->watch = NULL;
} }
} }

View File

@ -63,100 +63,6 @@
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #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 * Adapted (to pass syntax check) from 'g_string_replace' from
* glib-2.81.1. Drop once minimum glib is bumped to 2.68. * glib-2.81.1. Drop once minimum glib is bumped to 2.68.

View File

@ -42,24 +42,6 @@
#endif /* GLib < 2.67.0 */ #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 */ /* Drop once we require glib-2.68 at minimum */
guint guint
vir_g_string_replace(GString *string, vir_g_string_replace(GString *string,

View File

@ -213,7 +213,7 @@ virEventGLibHandleUpdate(int watch,
if (data->source != NULL) { if (data->source != NULL) {
VIR_DEBUG("Removed old handle source=%p", data->source); VIR_DEBUG("Removed old handle source=%p", data->source);
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
} }
data->source = virEventGLibAddSocketWatch( data->source = virEventGLibAddSocketWatch(
@ -227,7 +227,7 @@ virEventGLibHandleUpdate(int watch,
VIR_DEBUG("Removed old handle source=%p", data->source); VIR_DEBUG("Removed old handle source=%p", data->source);
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
data->source = NULL; data->source = NULL;
data->events = 0; data->events = 0;
} }
@ -276,7 +276,7 @@ virEventGLibHandleRemove(int watch)
if (data->source != NULL) { if (data->source != NULL) {
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
data->source = NULL; data->source = NULL;
data->events = 0; data->events = 0;
} }
@ -409,7 +409,7 @@ virEventGLibTimeoutUpdate(int timer,
if (interval >= 0) { if (interval >= 0) {
if (data->source != NULL) { if (data->source != NULL) {
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
} }
data->interval = interval; data->interval = interval;
@ -419,7 +419,7 @@ virEventGLibTimeoutUpdate(int timer,
goto cleanup; goto cleanup;
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
data->source = NULL; data->source = NULL;
} }
@ -468,7 +468,7 @@ virEventGLibTimeoutRemove(int timer)
if (data->source != NULL) { if (data->source != NULL) {
g_source_destroy(data->source); g_source_destroy(data->source);
vir_g_source_unref(data->source, NULL); g_source_unref(data->source);
data->source = NULL; data->source = NULL;
} }