X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvm_power_manager%2Fvm_power_cli.c;h=7edeaccda5ba60f10bed6cf21ca0de28c06e8cf9;hb=4ad736ce03d22e917f7de16fd4ba24d9b49edce9;hp=41e89ff202bcdc3bb846e3c51115d3213c4787cf;hpb=5776b7a371d1635aea5f15dd5f79fdc0cafdb63d;p=dpdk.git diff --git a/examples/vm_power_manager/vm_power_cli.c b/examples/vm_power_manager/vm_power_cli.c index 41e89ff202..7edeaccda5 100644 --- a/examples/vm_power_manager/vm_power_cli.c +++ b/examples/vm_power_manager/vm_power_cli.c @@ -27,9 +27,9 @@ struct cmd_quit_result { cmdline_fixed_string_t quit; }; -static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, +static void cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { channel_monitor_exit(); channel_manager_exit(); @@ -58,7 +58,7 @@ struct cmd_show_vm_result { static void cmd_show_vm_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_show_vm_result *res = parsed_result; struct vm_info info; @@ -135,7 +135,7 @@ struct cmd_set_pcpu_result { static void cmd_set_pcpu_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_set_pcpu_result *res = parsed_result; @@ -182,7 +182,7 @@ struct cmd_vm_op_result { static void cmd_vm_op_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_vm_op_result *res = parsed_result; @@ -221,11 +221,11 @@ struct cmd_channels_op_result { }; static void cmd_channels_op_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { unsigned num_channels = 0, channel_num, i; int channels_added; - unsigned channel_list[CHANNEL_CMDS_MAX_VM_CHANNELS]; + unsigned int channel_list[RTE_MAX_LCORE]; char *token, *remaining, *tail_ptr; struct cmd_channels_op_result *res = parsed_result; @@ -249,10 +249,10 @@ cmd_channels_op_parsed(void *parsed_result, struct cmdline *cl, if ((errno != 0) || tail_ptr == NULL || (*tail_ptr != '\0')) break; - if (channel_num == CHANNEL_CMDS_MAX_VM_CHANNELS) { + if (channel_num == RTE_MAX_LCORE) { cmdline_printf(cl, "Channel number '%u' exceeds the maximum number " "of allowable channels(%u) for VM '%s'\n", channel_num, - CHANNEL_CMDS_MAX_VM_CHANNELS, res->vm_name); + RTE_MAX_LCORE, res->vm_name); return; } channel_list[num_channels++] = channel_num; @@ -293,6 +293,53 @@ cmdline_parse_inst_t cmd_channels_op_set = { }, }; +struct cmd_set_query_result { + cmdline_fixed_string_t set_query; + cmdline_fixed_string_t vm_name; + cmdline_fixed_string_t query_status; +}; + +static void +cmd_set_query_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_query_result *res = parsed_result; + + if (!strcmp(res->query_status, "enable")) { + if (set_query_status(res->vm_name, true) < 0) + cmdline_printf(cl, "Unable to allow query for VM '%s'\n", + res->vm_name); + } else if (!strcmp(res->query_status, "disable")) { + if (set_query_status(res->vm_name, false) < 0) + cmdline_printf(cl, "Unable to disallow query for VM '%s'\n", + res->vm_name); + } +} + +cmdline_parse_token_string_t cmd_set_query = + TOKEN_STRING_INITIALIZER(struct cmd_set_query_result, + set_query, "set_query"); +cmdline_parse_token_string_t cmd_set_query_vm_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_query_result, + vm_name, NULL); +cmdline_parse_token_string_t cmd_set_query_status = + TOKEN_STRING_INITIALIZER(struct cmd_set_query_result, + query_status, "enable#disable"); + +cmdline_parse_inst_t cmd_set_query_set = { + .f = cmd_set_query_parsed, + .data = NULL, + .help_str = "set_query , allow or disallow queries" + " for the specified VM", + .tokens = { + (void *)&cmd_set_query, + (void *)&cmd_set_query_vm_name, + (void *)&cmd_set_query_status, + NULL, + }, +}; + struct cmd_channels_status_op_result { cmdline_fixed_string_t op; cmdline_fixed_string_t vm_name; @@ -302,11 +349,11 @@ struct cmd_channels_status_op_result { static void cmd_channels_status_op_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { unsigned num_channels = 0, channel_num; int changed; - unsigned channel_list[CHANNEL_CMDS_MAX_VM_CHANNELS]; + unsigned int channel_list[RTE_MAX_LCORE]; char *token, *remaining, *tail_ptr; struct cmd_channels_status_op_result *res = parsed_result; enum channel_status status; @@ -334,10 +381,10 @@ cmd_channels_status_op_parsed(void *parsed_result, struct cmdline *cl, if ((errno != 0) || tail_ptr == NULL || (*tail_ptr != '\0')) break; - if (channel_num == CHANNEL_CMDS_MAX_VM_CHANNELS) { + if (channel_num == RTE_MAX_LCORE) { cmdline_printf(cl, "%u exceeds the maximum number of allowable " "channels(%u) for VM '%s'\n", channel_num, - CHANNEL_CMDS_MAX_VM_CHANNELS, res->vm_name); + RTE_MAX_LCORE, res->vm_name); return; } channel_list[num_channels++] = channel_num; @@ -388,7 +435,7 @@ struct cmd_show_cpu_freq_result { static void cmd_show_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { struct cmd_show_cpu_freq_result *res = parsed_result; uint32_t curr_freq = power_manager_get_current_frequency(res->core_num); @@ -429,7 +476,7 @@ struct cmd_set_cpu_freq_result { static void cmd_set_cpu_freq_parsed(void *parsed_result, struct cmdline *cl, - __attribute__((unused)) void *data) + __rte_unused void *data) { int ret = -1; struct cmd_set_cpu_freq_result *res = parsed_result; @@ -484,11 +531,12 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_show_cpu_freq_set, (cmdline_parse_inst_t *)&cmd_set_cpu_freq_set, (cmdline_parse_inst_t *)&cmd_set_pcpu_set, + (cmdline_parse_inst_t *)&cmd_set_query_set, NULL, }; void -run_cli(__attribute__((unused)) void *arg) +run_cli(__rte_unused void *arg) { struct cmdline *cl;