Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import 3.0 xmls in 2.x #567

Open
wants to merge 2 commits into
base: v2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions 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.
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions 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.
Expand Down Expand Up @@ -1160,6 +1160,13 @@ hwloc__xml_import_object(hwloc_topology_t topology,
data->last_numanode = obj;
}

/* 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.
*
Expand Down Expand Up @@ -2094,9 +2101,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;
}
Expand Down