const char *qemu_opt_get(QemuOpts *opts, const char *name)
{
QemuOpt *opt;
+ const QemuOptDesc *desc;
if (opts == NULL) {
return NULL;
opt = qemu_opt_find(opts, name);
if (!opt) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
+ desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
return desc->def_value_str;
}
bool defval, bool del)
{
QemuOpt *opt;
+ const QemuOptDesc *desc;
bool ret = defval;
if (opts == NULL) {
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
+ desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_bool(name, desc->def_value_str, &ret, &error_abort);
}
uint64_t defval, bool del)
{
QemuOpt *opt;
+ const QemuOptDesc *desc;
uint64_t ret = defval;
if (opts == NULL) {
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
+ desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_number(name, desc->def_value_str, &ret, &error_abort);
}
uint64_t defval, bool del)
{
QemuOpt *opt;
+ const QemuOptDesc *desc;
uint64_t ret = defval;
if (opts == NULL) {
opt = qemu_opt_find(opts, name);
if (opt == NULL) {
- const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name);
+ desc = find_desc_by_name(opts->list->desc, name);
if (desc && desc->def_value_str) {
parse_option_size(name, desc->def_value_str, &ret, &error_abort);
}
Error **errp)
{
QemuOpt *opt;
- const QemuOptDesc *desc = opts->list->desc;
+ const QemuOptDesc *desc;
- opt = g_malloc0(sizeof(*opt));
- opt->desc = find_desc_by_name(desc, name);
- if (!opt->desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(opts->list->desc, name);
+ if (!desc && !opts_accepts_any(opts)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
- g_free(opt);
return;
}
+ opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
opt->opts = opts;
+ opt->desc = desc;
opt->value.boolean = !!val;
opt->str = g_strdup(val ? "on" : "off");
QTAILQ_INSERT_TAIL(&opts->head, opt, next);
Error **errp)
{
QemuOpt *opt;
- const QemuOptDesc *desc = opts->list->desc;
+ const QemuOptDesc *desc;
- opt = g_malloc0(sizeof(*opt));
- opt->desc = find_desc_by_name(desc, name);
- if (!opt->desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(opts->list->desc, name);
+ if (!desc && !opts_accepts_any(opts)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
- g_free(opt);
return;
}
+ opt = g_malloc0(sizeof(*opt));
opt->name = g_strdup(name);
opt->opts = opts;
+ opt->desc = desc;
opt->value.uint = val;
opt->str = g_strdup_printf("%" PRId64, val);
QTAILQ_INSERT_TAIL(&opts->head, opt, next);