8 |
8 |
#include "qmp-commands.h"
|
9 |
9 |
|
10 |
10 |
static QemuOptsList *vm_config_groups[32];
|
|
11 |
static QemuOptsList *drive_config_groups[4];
|
11 |
12 |
|
12 |
13 |
static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
|
13 |
14 |
Error **errp)
|
... | ... | |
77 |
78 |
return param_list;
|
78 |
79 |
}
|
79 |
80 |
|
|
81 |
/* remove repeated entry from the info list */
|
|
82 |
static void cleanup_infolist(CommandLineParameterInfoList *head)
|
|
83 |
{
|
|
84 |
CommandLineParameterInfoList *pre_entry, *cur, *del_entry;
|
|
85 |
|
|
86 |
cur = head;
|
|
87 |
while (cur->next) {
|
|
88 |
pre_entry = head;
|
|
89 |
while (pre_entry != cur->next) {
|
|
90 |
if (!strcmp(pre_entry->value->name, cur->next->value->name)) {
|
|
91 |
del_entry = cur->next;
|
|
92 |
cur->next = cur->next->next;
|
|
93 |
g_free(del_entry);
|
|
94 |
break;
|
|
95 |
}
|
|
96 |
pre_entry = pre_entry->next;
|
|
97 |
}
|
|
98 |
cur = cur->next;
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
/* merge the description items of two parameter infolists */
|
|
103 |
static void connect_infolist(CommandLineParameterInfoList *head,
|
|
104 |
CommandLineParameterInfoList *new)
|
|
105 |
{
|
|
106 |
CommandLineParameterInfoList *cur;
|
|
107 |
|
|
108 |
cur = head;
|
|
109 |
while (cur->next) {
|
|
110 |
cur = cur->next;
|
|
111 |
}
|
|
112 |
cur->next = new;
|
|
113 |
}
|
|
114 |
|
|
115 |
/* access all the local QemuOptsLists for drive option */
|
|
116 |
static CommandLineParameterInfoList *get_drive_infolist(void)
|
|
117 |
{
|
|
118 |
CommandLineParameterInfoList *head = NULL, *cur;
|
|
119 |
int i;
|
|
120 |
|
|
121 |
for (i = 0; drive_config_groups[i] != NULL; i++) {
|
|
122 |
if (!head) {
|
|
123 |
head = query_option_descs(drive_config_groups[i]->desc);
|
|
124 |
} else {
|
|
125 |
cur = query_option_descs(drive_config_groups[i]->desc);
|
|
126 |
connect_infolist(head, cur);
|
|
127 |
}
|
|
128 |
}
|
|
129 |
cleanup_infolist(head);
|
|
130 |
|
|
131 |
return head;
|
|
132 |
}
|
|
133 |
|
80 |
134 |
CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
|
81 |
135 |
const char *option,
|
82 |
136 |
Error **errp)
|
... | ... | |
89 |
143 |
if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
|
90 |
144 |
info = g_malloc0(sizeof(*info));
|
91 |
145 |
info->option = g_strdup(vm_config_groups[i]->name);
|
92 |
|
info->parameters = query_option_descs(vm_config_groups[i]->desc);
|
|
146 |
if (!strcmp("drive", vm_config_groups[i]->name)) {
|
|
147 |
info->parameters = get_drive_infolist();
|
|
148 |
} else {
|
|
149 |
info->parameters =
|
|
150 |
query_option_descs(vm_config_groups[i]->desc);
|
|
151 |
}
|
93 |
152 |
entry = g_malloc0(sizeof(*entry));
|
94 |
153 |
entry->value = info;
|
95 |
154 |
entry->next = conf_list;
|
... | ... | |
109 |
168 |
return find_list(vm_config_groups, group, errp);
|
110 |
169 |
}
|
111 |
170 |
|
|
171 |
void qemu_add_drive_opts(QemuOptsList *list)
|
|
172 |
{
|
|
173 |
int entries, i;
|
|
174 |
|
|
175 |
entries = ARRAY_SIZE(drive_config_groups);
|
|
176 |
entries--; /* keep list NULL terminated */
|
|
177 |
for (i = 0; i < entries; i++) {
|
|
178 |
if (drive_config_groups[i] == NULL) {
|
|
179 |
drive_config_groups[i] = list;
|
|
180 |
return;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
fprintf(stderr, "ran out of space in drive_config_groups");
|
|
184 |
abort();
|
|
185 |
}
|
|
186 |
|
112 |
187 |
void qemu_add_opts(QemuOptsList *list)
|
113 |
188 |
{
|
114 |
189 |
int entries, i;
|