diff --git a/ovni.c b/ovni.c index fc0c863..2f6d01b 100644 --- a/ovni.c +++ b/ovni.c @@ -167,6 +167,19 @@ proc_set_app(int appid) die("json_object_set_number for app_id failed\n"); } +static void +proc_set_version(void) +{ + JSON_Object *meta = json_value_get_object(rproc.meta); + + if(meta == NULL) + die("json_value_get_object failed\n"); + + if(json_object_set_number(meta, "version", OVNI_METADATA_VERSION) != 0) + die("json_object_set_number for app_id failed\n"); +} + + void ovni_proc_set_rank(int rank, int nranks) { @@ -246,6 +259,7 @@ ovni_proc_init(int app, const char *loom, int pid) rproc.ready = 1; + proc_set_version(); proc_set_app(app); } diff --git a/ovni.h b/ovni.h index c0617ab..e27f298 100644 --- a/ovni.h +++ b/ovni.h @@ -40,6 +40,8 @@ extern "C" { /* Hardcode the JSON_Value to avoid a dependency with janson */ typedef struct json_value_t JSON_Value; +#define OVNI_METADATA_VERSION 1 + #define OVNI_TRACEDIR "ovni" #define OVNI_MAX_HOSTNAME 512 diff --git a/trace.c b/trace.c index 2eb8304..f79b47d 100644 --- a/trace.c +++ b/trace.c @@ -124,6 +124,29 @@ load_proc_metadata(struct ovni_eproc *proc, int *rank_enabled) } } +static void +check_metadata_version(struct ovni_eproc *proc) +{ + JSON_Object *meta = json_value_get_object(proc->meta); + if(meta == NULL) + die("check_metadata_version: json_value_get_object() failed\n"); + + JSON_Value *version_val = json_object_get_value(meta, "version"); + if(version_val == NULL) + { + die("process %d is missing attribute \"version\" in metadata\n", + proc->pid); + } + + int version = (int) json_number(version_val); + + if(version != OVNI_METADATA_VERSION) + { + die("pid %d: metadata version mismatch %d (expected %d)\n", + proc->pid, version, + OVNI_METADATA_VERSION); + } +} static int load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, char *procdir) @@ -156,6 +179,8 @@ load_proc(struct ovni_eproc *proc, struct ovni_loom *loom, int index, int pid, c return -1; } + check_metadata_version(proc); + /* The appid is populated from the metadata */ load_proc_metadata(proc, &loom->rank_enabled);