mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virStringParseVersion: Parse into 'unsigned long long'
Phase out 'unsigned long' Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
396cf39400
commit
5b738195a2
@ -248,6 +248,7 @@ bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
|
|||||||
static int
|
static int
|
||||||
bhyveConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
bhyveConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
||||||
{
|
{
|
||||||
|
unsigned long long tmpver;
|
||||||
struct utsname ver;
|
struct utsname ver;
|
||||||
|
|
||||||
if (virConnectGetVersionEnsureACL(conn) < 0)
|
if (virConnectGetVersionEnsureACL(conn) < 0)
|
||||||
@ -255,12 +256,14 @@ bhyveConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
|||||||
|
|
||||||
uname(&ver);
|
uname(&ver);
|
||||||
|
|
||||||
if (virStringParseVersion(version, ver.release, true) < 0) {
|
if (virStringParseVersion(&tmpver, ver.release, true) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unknown release: %1$s"), ver.release);
|
_("Unknown release: %1$s"), ver.release);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*version = tmpver;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ virCHDriverConfigDispose(void *obj)
|
|||||||
int
|
int
|
||||||
chExtractVersion(virCHDriver *driver)
|
chExtractVersion(virCHDriver *driver)
|
||||||
{
|
{
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
g_autofree char *help = NULL;
|
g_autofree char *help = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
|
g_autofree char *ch_cmd = g_find_program_in_path(CH_CMD);
|
||||||
|
@ -179,9 +179,9 @@ struct _esxVI_Context {
|
|||||||
char *username;
|
char *username;
|
||||||
char *password;
|
char *password;
|
||||||
esxVI_ServiceContent *service;
|
esxVI_ServiceContent *service;
|
||||||
unsigned long apiVersion; /* = 1000000 * major + 1000 * minor + micro */
|
unsigned long long apiVersion; /* = 1000000 * major + 1000 * minor + micro */
|
||||||
esxVI_ProductLine productLine;
|
esxVI_ProductLine productLine;
|
||||||
unsigned long productVersion; /* = 1000000 * major + 1000 * minor + micro */
|
unsigned long long productVersion; /* = 1000000 * major + 1000 * minor + micro */
|
||||||
esxVI_UserSession *session; /* ... except the session ... */
|
esxVI_UserSession *session; /* ... except the session ... */
|
||||||
virMutex *sessionLock; /* ... that is protected by this mutex */
|
virMutex *sessionLock; /* ... that is protected by this mutex */
|
||||||
esxVI_Datacenter *datacenter;
|
esxVI_Datacenter *datacenter;
|
||||||
|
@ -1641,6 +1641,7 @@ lxcConnectSupportsFeature(virConnectPtr conn, int feature)
|
|||||||
|
|
||||||
static int lxcConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
static int lxcConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
||||||
{
|
{
|
||||||
|
unsigned long long tmpver;
|
||||||
struct utsname ver;
|
struct utsname ver;
|
||||||
|
|
||||||
uname(&ver);
|
uname(&ver);
|
||||||
@ -1648,11 +1649,13 @@ static int lxcConnectGetVersion(virConnectPtr conn, unsigned long *version)
|
|||||||
if (virConnectGetVersionEnsureACL(conn) < 0)
|
if (virConnectGetVersionEnsureACL(conn) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virStringParseVersion(version, ver.release, true) < 0) {
|
if (virStringParseVersion(&tmpver, ver.release, true) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %1$s"), ver.release);
|
virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown release: %1$s"), ver.release);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*version = tmpver;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,7 +869,7 @@ int networkAddFirewallRules(virNetworkDef *def)
|
|||||||
if (virFirewallDInterfaceSetZone(def->bridge, "libvirt") < 0)
|
if (virFirewallDInterfaceSetZone(def->bridge, "libvirt") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
int vresult = virFirewallDGetVersion(&version);
|
int vresult = virFirewallDGetVersion(&version);
|
||||||
|
|
||||||
if (vresult < 0)
|
if (vresult < 0)
|
||||||
|
@ -64,7 +64,7 @@ strtoI(const char *str)
|
|||||||
static int
|
static int
|
||||||
openvzExtractVersionInfo(const char *cmdstr, int *retversion)
|
openvzExtractVersionInfo(const char *cmdstr, int *retversion)
|
||||||
{
|
{
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
g_autofree char *help = NULL;
|
g_autofree char *help = NULL;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
g_autoptr(virCommand) cmd = virCommandNewArgList(cmdstr, "--help", NULL);
|
g_autoptr(virCommand) cmd = virCommandNewArgList(cmdstr, "--help", NULL);
|
||||||
|
@ -603,7 +603,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char *buf)
|
|||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
const char *p;
|
const char *p;
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
|
|
||||||
p = STRSKIP(buf, DNSMASQ_VERSION_STR);
|
p = STRSKIP(buf, DNSMASQ_VERSION_STR);
|
||||||
if (!p)
|
if (!p)
|
||||||
@ -616,7 +616,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char *buf)
|
|||||||
|
|
||||||
if (version < DNSMASQ_MIN_MAJOR * 1000000 + DNSMASQ_MIN_MINOR * 1000) {
|
if (version < DNSMASQ_MIN_MAJOR * 1000000 + DNSMASQ_MIN_MINOR * 1000) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("dnsmasq version >= %1$u.%2$u required but %3$lu.%4$lu found"),
|
_("dnsmasq version >= %1$u.%2$u required but %3$llu.%4$llu found"),
|
||||||
DNSMASQ_MIN_MAJOR, DNSMASQ_MIN_MINOR,
|
DNSMASQ_MIN_MAJOR, DNSMASQ_MIN_MINOR,
|
||||||
version / 1000000,
|
version / 1000000,
|
||||||
version % 1000000 / 1000);
|
version % 1000000 / 1000);
|
||||||
|
@ -80,7 +80,7 @@ virFirewallDIsRegistered(void)
|
|||||||
* Returns 0 if version was successfully retrieved, or -1 on error
|
* Returns 0 if version was successfully retrieved, or -1 on error
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virFirewallDGetVersion(unsigned long *version)
|
virFirewallDGetVersion(unsigned long long *version)
|
||||||
{
|
{
|
||||||
GDBusConnection *sysbus = virGDBusGetSystemBus();
|
GDBusConnection *sysbus = virGDBusGetSystemBus();
|
||||||
g_autoptr(GVariant) message = NULL;
|
g_autoptr(GVariant) message = NULL;
|
||||||
@ -114,7 +114,7 @@ virFirewallDGetVersion(unsigned long *version)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("FirewallD version: %s - %lu", versionStr, *version);
|
VIR_DEBUG("FirewallD version: %s - %llu", versionStr, *version);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ typedef enum {
|
|||||||
VIR_FIREWALLD_BACKEND_LAST,
|
VIR_FIREWALLD_BACKEND_LAST,
|
||||||
} virFirewallDBackendType;
|
} virFirewallDBackendType;
|
||||||
|
|
||||||
int virFirewallDGetVersion(unsigned long *version);
|
int virFirewallDGetVersion(unsigned long long *version);
|
||||||
int virFirewallDGetBackend(void);
|
int virFirewallDGetBackend(void);
|
||||||
int virFirewallDIsRegistered(void);
|
int virFirewallDIsRegistered(void);
|
||||||
int virFirewallDGetZones(char ***zones, size_t *nzones);
|
int virFirewallDGetZones(char ***zones, size_t *nzones);
|
||||||
|
@ -1022,7 +1022,7 @@ int virStringParseYesNo(const char *str, bool *result)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* virStringParseVersion:
|
* 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
|
* @str: const char pointer to the version string
|
||||||
* @allowMissing: true to treat 3 like 3.0.0, false to error out on
|
* @allowMissing: true to treat 3 like 3.0.0, false to error out on
|
||||||
* missing minor or micro
|
* missing minor or micro
|
||||||
@ -1037,7 +1037,7 @@ int virStringParseYesNo(const char *str, bool *result)
|
|||||||
* Returns the 0 for success, -1 for error.
|
* Returns the 0 for success, -1 for error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStringParseVersion(unsigned long *version,
|
virStringParseVersion(unsigned long long *version,
|
||||||
const char *str,
|
const char *str,
|
||||||
bool allowMissing)
|
bool allowMissing)
|
||||||
{
|
{
|
||||||
|
@ -136,6 +136,6 @@ int virStringParseYesNo(const char *str,
|
|||||||
bool *result)
|
bool *result)
|
||||||
G_GNUC_WARN_UNUSED_RESULT;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
int virStringParseVersion(unsigned long *version,
|
int virStringParseVersion(unsigned long long *version,
|
||||||
const char *str,
|
const char *str,
|
||||||
bool allowMissing);
|
bool allowMissing);
|
||||||
|
@ -272,6 +272,7 @@ vboxExtractVersion(void)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
PRUnichar *versionUtf16 = NULL;
|
PRUnichar *versionUtf16 = NULL;
|
||||||
char *vboxVersion = NULL;
|
char *vboxVersion = NULL;
|
||||||
|
unsigned long long version;
|
||||||
nsresult rc;
|
nsresult rc;
|
||||||
|
|
||||||
if (vbox_driver->version > 0)
|
if (vbox_driver->version > 0)
|
||||||
@ -283,9 +284,11 @@ vboxExtractVersion(void)
|
|||||||
|
|
||||||
gVBoxAPI.UPFN.Utf16ToUtf8(vbox_driver->pFuncs, versionUtf16, &vboxVersion);
|
gVBoxAPI.UPFN.Utf16ToUtf8(vbox_driver->pFuncs, versionUtf16, &vboxVersion);
|
||||||
|
|
||||||
if (virStringParseVersion(&vbox_driver->version, vboxVersion, false) >= 0)
|
if (virStringParseVersion(&version, vboxVersion, false) >= 0)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
vbox_driver->version = version;
|
||||||
|
|
||||||
gVBoxAPI.UPFN.Utf8Free(vbox_driver->pFuncs, vboxVersion);
|
gVBoxAPI.UPFN.Utf8Free(vbox_driver->pFuncs, vboxVersion);
|
||||||
gVBoxAPI.UPFN.ComUnallocMem(vbox_driver->pFuncs, versionUtf16);
|
gVBoxAPI.UPFN.ComUnallocMem(vbox_driver->pFuncs, versionUtf16);
|
||||||
vboxVersion = NULL;
|
vboxVersion = NULL;
|
||||||
|
@ -197,6 +197,7 @@ vmwareSetSentinal(const char **prog, const char *key)
|
|||||||
int
|
int
|
||||||
vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
|
vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
|
||||||
{
|
{
|
||||||
|
unsigned long long tmpver;
|
||||||
const char *pattern;
|
const char *pattern;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
@ -228,12 +229,14 @@ vmwareParseVersionStr(int type, const char *verbuf, unsigned long *version)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStringParseVersion(version, tmp, false) < 0) {
|
if (virStringParseVersion(&tmpver, tmp, false) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("version parsing error"));
|
_("version parsing error"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*version = tmpver;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ vzInitVersion(struct _vzDriver *driver)
|
|||||||
g_autofree char *output = NULL;
|
g_autofree char *output = NULL;
|
||||||
char *sVer, *tmp;
|
char *sVer, *tmp;
|
||||||
const char *searchStr = "prlsrvctl version ";
|
const char *searchStr = "prlsrvctl version ";
|
||||||
|
unsigned long long version;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
output = vzGetOutput(PRLSRVCTL, "--help", NULL);
|
output = vzGetOutput(PRLSRVCTL, "--help", NULL);
|
||||||
@ -183,11 +184,13 @@ vzInitVersion(struct _vzDriver *driver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmp[0] = '\0';
|
tmp[0] = '\0';
|
||||||
if (virStringParseVersion(&(driver->vzVersion), sVer, true) < 0) {
|
if (virStringParseVersion(&version, sVer, true) < 0) {
|
||||||
vzParseError();
|
vzParseError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
driver->vzVersion = version;
|
||||||
|
|
||||||
vzInitCaps(driver->vzVersion, &driver->vzCaps);
|
vzInitCaps(driver->vzVersion, &driver->vzCaps);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -718,8 +718,8 @@ testQemuGetLatestCapsForArch(const char *arch,
|
|||||||
g_autoptr(DIR) dir = NULL;
|
g_autoptr(DIR) dir = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
g_autofree char *fullsuffix = NULL;
|
g_autofree char *fullsuffix = NULL;
|
||||||
unsigned long maxver = 0;
|
unsigned long long maxver = 0;
|
||||||
unsigned long ver;
|
unsigned long long ver;
|
||||||
g_autofree char *maxname = NULL;
|
g_autofree char *maxname = NULL;
|
||||||
|
|
||||||
fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
|
fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
|
||||||
|
@ -124,7 +124,7 @@ struct testVersionString
|
|||||||
const char *string;
|
const char *string;
|
||||||
bool allowMissing;
|
bool allowMissing;
|
||||||
int result;
|
int result;
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct testVersionString versions[] = {
|
static struct testVersionString versions[] = {
|
||||||
@ -146,7 +146,7 @@ testParseVersionString(const void *data G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
size_t i;
|
size_t i;
|
||||||
unsigned long version;
|
unsigned long long version;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(versions); ++i) {
|
for (i = 0; i < G_N_ELEMENTS(versions); ++i) {
|
||||||
result = virStringParseVersion(&version, versions[i].string,
|
result = virStringParseVersion(&version, versions[i].string,
|
||||||
@ -165,8 +165,8 @@ testParseVersionString(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (version != versions[i].version) {
|
if (version != versions[i].version) {
|
||||||
VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
|
VIR_TEST_DEBUG("\nVersion string [%s]", versions[i].string);
|
||||||
VIR_TEST_DEBUG("Expect version [%lu]", versions[i].version);
|
VIR_TEST_DEBUG("Expect version [%llu]", versions[i].version);
|
||||||
VIR_TEST_DEBUG("Actual version [%lu]", version);
|
VIR_TEST_DEBUG("Actual version [%llu]", version);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ int virHostValidateLinuxKernel(const char *hvname,
|
|||||||
const char *hint)
|
const char *hint)
|
||||||
{
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
unsigned long thisversion;
|
unsigned long long thisversion;
|
||||||
|
|
||||||
uname(&uts);
|
uname(&uts);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user