mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 06:25:19 +00:00
testQemuGetLatestCapsForArch: Rewrite using testQemuGetLatestCaps
Fetch the full hash of 'latest' files and just return the correct one. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
a13f37265b
commit
5153a67c19
@ -731,54 +731,22 @@ char *
|
|||||||
testQemuGetLatestCapsForArch(const char *arch,
|
testQemuGetLatestCapsForArch(const char *arch,
|
||||||
const char *suffix)
|
const char *suffix)
|
||||||
{
|
{
|
||||||
struct dirent *ent;
|
g_autoptr(GHashTable) caps = testQemuGetLatestCaps();
|
||||||
g_autoptr(DIR) dir = NULL;
|
struct testQemuCapsFile *f;
|
||||||
int rc;
|
|
||||||
g_autofree char *fullsuffix = NULL;
|
|
||||||
unsigned long long maxver = 0;
|
|
||||||
unsigned long long ver;
|
|
||||||
g_autofree char *maxname = NULL;
|
|
||||||
|
|
||||||
fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
|
if (!(f = g_hash_table_lookup(caps, arch))) {
|
||||||
|
|
||||||
if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
|
|
||||||
g_autofree char *tmp = NULL;
|
|
||||||
|
|
||||||
tmp = g_strdup(STRSKIP(ent->d_name, "caps_"));
|
|
||||||
|
|
||||||
if (!tmp)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!virStringStripSuffix(tmp, fullsuffix))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (virStringParseVersion(&ver, tmp, false) < 0) {
|
|
||||||
VIR_TEST_DEBUG("skipping caps file '%s'", ent->d_name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ver > maxver) {
|
|
||||||
g_free(maxname);
|
|
||||||
maxname = g_strdup(ent->d_name);
|
|
||||||
maxver = ver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!maxname) {
|
|
||||||
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'",
|
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'",
|
||||||
arch, TEST_QEMU_CAPS_PATH);
|
arch, TEST_QEMU_CAPS_PATH);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
|
if (STRNEQ(suffix, "xml")) {
|
||||||
}
|
ignore_value(virStringStripSuffix(f->path, "xml"));
|
||||||
|
return g_strdup_printf("%s%s", f->path, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_steal_pointer(&f->path);
|
||||||
|
}
|
||||||
|
|
||||||
GHashTable *
|
GHashTable *
|
||||||
testQemuGetLatestCaps(void)
|
testQemuGetLatestCaps(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user