+ const struct lttng_ust_event_field **choices;
+ char tag_field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
+ const struct lttng_type *tag_type;
+ const struct lttng_ust_event_field *tag_field_generic;
+ struct lttng_ust_event_field tag_field = {
+ .name = tag_field_name,
+ .nowrite = 0,
+ };
+ struct ustctl_field *uf;
+ size_t nr_choices, i;
+ int ret;
+
+ tag_field_generic = lttng_ust_dynamic_type_tag_field();
+ tag_type = &tag_field_generic->type;
+
+ /* Serialize enum field. */
+ strncpy(tag_field_name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
+ tag_field_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
+ strncat(tag_field_name,
+ "_tag",
+ LTTNG_UST_ABI_SYM_NAME_LEN - strlen(tag_field_name) - 1);
+ tag_field.type = *tag_type;
+ ret = serialize_one_field(session, fields, iter_output,
+ &tag_field);
+ if (ret)
+ return ret;
+
+ /* Serialize variant field. */
+ uf = &fields[*iter_output];
+ ret = lttng_ust_dynamic_type_choices(&nr_choices, &choices);
+ if (ret)
+ return ret;
+
+ strncpy(uf->name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
+ uf->name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
+ uf->type.atype = ustctl_atype_variant;
+ uf->type.u.variant_nestable.nr_choices = nr_choices;
+ strncpy(uf->type.u.variant_nestable.tag_name,
+ tag_field_name,
+ LTTNG_UST_ABI_SYM_NAME_LEN);
+ uf->type.u.variant_nestable.tag_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
+ uf->type.u.variant_nestable.alignment = 0;
+ (*iter_output)++;
+
+ /* Serialize choice fields after variant. */
+ for (i = 0; i < nr_choices; i++) {
+ ret = serialize_one_field(session, fields,
+ iter_output, choices[i]);
+ if (ret)
+ return ret;