mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
qemu-option: qemu_opts_validate(): fix duplicated code
Use opts_accepts_any() and find_desc_by_name(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
c474ced8fe
commit
db97ceba1e
1 changed files with 3 additions and 11 deletions
|
@ -1076,23 +1076,15 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
|
||||||
QemuOpt *opt;
|
QemuOpt *opt;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
assert(opts->list->desc[0].name == NULL);
|
assert(opts_accepts_any(opts));
|
||||||
|
|
||||||
QTAILQ_FOREACH(opt, &opts->head, next) {
|
QTAILQ_FOREACH(opt, &opts->head, next) {
|
||||||
int i;
|
opt->desc = find_desc_by_name(desc, opt->name);
|
||||||
|
if (!opt->desc) {
|
||||||
for (i = 0; desc[i].name != NULL; i++) {
|
|
||||||
if (strcmp(desc[i].name, opt->name) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (desc[i].name == NULL) {
|
|
||||||
error_set(errp, QERR_INVALID_PARAMETER, opt->name);
|
error_set(errp, QERR_INVALID_PARAMETER, opt->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt->desc = &desc[i];
|
|
||||||
|
|
||||||
qemu_opt_parse(opt, &local_err);
|
qemu_opt_parse(opt, &local_err);
|
||||||
if (error_is_set(&local_err)) {
|
if (error_is_set(&local_err)) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue