OPT_LIST_COMMANDS,
};
+static struct mi_writer *writer;
+
static struct poptOption long_options[] = {
/* { longName, shortName, argInfo, argPtr, value, descrip, argDesc, } */
{ "help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0, },
while (cmd->func != NULL) {
/* Find command */
if (strcmp(argv[0], cmd->name) == 0) {
+ if (lttng_opt_mi) {
+ /* Action element */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_command_metadata_action);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Name of the action */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_name, argv[0]);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
command_ret = cmd->func(argc, argv);
+ if (lttng_opt_mi) {
+ /* Close output and action element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
goto end;
}
*/
int cmd_metadata(int argc, const char **argv)
{
- int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS;
+ int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1;
static poptContext pc;
if (argc < 1) {
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
+ if (lttng_opt_mi) {
+ writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);
+ if (!writer) {
+ ret = -LTTNG_ERR_NOMEM;
+ goto end;
+ }
+ /* Open command element */
+ ret = mi_lttng_writer_command_open(writer,
+ mi_lttng_element_command_metadata);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Open output element */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_command_output);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
case OPT_HELP:
switch (-command_ret) {
default:
ERR("%s", lttng_strerror(command_ret));
+ success = 0;
break;
}
}
+ if (lttng_opt_mi) {
+ /* Close output element */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Success ? */
+ ret = mi_lttng_writer_write_element_bool(writer,
+ mi_lttng_element_command_success, success);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+
+ /* Command element close */
+ ret = mi_lttng_writer_command_close(writer);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ }
+
end:
+ /* Mi clean-up */
+ if (writer && mi_lttng_writer_destroy(writer)) {
+ /* Preserve original error code */
+ ret = ret ? ret : -LTTNG_ERR_MI_IO_FAIL;
+ }
+
if (!opt_session_name) {
free(session_name);
}
</xs:sequence>
</xs:complexType>
- <!-- Maps to an action dutring snapshot command -->
+ <!-- Maps to an action during snapshot command -->
<xs:complexType name="snapshot_action_type">
<xs:sequence>
<xs:element name="name" type="tns:snapshot_actiontype_type" minOccurs="0" />
</xs:restriction>
</xs:simpleType>
+ <!-- Maps to an action during metadata command -->
+ <xs:complexType name="metadata_action_type">
+ <xs:sequence>
+ <xs:element name="name" type="tns:metadata_actiontype_type" minOccurs="0" />
+ </xs:sequence>
+ </xs:complexType>
+
+ <!-- Type of metadata commands -->
+ <xs:simpleType name="metadata_actiontype_type">
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="regenerate" />
+ </xs:restriction>
+ </xs:simpleType>
+
<xs:complexType name="output_type">
<xs:choice>
<xs:element name="domains" type="tns:domains_type" minOccurs="0" />
<xs:element name="events" type="tns:event_list_type" minOccurs="0" />
<xs:element name="channel" type="tns:channel_type" minOccurs="0" />
<xs:element name="targets" type="tns:targets_type" minOccurs="0" />
+ <xs:element name="metadata_action" type="tns:metadata_action_type" minOccurs="0" />
</xs:choice>
</xs:complexType>
<xs:enumeration value="disable-channel" />
<xs:enumeration value="track" />
<xs:enumeration value="untrack" />
+ <xs:enumeration value="metadata" />
</xs:restriction>
</xs:simpleType>