Skip to content

Commit 1c288c9

Browse files
committed
xml/import/v2: move v2 root info attrs to topo when appropriate
Signed-off-by: Brice Goglin <[email protected]>
1 parent 45f5e07 commit 1c288c9

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

hwloc/topology-xml.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ hwloc___xml_import_info(char **infonamep, char **infovaluep,
434434
}
435435

436436
static int
437-
hwloc__xml_import_obj_info(hwloc_obj_t obj,
437+
hwloc__xml_import_obj_info(hwloc_topology_t topology,
438+
hwloc_obj_t obj,
438439
hwloc__xml_import_state_t state)
439440
{
440441
char *infoname = NULL;
@@ -447,8 +448,25 @@ hwloc__xml_import_obj_info(hwloc_obj_t obj,
447448

448449
if (infoname) {
449450
/* empty strings are ignored by libxml */
450-
if (infovalue)
451-
hwloc_obj_add_info(obj, infoname, infovalue);
451+
if (infovalue) {
452+
if (!obj->parent && (
453+
!strcmp(infoname, "Backend")
454+
|| !strcmp(infoname, "SyntheticDescription")
455+
|| !strcmp(infoname, "LinuxCgroup")
456+
|| !strcmp(infoname, "WindowsBuildEnvironment")
457+
|| !strcmp(infoname, "OSName")
458+
|| !strcmp(infoname, "OSRelease")
459+
|| !strcmp(infoname, "OSVersion")
460+
|| !strcmp(infoname, "HostName")
461+
|| !strcmp(infoname, "Architecture")
462+
|| !strcmp(infoname, "hwlocVersion")
463+
|| !strcmp(infoname, "ProcessName"))) {
464+
/* topo infos were in root in v2 */
465+
hwloc__add_info(&topology->infos, infoname, infovalue);
466+
} else {
467+
hwloc_obj_add_info(obj, infoname, infovalue);
468+
}
469+
}
452470
}
453471

454472
return err;
@@ -699,7 +717,7 @@ hwloc__xml_import_object(hwloc_topology_t topology,
699717
}
700718

701719
} else if (!strcmp(tag, "info")) {
702-
ret = hwloc__xml_import_obj_info(obj, &childstate);
720+
ret = hwloc__xml_import_obj_info(topology, obj, &childstate);
703721
} else if (!strcmp(tag, "userdata")) {
704722
ret = hwloc__xml_import_userdata(topology, obj, &childstate);
705723
} else {

0 commit comments

Comments
 (0)