Skip to content

Commit

Permalink
xml/import: allow (and ignore for now) info children in more xml tags
Browse files Browse the repository at this point in the history
This commit is mostly for backport in v2.x since it will simplify
xml compatibility between 3.0 export and 2.x import.

Allow info tags inside all tags where it could be useful one day
(topology, page_type, distances2*, memattr). We already had them
in object and cpukind.

It's not clear yet whether we'll use info in more objects in v3
(distances and topology have been proposed but not decided yet),
but ignoring them is easy to make (current) v3 XML importable in v2.

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed May 16, 2023
1 parent c9c229b commit 806fa7b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions hwloc/topology-xml.c
Expand Up @@ -466,7 +466,13 @@ hwloc__xml_import_pagetype(hwloc_topology_t topology __hwloc_attribute_unused, s
char *attrname, *attrvalue;
if (state->global->next_attr(state, &attrname, &attrvalue) < 0)
break;
if (!strcmp(attrname, "size"))
if (!strcmp(attrname, "info")) {
char *infoname, *infovalue;
int ret = hwloc___xml_import_info(&infoname, &infovalue, state);
if (ret < 0)
return -1;
/* ignored */
} else if (!strcmp(attrname, "size"))
size = strtoull(attrvalue, NULL, 10);
else if (!strcmp(attrname, "count"))
count = strtoull(attrvalue, NULL, 10);
Expand Down Expand Up @@ -1066,7 +1072,14 @@ hwloc__xml_v2import_distances(hwloc_topology_t topology,
if (ret <= 0)
break;

if (!strcmp(tag, "indexes"))
if (!strcmp(tag, "info")) {
char *infoname, *infovalue;
ret = hwloc___xml_import_info(&infoname, &infovalue, state);
if (ret < 0)
return ret;
/* ignored */
continue;
} else if (!strcmp(tag, "indexes"))
is_index = 1;
else if (!strcmp(tag, "u64values"))
is_u64values = 1;
Expand Down Expand Up @@ -1399,6 +1412,10 @@ hwloc__xml_import_memattr(hwloc_topology_t topology,

if (!strcmp(tag, "memattr_value")) {
ret = hwloc__xml_import_memattr_value(topology, id, flags, &childstate);
} else if (!strcmp(tag, "info")) {
char *infoname, *infovalue;
ret = hwloc___xml_import_info(&infoname, &infovalue, &childstate);
/* ignored */
} else {
if (hwloc__xml_verbose())
fprintf(stderr, "%s: memattr with unrecognized child %s\n",
Expand Down Expand Up @@ -1734,6 +1751,12 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus)
ret = hwloc__xml_import_cpukind(topology, &childstate);
if (ret < 0)
goto failed;
} else if (!strcmp(tag, "info")) {
char *infoname, *infovalue;
ret = hwloc___xml_import_info(&infoname, &infovalue, &childstate);
if (ret < 0)
goto failed;
/* ignored */
} else {
if (hwloc__xml_verbose())
fprintf(stderr, "%s: ignoring unknown tag `%s' after root object.\n",
Expand Down

0 comments on commit 806fa7b

Please sign in to comment.