From bffbb3ece8f38f98b9ce6a8ea0e46c9c222d708b Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Thu, 26 Jan 2023 11:30:28 +0100 Subject: [PATCH 1/2] xml/import: allow xml 3.0 (and not 3.1 and later) Signed-off-by: Brice Goglin --- hwloc/topology-xml-libxml.c | 7 ++++--- hwloc/topology-xml.c | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hwloc/topology-xml-libxml.c b/hwloc/topology-xml-libxml.c index c328bc885f..53b8982991 100644 --- a/hwloc/topology-xml-libxml.c +++ b/hwloc/topology-xml-libxml.c @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2018 Inria. All rights reserved. + * Copyright © 2009-2023 Inria. All rights reserved. * Copyright © 2009-2011, 2020 Université Bordeaux * Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. @@ -188,10 +188,11 @@ hwloc_libxml_look_init(struct hwloc_xml_backend_data_s *bdata, fprintf(stderr, "%s: Loading XML topology without DTD\n", state->global->msgprefix); } else if (strcmp((char *) dtd->SystemID, "hwloc.dtd") - && strcmp((char *) dtd->SystemID, "hwloc2.dtd")) { + && strcmp((char *) dtd->SystemID, "hwloc2.dtd") + && strcmp((char *) dtd->SystemID, "hwloc3.dtd")) { if (hwloc__xml_verbose()) fprintf(stderr, "%s: Loading XML topology with wrong DTD SystemID (%s instead of %s)\n", - state->global->msgprefix, (char *) dtd->SystemID, "hwloc.dtd or hwloc2.dtd"); + state->global->msgprefix, (char *) dtd->SystemID, "hwloc.dtd, hwloc2.dtd or hwloc3.dtd"); } root_node = xmlDocGetRootElement((xmlDocPtr) bdata->data); diff --git a/hwloc/topology-xml.c b/hwloc/topology-xml.c index b1f20dbf29..67d1e3ee37 100644 --- a/hwloc/topology-xml.c +++ b/hwloc/topology-xml.c @@ -1,6 +1,6 @@ /* * Copyright © 2009 CNRS - * Copyright © 2009-2022 Inria. All rights reserved. + * Copyright © 2009-2023 Inria. All rights reserved. * Copyright © 2009-2011, 2020 Université Bordeaux * Copyright © 2009-2018 Cisco Systems, Inc. All rights reserved. * See COPYING in top-level directory. @@ -1160,6 +1160,9 @@ hwloc__xml_import_object(hwloc_topology_t topology, data->last_numanode = obj; } + /* 3.0 forward compatibility */ + + if (!hwloc_filter_check_keep_object(topology, obj)) { /* Ignore this object instead of inserting it. * @@ -2094,9 +2097,10 @@ hwloc_look_xml(struct hwloc_backend *backend, struct hwloc_disc_status *dstatus) if (ret < 0) goto failed; - if (data->version_major > 2) { + if (data->version_major > 3 + || (data->version_major == 3 && data->version_minor > 0)) { if (hwloc__xml_verbose()) - fprintf(stderr, "%s: cannot import XML version %u.%u > 2\n", + fprintf(stderr, "%s: cannot import XML version %u.%u > 3.0\n", data->msgprefix, data->version_major, data->version_minor); goto err; } From 1a3c1d55fd5b957e047c69355ed0ff495cbf2bf0 Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Thu, 26 Jan 2023 11:38:10 +0100 Subject: [PATCH 2/2] xml/import: convert 3.0 "memory" osdev back into "block" Signed-off-by: Brice Goglin --- hwloc/topology-xml.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hwloc/topology-xml.c b/hwloc/topology-xml.c index 67d1e3ee37..fc53b590cb 100644 --- a/hwloc/topology-xml.c +++ b/hwloc/topology-xml.c @@ -1161,7 +1161,11 @@ hwloc__xml_import_object(hwloc_topology_t topology, } /* 3.0 forward compatibility */ - + if (data->version_major >= 3 && obj->type == HWLOC_OBJ_OS_DEVICE) { + /* block replaced by storage+memory in 3.0 */ + if (obj->attr->osdev.type == 6 /* MEMORY */) + obj->attr->osdev.type = HWLOC_OBJ_OSDEV_BLOCK; + } if (!hwloc_filter_check_keep_object(topology, obj)) { /* Ignore this object instead of inserting it.