From nobody Fri Dec 19 19:13:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679065044; cv=none; d=zohomail.com; s=zohoarc; b=A3pl2Wmmr/Y2eODBstg+cqB8Vt6m/h7K8av/cyqSNBAmz7044sruxcKxSnpdaBLkxpNmOx1GgZ05UYs7iwHOfEuFO0wzR0lha5fjeFYCUK14GPFU2KclG+EmItY/NmhHt3EwTsY2UfR+cOt99z1OAoKzrXBkx753fUtMf6KnArI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679065044; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J+QLaWN7KkOnE0eOOmZNs5I/2eCV+TmAbj33GxrMZUw=; b=ONPEPodz25kuBZn/rQtOYKhoo2qzzLAiIrekQgcXcAnCtG7htOojAZbchZwjA3l7rr8ywkEyph+g4JObWQcOewyyLNgWlecvBrFE9LZvy8irXvm/ZdzRA3rVbnE6y7PUjmajrpeRidzwkfEaIN5PLQY4zR9cXBpVTct4aq9VQDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1679065044484828.9284668771779; Fri, 17 Mar 2023 07:57:24 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-p7I0RmdPP3Kk_yq72mH3dg-1; Fri, 17 Mar 2023 10:56:05 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 10D60884ECA; Fri, 17 Mar 2023 14:55:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0FEB40CF8F2; Fri, 17 Mar 2023 14:55:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B802A1946A49; Fri, 17 Mar 2023 14:55:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 95D591946587 for ; Thu, 16 Mar 2023 16:11:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 66A4F2166B29; Thu, 16 Mar 2023 16:11:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B60522166B26 for ; Thu, 16 Mar 2023 16:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679065043; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=J+QLaWN7KkOnE0eOOmZNs5I/2eCV+TmAbj33GxrMZUw=; b=F2bTABTjGReybWa63H55Q24j/xJ0dwFFArhj3wQ19udvbi11IJ2BkmdE85Vqt72R2Z91iW 61EeXWPbeE1WNVsSAOZYe/Qnza4OfX3EkMjH5u49Os4VYnS0QuQn+NXnWmzqX8H0780RNs UU+C8jOlKhV7SAGqV5XE5osTLr33Ur4= X-MC-Unique: p7I0RmdPP3Kk_yq72mH3dg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/24] virStringParseVersion: Parse into 'unsigned long long' Date: Thu, 16 Mar 2023 17:11:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679065046521100001 Content-Type: text/plain; charset="utf-8" Phase out 'unsigned long' Signed-off-by: Peter Krempa --- src/bhyve/bhyve_driver.c | 5 ++++- src/ch/ch_conf.c | 2 +- src/esx/esx_vi.h | 4 ++-- src/lxc/lxc_driver.c | 5 ++++- src/network/bridge_driver_linux.c | 2 +- src/openvz/openvz_conf.c | 2 +- src/util/virdnsmasq.c | 4 ++-- src/util/virfirewalld.c | 4 ++-- src/util/virfirewalld.h | 2 +- src/util/virstring.c | 4 ++-- src/util/virstring.h | 2 +- src/vbox/vbox_common.c | 5 ++++- src/vmware/vmware_conf.c | 5 ++++- src/vz/vz_utils.c | 5 ++++- tests/testutilsqemu.c | 4 ++-- tests/utiltest.c | 8 ++++---- tools/virt-host-validate-common.c | 2 +- 17 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index e7d9c2adf3..e948f890b9 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -248,6 +248,7 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int= flags) static int bhyveConnectGetVersion(virConnectPtr conn, unsigned long *version) { + unsigned long long tmpver; struct utsname ver; if (virConnectGetVersionEnsureACL(conn) < 0) @@ -255,12 +256,14 @@ bhyveConnectGetVersion(virConnectPtr conn, unsigned l= ong *version) uname(&ver); - if (virStringParseVersion(version, ver.release, true) < 0) { + if (virStringParseVersion(&tmpver, ver.release, true) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %s"), ver.release); return -1; } + *version =3D tmpver; + return 0; } diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 0d07fa270c..81ef729bc9 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -175,7 +175,7 @@ virCHDriverConfigDispose(void *obj) int chExtractVersion(virCHDriver *driver) { - unsigned long version; + unsigned long long version; g_autofree char *help =3D NULL; char *tmp =3D NULL; g_autofree char *ch_cmd =3D g_find_program_in_path(CH_CMD); diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h index 17d0bf9fea..b5eeaa750e 100644 --- a/src/esx/esx_vi.h +++ b/src/esx/esx_vi.h @@ -179,9 +179,9 @@ struct _esxVI_Context { char *username; char *password; esxVI_ServiceContent *service; - unsigned long apiVersion; /* =3D 1000000 * major + 1000 * minor + micr= o */ + unsigned long long apiVersion; /* =3D 1000000 * major + 1000 * minor += micro */ esxVI_ProductLine productLine; - unsigned long productVersion; /* =3D 1000000 * major + 1000 * minor + = micro */ + unsigned long long productVersion; /* =3D 1000000 * major + 1000 * min= or + micro */ esxVI_UserSession *session; /* ... except the session ... */ virMutex *sessionLock; /* ... that is protected by this mutex */ esxVI_Datacenter *datacenter; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b1d53659d7..623e8cfbb3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1641,6 +1641,7 @@ lxcConnectSupportsFeature(virConnectPtr conn, int fea= ture) static int lxcConnectGetVersion(virConnectPtr conn, unsigned long *version) { + unsigned long long tmpver; struct utsname ver; uname(&ver); @@ -1648,11 +1649,13 @@ static int lxcConnectGetVersion(virConnectPtr conn,= unsigned long *version) if (virConnectGetVersionEnsureACL(conn) < 0) return -1; - if (virStringParseVersion(version, ver.release, true) < 0) { + if (virStringParseVersion(&tmpver, ver.release, true) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %s"), v= er.release); return -1; } + *version =3D tmpver; + return 0; } diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_= linux.c index d9597d91be..6e80435913 100644 --- a/src/network/bridge_driver_linux.c +++ b/src/network/bridge_driver_linux.c @@ -871,7 +871,7 @@ int networkAddFirewallRules(virNetworkDef *def) if (virFirewallDInterfaceSetZone(def->bridge, "libvirt") <= 0) return -1; } else { - unsigned long version; + unsigned long long version; int vresult =3D virFirewallDGetVersion(&version); if (vresult < 0) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index c28d0e9f43..005f73d013 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -64,7 +64,7 @@ strtoI(const char *str) static int openvzExtractVersionInfo(const char *cmdstr, int *retversion) { - unsigned long version; + unsigned long long version; g_autofree char *help =3D NULL; char *tmp; g_autoptr(virCommand) cmd =3D virCommandNewArgList(cmdstr, "--help", N= ULL); diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 342b489ab7..91d8080b92 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -604,7 +604,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) { int len; const char *p; - unsigned long version; + unsigned long long version; p =3D STRSKIP(buf, DNSMASQ_VERSION_STR); if (!p) @@ -617,7 +617,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) if (version < DNSMASQ_MIN_MAJOR * 1000000 + DNSMASQ_MIN_MINOR * 1000) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("dnsmasq version >=3D %u.%u required but %lu.%lu = found"), + _("dnsmasq version >=3D %u.%u required but %llu.%ll= u found"), DNSMASQ_MIN_MAJOR, DNSMASQ_MIN_MINOR, version / 1000000, version % 1000000 / 1000); diff --git a/src/util/virfirewalld.c b/src/util/virfirewalld.c index d11e974cc2..06f8d49837 100644 --- a/src/util/virfirewalld.c +++ b/src/util/virfirewalld.c @@ -80,7 +80,7 @@ virFirewallDIsRegistered(void) * Returns 0 if version was successfully retrieved, or -1 on error */ int -virFirewallDGetVersion(unsigned long *version) +virFirewallDGetVersion(unsigned long long *version) { GDBusConnection *sysbus =3D virGDBusGetSystemBus(); g_autoptr(GVariant) message =3D NULL; @@ -114,7 +114,7 @@ virFirewallDGetVersion(unsigned long *version) return -1; } - VIR_DEBUG("FirewallD version: %s - %lu", versionStr, *version); + VIR_DEBUG("FirewallD version: %s - %llu", versionStr, *version); return 0; } diff --git a/src/util/virfirewalld.h b/src/util/virfirewalld.h index fa4c9e702c..004d10ec29 100644 --- a/src/util/virfirewalld.h +++ b/src/util/virfirewalld.h @@ -29,7 +29,7 @@ typedef enum { VIR_FIREWALLD_BACKEND_LAST, } virFirewallDBackendType; -int virFirewallDGetVersion(unsigned long *version); +int virFirewallDGetVersion(unsigned long long *version); int virFirewallDGetBackend(void); int virFirewallDIsRegistered(void); int virFirewallDGetZones(char ***zones, size_t *nzones); diff --git a/src/util/virstring.c b/src/util/virstring.c index 7b7aee6179..c0c7b7ea8b 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -1022,7 +1022,7 @@ int virStringParseYesNo(const char *str, bool *result) /** * virStringParseVersion: - * @version: unsigned long pointer to output the version number + * @version: unsigned long long pointer to output the version number * @str: const char pointer to the version string * @allowMissing: true to treat 3 like 3.0.0, false to error out on * missing minor or micro @@ -1037,7 +1037,7 @@ int virStringParseYesNo(const char *str, bool *result) * Returns the 0 for success, -1 for error. */ int -virStringParseVersion(unsigned long *version, +virStringParseVersion(unsigned long long *version, const char *str, bool allowMissing) { diff --git a/src/util/virstring.h b/src/util/virstring.h index ec8ceb0022..0f8b5d0664 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -136,6 +136,6 @@ int virStringParseYesNo(const char *str, bool *result) G_GNUC_WARN_UNUSED_RESULT; -int virStringParseVersion(unsigned long *version, +int virStringParseVersion(unsigned long long *version, const char *str, bool allowMissing); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 7aed421390..d1dffe3df7 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -272,6 +272,7 @@ vboxExtractVersion(void) int ret =3D -1; PRUnichar *versionUtf16 =3D NULL; char *vboxVersion =3D NULL; + unsigned long long version; nsresult rc; if (vbox_driver->version > 0) @@ -283,9 +284,11 @@ vboxExtractVersion(void) gVBoxAPI.UPFN.Utf16ToUtf8(vbox_driver->pFuncs, versionUtf16, &vboxVers= ion); - if (virStringParseVersion(&vbox_driver->version, vboxVersion, false) >= =3D 0) + if (virStringParseVersion(&version, vboxVersion, false) >=3D 0) ret =3D 0; + vbox_driver->version =3D version; + gVBoxAPI.UPFN.Utf8Free(vbox_driver->pFuncs, vboxVersion); gVBoxAPI.UPFN.ComUnallocMem(vbox_driver->pFuncs, versionUtf16); vboxVersion =3D NULL; diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 5703ce717e..77a592e3b7 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -197,6 +197,7 @@ vmwareSetSentinal(const char **prog, const char *key) int vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version) { + unsigned long long tmpver; const char *pattern; const char *tmp; @@ -228,12 +229,14 @@ vmwareParseVersionStr(int type, const char *verbuf, u= nsigned long *version) return -1; } - if (virStringParseVersion(version, tmp, false) < 0) { + if (virStringParseVersion(&tmpver, tmp, false) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("version parsing error")); return -1; } + *version =3D tmpver; + return 0; } diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c index 219d13823b..c6e4a58771 100644 --- a/src/vz/vz_utils.c +++ b/src/vz/vz_utils.c @@ -154,6 +154,7 @@ vzInitVersion(struct _vzDriver *driver) g_autofree char *output =3D NULL; char *sVer, *tmp; const char *searchStr =3D "prlsrvctl version "; + unsigned long long version; int ret =3D -1; output =3D vzGetOutput(PRLSRVCTL, "--help", NULL); @@ -183,11 +184,13 @@ vzInitVersion(struct _vzDriver *driver) } tmp[0] =3D '\0'; - if (virStringParseVersion(&(driver->vzVersion), sVer, true) < 0) { + if (virStringParseVersion(&version, sVer, true) < 0) { vzParseError(); return -1; } + driver->vzVersion =3D version; + vzInitCaps(driver->vzVersion, &driver->vzCaps); return 0; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index a5780dc746..41727cfd1a 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -718,8 +718,8 @@ testQemuGetLatestCapsForArch(const char *arch, g_autoptr(DIR) dir =3D NULL; int rc; g_autofree char *fullsuffix =3D NULL; - unsigned long maxver =3D 0; - unsigned long ver; + unsigned long long maxver =3D 0; + unsigned long long ver; g_autofree char *maxname =3D NULL; fullsuffix =3D g_strdup_printf("%s.%s", arch, suffix); diff --git a/tests/utiltest.c b/tests/utiltest.c index e90baca65f..5930557c08 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -124,7 +124,7 @@ struct testVersionString const char *string; bool allowMissing; int result; - unsigned long version; + unsigned long long version; }; static struct testVersionString versions[] =3D { @@ -146,7 +146,7 @@ testParseVersionString(const void *data G_GNUC_UNUSED) { int result; size_t i; - unsigned long version; + unsigned long long version; for (i =3D 0; i < G_N_ELEMENTS(versions); ++i) { result =3D virStringParseVersion(&version, versions[i].string, @@ -165,8 +165,8 @@ testParseVersionString(const void *data G_GNUC_UNUSED) if (version !=3D versions[i].version) { VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string); - VIR_TEST_DEBUG("Expect version [%lu]", versions[i].version); - VIR_TEST_DEBUG("Actual version [%lu]", version); + VIR_TEST_DEBUG("Expect version [%llu]", versions[i].version); + VIR_TEST_DEBUG("Actual version [%llu]", version); return -1; } diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index a41bb346d2..08fcdc1173 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -251,7 +251,7 @@ int virHostValidateLinuxKernel(const char *hvname, const char *hint) { struct utsname uts; - unsigned long thisversion; + unsigned long long thisversion; uname(&uts); --=20 2.39.2