aboutsummaryrefslogtreecommitdiff
path: root/util/qemu-option.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-07-07 18:05:39 +0200
committerMarkus Armbruster <armbru@redhat.com>2020-07-10 15:01:06 +0200
commit81a8a0726a67b0f28d36201c1b9e0944e5849a76 (patch)
tree4cb3395bdf33ab10469d416091365ffc9c3ff470 /util/qemu-option.c
parent44b0b7d1758d105cea2d6156a071e8d9e2256f69 (diff)
qemu-option: Factor out helper opt_create()
There is just one use so far. The next commit will add more. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20200707160613.848843-12-armbru@redhat.com>
Diffstat (limited to 'util/qemu-option.c')
-rw-r--r--util/qemu-option.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/util/qemu-option.c b/util/qemu-option.c
index e7b540a21b..1023fe7527 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -499,6 +499,23 @@ int qemu_opt_unset(QemuOpts *opts, const char *name)
}
}
+static QemuOpt *opt_create(QemuOpts *opts, const char *name, char *value,
+ bool prepend)
+{
+ QemuOpt *opt = g_malloc0(sizeof(*opt));
+
+ opt->name = g_strdup(name);
+ opt->str = value;
+ opt->opts = opts;
+ if (prepend) {
+ QTAILQ_INSERT_HEAD(&opts->head, opt, next);
+ } else {
+ QTAILQ_INSERT_TAIL(&opts->head, opt, next);
+ }
+
+ return opt;
+}
+
static void opt_set(QemuOpts *opts, const char *name, char *value,
bool prepend, bool *help_wanted, Error **errp)
{
@@ -516,16 +533,8 @@ static void opt_set(QemuOpts *opts, const char *name, char *value,
return;
}
- opt = g_malloc0(sizeof(*opt));
- opt->name = g_strdup(name);
- opt->opts = opts;
- if (prepend) {
- QTAILQ_INSERT_HEAD(&opts->head, opt, next);
- } else {
- QTAILQ_INSERT_TAIL(&opts->head, opt, next);
- }
+ opt = opt_create(opts, name, value, prepend);
opt->desc = desc;
- opt->str = value;
qemu_opt_parse(opt, &local_err);
if (local_err) {
error_propagate(errp, local_err);