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:
Dong Xu Wang 2012-12-06 14:47:19 +08:00 committed by Kevin Wolf
parent c474ced8fe
commit db97ceba1e
1 changed files with 3 additions and 11 deletions

View File

@ -1076,23 +1076,15 @@ void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp)
QemuOpt *opt;
Error *local_err = NULL;
assert(opts->list->desc[0].name == NULL);
assert(opts_accepts_any(opts));
QTAILQ_FOREACH(opt, &opts->head, next) {
int i;
for (i = 0; desc[i].name != NULL; i++) {
if (strcmp(desc[i].name, opt->name) == 0) {
break;
}
}
if (desc[i].name == NULL) {
opt->desc = find_desc_by_name(desc, opt->name);
if (!opt->desc) {
error_set(errp, QERR_INVALID_PARAMETER, opt->name);
return;
}
opt->desc = &desc[i];
qemu_opt_parse(opt, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);