qemu-config.c (b785d25e91718a660546a6550f64b3c543af7754) qemu-config.c (54aa3de72ea2aaa2e903e7e879a4f3dda515a00e)
1#include "qemu/osdep.h"
2#include "block/qdict.h" /* for qdict_extract_subqdict() */
3#include "qapi/error.h"
4#include "qapi/qapi-commands-misc.h"
5#include "qapi/qmp/qdict.h"
6#include "qapi/qmp/qlist.h"
7#include "qemu/error-report.h"
8#include "qemu/option.h"

--- 41 unchanged lines hidden (view full) ---

50 if (!opts) {
51 opts = qemu_opts_create(list, NULL, 0, &error_abort);
52 }
53 return opts;
54}
55
56static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
57{
1#include "qemu/osdep.h"
2#include "block/qdict.h" /* for qdict_extract_subqdict() */
3#include "qapi/error.h"
4#include "qapi/qapi-commands-misc.h"
5#include "qapi/qmp/qdict.h"
6#include "qapi/qmp/qlist.h"
7#include "qemu/error-report.h"
8#include "qemu/option.h"

--- 41 unchanged lines hidden (view full) ---

50 if (!opts) {
51 opts = qemu_opts_create(list, NULL, 0, &error_abort);
52 }
53 return opts;
54}
55
56static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
57{
58 CommandLineParameterInfoList *param_list = NULL, *entry;
58 CommandLineParameterInfoList *param_list = NULL;
59 CommandLineParameterInfo *info;
60 int i;
61
62 for (i = 0; desc[i].name != NULL; i++) {
63 info = g_malloc0(sizeof(*info));
64 info->name = g_strdup(desc[i].name);
65
66 switch (desc[i].type) {

--- 15 unchanged lines hidden (view full) ---

82 info->has_help = true;
83 info->help = g_strdup(desc[i].help);
84 }
85 if (desc[i].def_value_str) {
86 info->has_q_default = true;
87 info->q_default = g_strdup(desc[i].def_value_str);
88 }
89
59 CommandLineParameterInfo *info;
60 int i;
61
62 for (i = 0; desc[i].name != NULL; i++) {
63 info = g_malloc0(sizeof(*info));
64 info->name = g_strdup(desc[i].name);
65
66 switch (desc[i].type) {

--- 15 unchanged lines hidden (view full) ---

82 info->has_help = true;
83 info->help = g_strdup(desc[i].help);
84 }
85 if (desc[i].def_value_str) {
86 info->has_q_default = true;
87 info->q_default = g_strdup(desc[i].def_value_str);
88 }
89
90 entry = g_malloc0(sizeof(*entry));
91 entry->value = info;
92 entry->next = param_list;
93 param_list = entry;
90 QAPI_LIST_PREPEND(param_list, info);
94 }
95
96 return param_list;
97}
98
99/* remove repeated entry from the info list */
100static void cleanup_infolist(CommandLineParameterInfoList *head)
101{

--- 139 unchanged lines hidden (view full) ---

241 { /* End of list */ }
242 }
243};
244
245CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
246 const char *option,
247 Error **errp)
248{
91 }
92
93 return param_list;
94}
95
96/* remove repeated entry from the info list */
97static void cleanup_infolist(CommandLineParameterInfoList *head)
98{

--- 139 unchanged lines hidden (view full) ---

238 { /* End of list */ }
239 }
240};
241
242CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
243 const char *option,
244 Error **errp)
245{
249 CommandLineOptionInfoList *conf_list = NULL, *entry;
246 CommandLineOptionInfoList *conf_list = NULL;
250 CommandLineOptionInfo *info;
251 int i;
252
253 for (i = 0; vm_config_groups[i] != NULL; i++) {
254 if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
255 info = g_malloc0(sizeof(*info));
256 info->option = g_strdup(vm_config_groups[i]->name);
257 if (!strcmp("drive", vm_config_groups[i]->name)) {
258 info->parameters = get_drive_infolist();
259 } else if (!strcmp("machine", vm_config_groups[i]->name)) {
260 info->parameters = query_option_descs(machine_opts.desc);
261 } else {
262 info->parameters =
263 query_option_descs(vm_config_groups[i]->desc);
264 }
247 CommandLineOptionInfo *info;
248 int i;
249
250 for (i = 0; vm_config_groups[i] != NULL; i++) {
251 if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
252 info = g_malloc0(sizeof(*info));
253 info->option = g_strdup(vm_config_groups[i]->name);
254 if (!strcmp("drive", vm_config_groups[i]->name)) {
255 info->parameters = get_drive_infolist();
256 } else if (!strcmp("machine", vm_config_groups[i]->name)) {
257 info->parameters = query_option_descs(machine_opts.desc);
258 } else {
259 info->parameters =
260 query_option_descs(vm_config_groups[i]->desc);
261 }
265 entry = g_malloc0(sizeof(*entry));
266 entry->value = info;
267 entry->next = conf_list;
268 conf_list = entry;
262 QAPI_LIST_PREPEND(conf_list, info);
269 }
270 }
271
272 if (conf_list == NULL) {
273 error_setg(errp, "invalid option name: %s", option);
274 }
275
276 return conf_list;

--- 264 unchanged lines hidden ---
263 }
264 }
265
266 if (conf_list == NULL) {
267 error_setg(errp, "invalid option name: %s", option);
268 }
269
270 return conf_list;

--- 264 unchanged lines hidden ---