From nobody Sun Oct 5 01:49:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1757494054; cv=none; d=zohomail.com; s=zohoarc; b=OyqwdQhrhKTe9xXc0L1y7rJxNMOhRaXUu0YdzsKOYAqgaJlgiRSBkU7uyRSHPpBZj6OHymEotSf4ZqQXJ1vsHi+1z6+EGRdSPg65qgZTqXSr6ENVEf5OnrSV5TS4+HBI9/maXIjnJm5+R0o+qpy5N5M3AizOH4YneNV3GsPcBrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757494054; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=cZ6IRfjrTyZWfPBgOIr9tp/oboYseYQRhuYhfE6+mbY=; b=XFKEXyfcpYQS/Wdb6Ruwg6ivC4RDBo/cyKpbc7rx9kvzXZYW6ZsIQO9wO3WZNhTAyOF5zkIDkjh1Ev7Lhr1Ssp/92PtCVuAJnWWIQk+PFl8R5b7mG01gHdMderPx8rc7uMNuitLerkU4id7tlwfa45VxCCJ1c2RL079XI5Wbhjs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 175749405411616.538143793238874; Wed, 10 Sep 2025 01:47:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 28C9241BA0; Wed, 10 Sep 2025 04:47:33 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3D8BE43DBF; Wed, 10 Sep 2025 04:45:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4988E41A01; Wed, 10 Sep 2025 04:44:58 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3C5CE419E3 for ; Wed, 10 Sep 2025 04:44:57 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-88-YSZ6_jz9OyCO9AmayTV4Hg-1; Wed, 10 Sep 2025 04:44:55 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC2901955F45 for ; Wed, 10 Sep 2025 08:44:54 +0000 (UTC) Received: from hjs (unknown [10.43.3.187]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 126333000198 for ; Wed, 10 Sep 2025 08:44:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757493896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cZ6IRfjrTyZWfPBgOIr9tp/oboYseYQRhuYhfE6+mbY=; b=FtUfTdPGBtd7JTo28pG2CVJJfB/iSk+iS4KCc65eLUVKxKEiudqd9/8E9CVxjGtAXD2Cn6 KxYIo+agx0lQyfVI3zy+1mQ4kfiSjTw4UivP/42yrbDL+1IF0cJ33ZSGFpKelmw+N6yCqJ AidsNbWGa/XGZuuDIDS9P8K2DuWMIJs= X-MC-Unique: YSZ6_jz9OyCO9AmayTV4Hg-1 X-Mimecast-MFC-AGG-ID: YSZ6_jz9OyCO9AmayTV4Hg_1757493894 To: devel@lists.libvirt.org Subject: [libvirt PATCH 1/2] build: bump minimum glib version to 2.68 Date: Wed, 10 Sep 2025 10:43:49 +0200 Message-ID: <6691f6aea5639a556e821f9b0749a4a71cc5b6a4.1757493830.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tNx7NOWRcniYELMbePk1VzMKvlq1MhvWnvTrCsCDOug_1757493894 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GGPKEHC3PSTU3YBQA3YA7YSOZAYIFVSW X-Message-ID-Hash: GGPKEHC3PSTU3YBQA3YA7YSOZAYIFVSW X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?J=C3=A1n_Tomko_via_Devel?= Reply-To: =?UTF-8?q?J=C3=A1n=20Tomko?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1757494074687154100 From: J=C3=A1n Tomko We removed support for Debian 11 which only had 2.66.8. Next stop: 2.72 after we drop Ubuntu 22.04 For libvirt, the update to the 2.68 GLib release: * introduces g_string_replace * deprecates g_memdup in favor of g_memdup2 * removes the need for some warning workarounds * deprecates g_time_zone_new in favor of g_time_zone_new_identifier which returns NULL on error instead of returning UTC Signed-off-by: J=C3=A1n Tomko --- meson.build | 2 +- src/conf/virdomainjob.c | 6 +- src/esx/esx_vi_types.c | 9 ++- src/internal.h | 24 ------ src/libvirt_private.syms | 4 - src/qemu/qemu_capabilities.c | 8 +- src/util/glibcompat.c | 149 ----------------------------------- src/util/glibcompat.h | 29 ------- 8 files changed, 13 insertions(+), 218 deletions(-) diff --git a/meson.build b/meson.build index 0d64a77a4c..5d261a0e4f 100644 --- a/meson.build +++ b/meson.build @@ -981,7 +981,7 @@ else endif endif =20 -glib_version =3D '2.66.0' +glib_version =3D '2.68' glib_dep =3D dependency('glib-2.0', version: '>=3D' + glib_version) gobject_dep =3D dependency('gobject-2.0', version: '>=3D' + glib_version) if host_machine.system() =3D=3D 'windows' diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index 2d5a857a8c..99c362d593 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -129,8 +129,8 @@ virDomainObjInitJob(virDomainJobObj *job, virDomainJobDataPrivateDataCallbacks *jobDataPrivateCb) { memset(job, 0, sizeof(*job)); - job->cb =3D g_memdup(cb, sizeof(*cb)); - job->jobDataPrivateCb =3D g_memdup(jobDataPrivateCb, sizeof(*jobDataPr= ivateCb)); + job->cb =3D g_memdup2(cb, sizeof(*cb)); + job->jobDataPrivateCb =3D g_memdup2(jobDataPrivateCb, sizeof(*jobDataP= rivateCb)); =20 if (virCondInit(&job->cond) < 0) return -1; @@ -212,7 +212,7 @@ virDomainObjPreserveJob(virDomainJobObj *currJob, if (currJob->cb && currJob->cb->allocJobPrivate && !(currJob->privateData =3D currJob->cb->allocJobPrivate())) return -1; - job->cb =3D g_memdup(currJob->cb, sizeof(*currJob->cb)); + job->cb =3D g_memdup2(currJob->cb, sizeof(*currJob->cb)); =20 virDomainObjResetJob(currJob); virDomainObjResetAsyncJob(currJob); diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 9386727fcf..614e7939c3 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1512,11 +1512,12 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime= *dateTime, } =20 /* parse timezone offset if present. if missing assume UTC */ - if (*tmp =3D=3D '+' || *tmp =3D=3D '-') { - tz =3D g_time_zone_new(tmp); - } else if (STREQ(tmp, "Z")) { + if (STREQ(tmp, "Z")) tz =3D g_time_zone_new_utc(); - } else { + + if (*tmp =3D=3D '+' || *tmp =3D=3D '-') + tz =3D g_time_zone_new_identifier(tmp); + if (!tz) { virReportError(VIR_ERR_INTERNAL_ERROR, _("xsd:dateTime value '%1$s' has unexpected for= mat"), dateTime->value); diff --git a/src/internal.h b/src/internal.h index bd62a25ef8..8200480394 100644 --- a/src/internal.h +++ b/src/internal.h @@ -152,30 +152,6 @@ # endif #endif =20 -/** - * - * G_GNUC_FALLTHROUGH - * - * silence the compiler warning when falling through a switch case - * - * Note: GLib 2.69.0 introduced version checks on the - * macro usage. Thus an app setting GLIB_VERSION_MAX_ALLOWED - * to less than 2.60 will trigger a warning using G_GNUC_FALLTHROUGH - * Normally the warning is a good thing, but we want to use our - * fallback impl, so we have to temporarily cull the GLib macro. - * - * All this should be removed once updating to min GLib >=3D 2.60 - */ -#if GLIB_CHECK_VERSION(2, 69, 0) -# undef G_GNUC_FALLTHROUGH -#endif -#ifndef G_GNUC_FALLTHROUGH -# if __GNUC_PREREQ (7, 0) -# define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) -# else -# define G_GNUC_FALLTHROUGH do {} while(0) -# endif -#endif =20 /** * diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b846011f0f..fe72402527 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1899,10 +1899,6 @@ virStorageSourceUpdateCapacity; virStorageSourceUpdatePhysicalSize; =20 =20 -# util/glibcompat.h -vir_g_string_replace; - - # util/viracpi.c virAcpiHasSMMU; virAcpiParseIORT; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7f6abed1aa..618291e5b6 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2070,8 +2070,8 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGX_EPC)) virQEMUCapsSGXInfoCopy(&ret->sgxCapabilities, qemuCaps->sgxCapabil= ities); =20 - ret->hypervCapabilities =3D g_memdup(qemuCaps->hypervCapabilities, - sizeof(virDomainCapsFeatureHyperv)); + ret->hypervCapabilities =3D g_memdup2(qemuCaps->hypervCapabilities, + sizeof(virDomainCapsFeatureHyperv)= ); =20 return g_steal_pointer(&ret); } @@ -6930,8 +6930,8 @@ static void virQEMUCapsFillDomainFeatureHypervCaps(virQEMUCaps *qemuCaps, virDomainCaps *domCaps) { - domCaps->hyperv =3D g_memdup(qemuCaps->hypervCapabilities, - sizeof(virDomainCapsFeatureHyperv)); + domCaps->hyperv =3D g_memdup2(qemuCaps->hypervCapabilities, + sizeof(virDomainCapsFeatureHyperv)); } =20 =20 diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 47e3edef13..dd19c7ac43 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -62,152 +62,3 @@ =20 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -/** - * Adapted (to pass syntax check) from 'g_string_replace' from - * glib-2.83.3. Drop once minimum glib is bumped to 2.68. - * - * g_string_replace: - * @string: a #GString - * @find: the string to find in @string - * @replace: the string to insert in place of @find - * @limit: the maximum instances of @find to replace with @replace, or `0`= for - * no limit - * - * Replaces the string @find with the string @replace in a #GString up to - * @limit times. If the number of instances of @find in the #GString is - * less than @limit, all instances are replaced. If @limit is `0`, - * all instances of @find are replaced. - * - * If @find is the empty string, since versions 2.69.1 and 2.68.4 the - * replacement will be inserted no more than once per possible position - * (beginning of string, end of string and between characters). This did - * not work correctly in earlier versions. - * - * Returns: the number of find and replace operations performed. - * - * Since: 2.68 - */ -guint -vir_g_string_replace(GString *string, - const gchar *find, - const gchar *replace, - guint limit) -{ - GString *new_string =3D NULL; - gsize f_len, r_len, new_len; - gchar *cur, *next, *first, *dst; - guint n; - - g_return_val_if_fail(string !=3D NULL, 0); - g_return_val_if_fail(find !=3D NULL, 0); - g_return_val_if_fail(replace !=3D NULL, 0); - - first =3D strstr(string->str, find); - - if (first =3D=3D NULL) - return 0; - - new_len =3D string->len; - f_len =3D strlen(find); - r_len =3D strlen(replace); - - /* It removes a lot of branches and possibility for infinite loops if = we - * handle the case of an empty @find string separately. */ - if (G_UNLIKELY(f_len =3D=3D 0)) { - size_t i; - if (limit =3D=3D 0 || limit > string->len) { - if (string->len > G_MAXSIZE - 1) - g_error("inserting in every position in string would overf= low"); - - limit =3D string->len + 1; - } - - if (r_len > 0 && - (limit > G_MAXSIZE / r_len || - limit * r_len > G_MAXSIZE - string->len)) - g_error("inserting in every position in string would overflow"= ); - - new_len =3D string->len + limit * r_len; - new_string =3D g_string_sized_new(new_len); - for (i =3D 0; i < limit; i++) { - g_string_append_len(new_string, replace, r_len); - if (i < string->len) - g_string_append_c(new_string, string->str[i]); - } - if (limit < string->len) - g_string_append_len(new_string, string->str + limit, string->l= en - limit); - - g_free(string->str); - string->allocated_len =3D new_string->allocated_len; - string->len =3D new_string->len; - string->str =3D g_string_free(g_steal_pointer(&new_string), FALSE); - - return limit; - } - /* Potentially do two passes: the first to calculate the length of the= new string, - * new_len, if it=E2=80=99s going to be longer than the original strin= g; and the second to - * do the replacements. The first pass is skipped if the new string is= going to be - * no longer than the original. - * - * The second pass calls various g_string_insert_len() (and similar) m= ethods - * which would normally potentially reallocate string->str, and hence - * invalidate the cur/next/first/dst pointers. Because we=E2=80=99ve p= re-calculated - * the new_len and do all the string manipulations on new_string, that - * shouldn=E2=80=99t happen. This means we scan `string` while modifyi= ng - * `new_string`. */ - do { - dst =3D first; - cur =3D first; - n =3D 0; - while ((next =3D strstr(cur, find)) !=3D NULL) { - n++; - - if (r_len <=3D f_len) { - memmove(dst, cur, next - cur); - dst +=3D next - cur; - memcpy(dst, replace, r_len); - dst +=3D r_len; - } else { - if (new_string =3D=3D NULL) { - new_len +=3D r_len - f_len; - } else { - g_string_append_len(new_string, cur, next - cur); - g_string_append_len(new_string, replace, r_len); - } - } - cur =3D next + f_len; - - if (n =3D=3D limit) - break; - } - - /* Append the trailing characters from after the final instance of= @find - * in the input string. */ - if (r_len <=3D f_len) { - /* First pass skipped. */ - gchar *end =3D string->str + string->len; - memmove(dst, cur, end - cur); - end =3D dst + (end - cur); - *end =3D 0; - string->len =3D end - string->str; - break; - } else { - if (new_string =3D=3D NULL) { - /* First pass. */ - new_string =3D g_string_sized_new(new_len); - g_string_append_len(new_string, string->str, first - strin= g->str); - } else { - /* Second pass. */ - g_string_append_len(new_string, cur, (string->str + string= ->len) - cur); - g_free(string->str); - string->allocated_len =3D new_string->allocated_len; - string->len =3D new_string->len; - string->str =3D g_string_free(g_steal_pointer(&new_string)= , FALSE); - break; - } - } - } while (1); - - return n; -} diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index a3d01089e6..5eb63e3cce 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -22,35 +22,6 @@ #include #include =20 -#if !GLIB_CHECK_VERSION(2, 67, 0) - -/* - * ...meanwhile GCC >=3D 11 has started issuing warnings about volatile - * from the old G_DEFINE_TYPE macro impl. IOW the new macros impls fixed - * new GCC, but broke CLang - */ -# if !defined(__clang__) && __GNUC_PREREQ (11, 0) -# undef _G_DEFINE_TYPE_EXTENDED_BEGIN - -# define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, = flags) \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wincompatible-pointer-types\"") \ - _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \ - _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PAREN= T, flags) \ - _Pragma("GCC diagnostic pop") -# endif /* !clang && GCC >=3D 11.0 */ - -#endif /* GLib < 2.67.0 */ - -/* Drop once we require glib-2.68 at minimum */ -guint -vir_g_string_replace(GString *string, - const gchar *find, - const gchar *replace, - guint limit); -#undef g_string_replace -#define g_string_replace vir_g_string_replace - #if !GLIB_CHECK_VERSION(2, 73, 2) # if (defined(__has_attribute) && __has_attribute(__noinline__)) || G_GNUC= _CHECK_VERSION (2, 96) # if defined (__cplusplus) && __cplusplus >=3D 201103L --=20 2.50.1