mirror of https://github.com/xemu-project/xemu.git
QemuOpts: add find_list()
Factor out the QemuOptsList search code for upcoming users. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
3e03236438
commit
ddc978550d
|
@ -212,17 +212,9 @@ static QemuOptsList *lists[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
int qemu_set_option(const char *str)
|
static QemuOptsList *find_list(const char *group)
|
||||||
{
|
{
|
||||||
char group[64], id[64], arg[64];
|
int i;
|
||||||
QemuOpts *opts;
|
|
||||||
int i, rc, offset;
|
|
||||||
|
|
||||||
rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
|
|
||||||
if (rc < 3 || str[offset] != '=') {
|
|
||||||
qemu_error("can't parse: \"%s\"\n", str);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; lists[i] != NULL; i++) {
|
for (i = 0; lists[i] != NULL; i++) {
|
||||||
if (strcmp(lists[i]->name, group) == 0)
|
if (strcmp(lists[i]->name, group) == 0)
|
||||||
|
@ -230,13 +222,32 @@ int qemu_set_option(const char *str)
|
||||||
}
|
}
|
||||||
if (lists[i] == NULL) {
|
if (lists[i] == NULL) {
|
||||||
qemu_error("there is no option group \"%s\"\n", group);
|
qemu_error("there is no option group \"%s\"\n", group);
|
||||||
|
}
|
||||||
|
return lists[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
int qemu_set_option(const char *str)
|
||||||
|
{
|
||||||
|
char group[64], id[64], arg[64];
|
||||||
|
QemuOptsList *list;
|
||||||
|
QemuOpts *opts;
|
||||||
|
int rc, offset;
|
||||||
|
|
||||||
|
rc = sscanf(str, "%63[^.].%63[^.].%63[^=]%n", group, id, arg, &offset);
|
||||||
|
if (rc < 3 || str[offset] != '=') {
|
||||||
|
qemu_error("can't parse: \"%s\"\n", str);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = qemu_opts_find(lists[i], id);
|
list = find_list(group);
|
||||||
|
if (list == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
opts = qemu_opts_find(list, id);
|
||||||
if (!opts) {
|
if (!opts) {
|
||||||
qemu_error("there is no %s \"%s\" defined\n",
|
qemu_error("there is no %s \"%s\" defined\n",
|
||||||
lists[i]->name, id);
|
list->name, id);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue