[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 10/44] qemu-option: Factor out helper opt_create()
From: |
Markus Armbruster |
Subject: |
[PATCH v3 10/44] qemu-option: Factor out helper opt_create() |
Date: |
Mon, 6 Jul 2020 10:09:16 +0200 |
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>
---
util/qemu-option.c | 27 ++++++++++++++++++---------
1 file 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);
--
2.26.2
- [PATCH v3 00/44] Less clumsy error checking, Markus Armbruster, 2020/07/06
- [PATCH v3 02/44] error: Document Error API usage rules, Markus Armbruster, 2020/07/06
- [PATCH v3 01/44] error: Improve examples in error.h's big comment, Markus Armbruster, 2020/07/06
- [PATCH v3 10/44] qemu-option: Factor out helper opt_create(),
Markus Armbruster <=
- [PATCH v3 07/44] qemu-option: Make uses of find_desc_by_name() more similar, Markus Armbruster, 2020/07/06
- [PATCH v3 04/44] macio: Tidy up error handling in macio_newworld_realize(), Markus Armbruster, 2020/07/06
- [PATCH v3 15/44] hmp: Eliminate a variable in hmp_migrate_set_parameter(), Markus Armbruster, 2020/07/06
- [PATCH v3 14/44] block: Avoid error accumulation in bdrv_img_create(), Markus Armbruster, 2020/07/06
- [PATCH v3 09/44] qemu-option: Simplify around find_default_by_name(), Markus Armbruster, 2020/07/06
- [PATCH v3 12/44] qemu-option: Make functions taking Error ** return bool, not void, Markus Armbruster, 2020/07/06
- [PATCH v3 21/44] qom: Rename qdev_get_type() to object_get_type(), Markus Armbruster, 2020/07/06
- [PATCH v3 03/44] qdev: Use returned bool to check for qdev_realize() etc. failure, Markus Armbruster, 2020/07/06