Add a wrapper similar to qemu_opts_parse_list() with the same
objective, to free the non _list version,
i.e. qemu_opts_parse_noisily() to be converted to receive the group
name.

Signed-off-by: Fabiano Rosas <[email protected]>
---
 block/monitor/block-hmp-cmds.c       |  2 +-
 include/qemu/option.h                |  2 ++
 monitor/hmp.c                        |  2 +-
 net/net.c                            |  2 +-
 qemu-img.c                           | 10 +++++-----
 qemu-io-cmds.c                       |  2 +-
 qemu-io.c                            |  7 ++++---
 qemu-nbd.c                           |  6 +++---
 storage-daemon/qemu-storage-daemon.c |  4 ++--
 system/qdev-monitor.c                |  2 +-
 system/tpm.c                         |  2 +-
 system/vl.c                          |  6 +++---
 tests/unit/test-replication.c        |  6 +++---
 tools/qemu-vnc/qemu-vnc.c            |  2 +-
 util/qemu-option.c                   | 14 ++++++++++++++
 15 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index 7bae4d425c..cbd64166ec 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -63,7 +63,7 @@ static void hmp_drive_add_node(MonitorHMP *hmp, const char 
*optstr)
     QDict *qdict;
     Error *err = NULL;
 
-    opts = qemu_opts_parse_noisily(&qemu_drive_opts, optstr, false);
+    opts = qemu_opts_parse_list_noisily(&qemu_drive_opts, optstr, false);
     if (!opts) {
         return;
     }
diff --git a/include/qemu/option.h b/include/qemu/option.h
index dfe0d9b893..df68da9aa8 100644
--- a/include/qemu/option.h
+++ b/include/qemu/option.h
@@ -134,6 +134,8 @@ QemuOpts *qemu_opts_parse(const char *group, const char 
*params,
                           bool permit_abbrev, Error **errp);
 QemuOpts *qemu_opts_parse_list(QemuOptsList *list, const char *params,
                                bool permit_abbrev, Error **errp);
+QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *list, const char *params,
+                                       bool permit_abbrev);
 QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict,
                                Error **errp);
 QDict *qemu_opts_to_qdict_filtered(QemuOpts *opts, QDict *qdict,
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 488ec23937..fc32cfd1ff 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -897,7 +897,7 @@ static QDict *monitor_parse_arguments(MonitorHMP *mon,
                 if (get_str(buf, sizeof(buf), &p) < 0) {
                     goto fail;
                 }
-                opts = qemu_opts_parse_noisily(opts_list, buf, true);
+                opts = qemu_opts_parse_list_noisily(opts_list, buf, true);
                 if (!opts) {
                     goto fail;
                 }
diff --git a/net/net.c b/net/net.c
index d7fa637ce5..37401ab2b4 100644
--- a/net/net.c
+++ b/net/net.c
@@ -2029,7 +2029,7 @@ void netdev_parse_modern(const char *optstr)
 
 void net_client_parse(QemuOptsList *opts_list, const char *optstr)
 {
-    if (!qemu_opts_parse_noisily(opts_list, optstr, true)) {
+    if (!qemu_opts_parse_list_noisily(opts_list, optstr, true)) {
         exit(1);
     }
 }
diff --git a/qemu-img.c b/qemu-img.c
index 2f63d31141..4996618a4e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -161,7 +161,7 @@ static OutputFormat parse_output_format(const char *argv0, 
const char *arg)
  * an odd number of ',' (or else a separating ',' following it gets
  * escaped), or be empty (or else a separating ',' preceding it can
  * escape a separating ',' following it).
- * 
+ *
  */
 static bool is_valid_option_list(const char *list)
 {
@@ -2383,8 +2383,8 @@ static int img_convert(const img_cmd_t *ccmd, int argc, 
char **argv)
             break;
         case 'l':
             if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
-                sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
-                                                  optarg, false);
+                sn_opts = qemu_opts_parse_list_noisily(&internal_snapshot_opts,
+                                                       optarg, false);
                 if (!sn_opts) {
                     error_report("Failed in parsing snapshot param '%s'",
                                  optarg);
@@ -5768,8 +5768,8 @@ static int img_measure(const img_cmd_t *ccmd, int argc, 
char **argv)
             break;
         case 'l':
             if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
-                sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
-                                                  optarg, false);
+                sn_opts = qemu_opts_parse_list_noisily(&internal_snapshot_opts,
+                                                       optarg, false);
                 if (!sn_opts) {
                     error_report("Failed in parsing snapshot param '%s'",
                                  optarg);
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index aa795fd87a..6c8c4c9540 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -2540,7 +2540,7 @@ static int reopen_f(BlockBackend *blk, int argc, char 
**argv, Error **errp)
             has_cache_option = true;
             break;
         case 'o':
-            if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) {
+            if (!qemu_opts_parse_list_noisily(&reopen_opts, optarg, 0)) {
                 qemu_opts_reset(&reopen_opts);
                 return -EINVAL;
             }
diff --git a/qemu-io.c b/qemu-io.c
index 598d5b1c9c..db0ee499e4 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -220,7 +220,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv, 
Error **errp)
                 qemu_opts_reset(&empty_opts);
                 return -EINVAL;
             }
-            if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) {
+            if (!qemu_opts_parse_list_noisily(&empty_opts, optarg, false)) {
                 qemu_opts_reset(&empty_opts);
                 return -EINVAL;
             }
@@ -240,7 +240,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv, 
Error **errp)
     }
 
     if (imageOpts && (optind == argc - 1)) {
-        if (!qemu_opts_parse_noisily(&empty_opts, argv[optind], false)) {
+        if (!qemu_opts_parse_list_noisily(&empty_opts, argv[optind], false)) {
             qemu_opts_reset(&empty_opts);
             return -EINVAL;
         }
@@ -659,7 +659,8 @@ int main(int argc, char **argv)
     if ((argc - optind) == 1) {
         if (imageOpts) {
             QemuOpts *qopts = NULL;
-            qopts = qemu_opts_parse_noisily(&file_opts, argv[optind], false);
+            qopts = qemu_opts_parse_list_noisily(&file_opts, argv[optind],
+                                                 false);
             if (!qopts) {
                 exit(1);
             }
diff --git a/qemu-nbd.c b/qemu-nbd.c
index ed5895861b..749c915b58 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -706,8 +706,8 @@ int main(int argc, char **argv)
             break;
         case 'l':
             if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) {
-                sn_opts = qemu_opts_parse_noisily(&internal_snapshot_opts,
-                                                  optarg, false);
+                sn_opts = qemu_opts_parse_list_noisily(&internal_snapshot_opts,
+                                                       optarg, false);
                 if (!sn_opts) {
                     error_report("Failed in parsing snapshot param `%s'",
                                  optarg);
@@ -1117,7 +1117,7 @@ int main(int argc, char **argv)
             error_report("--image-opts and -f are mutually exclusive");
             exit(EXIT_FAILURE);
         }
-        o = qemu_opts_parse_noisily(&file_opts, opts.srcpath, true);
+        o = qemu_opts_parse_list_noisily(&file_opts, opts.srcpath, true);
         if (!o) {
             qemu_opts_reset(&file_opts);
             exit(EXIT_FAILURE);
diff --git a/storage-daemon/qemu-storage-daemon.c 
b/storage-daemon/qemu-storage-daemon.c
index 50dbfbd97a..5d63ef2efc 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -283,8 +283,8 @@ static void process_options(int argc, char *argv[], bool 
pre_init_pass)
         case OPTION_CHARDEV:
             {
                 /* TODO This interface is not stable until we QAPIfy it */
-                QemuOpts *opts = qemu_opts_parse_noisily(&qemu_chardev_opts,
-                                                         optarg, true);
+                QemuOpts *opts = qemu_opts_parse_list_noisily(
+                    &qemu_chardev_opts, optarg, true);
                 if (opts == NULL) {
                     exit(EXIT_FAILURE);
                 }
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index a62ad23ecf..8ba85a59d7 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -1197,7 +1197,7 @@ int qemu_global_option(const char *str)
         return 0;
     }
 
-    opts = qemu_opts_parse_noisily(&qemu_global_opts, str, false);
+    opts = qemu_opts_parse_list_noisily(&qemu_global_opts, str, false);
     if (!opts) {
         return -1;
     }
diff --git a/system/tpm.c b/system/tpm.c
index 903b29c043..f0f5a64d9a 100644
--- a/system/tpm.c
+++ b/system/tpm.c
@@ -184,7 +184,7 @@ int tpm_config_parse(QemuOptsList *opts_list, const char 
*optstr)
         tpm_display_backend_drivers();
         exit(EXIT_SUCCESS);
     }
-    opts = qemu_opts_parse_noisily(opts_list, optstr, true);
+    opts = qemu_opts_parse_list_noisily(opts_list, optstr, true);
     if (!opts) {
         return -1;
     }
diff --git a/system/vl.c b/system/vl.c
index 239c537e45..adda7b0f70 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -3262,7 +3262,7 @@ void qemu_init(int argc, char **argv)
                     error_report("fsdev support is disabled");
                     exit(1);
                 }
-                if (!qemu_opts_parse_noisily(olist, optarg, true)) {
+                if (!qemu_opts_parse_list_noisily(olist, optarg, true)) {
                     exit(1);
                 }
                 break;
@@ -3277,7 +3277,7 @@ void qemu_init(int argc, char **argv)
                     error_report("virtfs support is disabled");
                     exit(1);
                 }
-                opts = qemu_opts_parse_noisily(olist, optarg, true);
+                opts = qemu_opts_parse_list_noisily(olist, optarg, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3626,7 +3626,7 @@ void qemu_init(int argc, char **argv)
                     exit(1);
                 }
 
-                opts = qemu_opts_parse_noisily(olist, optarg, true);
+                opts = qemu_opts_parse_list_noisily(olist, optarg, true);
                 if (!opts) {
                     exit(1);
                 }
diff --git a/tests/unit/test-replication.c b/tests/unit/test-replication.c
index 3aa98e6f56..101f72acdc 100644
--- a/tests/unit/test-replication.c
+++ b/tests/unit/test-replication.c
@@ -179,7 +179,7 @@ static BlockBackend *start_primary(void)
                               "file.driver=qcow2,file.file.filename=%s,"
                               "file.file.locking=off"
                               , p_local_disk);
-    opts = qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false);
+    opts = qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false);
     g_free(cmdline);
 
     qdict = qemu_opts_to_qdict(opts, NULL);
@@ -295,7 +295,7 @@ static BlockBackend *start_secondary(void)
     cmdline = g_strdup_printf("file.filename=%s,driver=qcow2,"
                               "file.locking=off",
                               s_local_disk);
-    opts = qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false);
+    opts = qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false);
     g_free(cmdline);
 
     qdict = qemu_opts_to_qdict(opts, NULL);
@@ -321,7 +321,7 @@ static BlockBackend *start_secondary(void)
                               "file.backing.backing=%s"
                               , S_ID, s_active_disk, s_hidden_disk
                               , S_LOCAL_DISK_ID);
-    opts = qemu_opts_parse_noisily(&qemu_drive_opts, cmdline, false);
+    opts = qemu_opts_parse_list_noisily(&qemu_drive_opts, cmdline, false);
     g_free(cmdline);
 
     qdict = qemu_opts_to_qdict(opts, NULL);
diff --git a/tools/qemu-vnc/qemu-vnc.c b/tools/qemu-vnc/qemu-vnc.c
index 5c2ba3b7a5..10ac76298a 100644
--- a/tools/qemu-vnc/qemu-vnc.c
+++ b/tools/qemu-vnc/qemu-vnc.c
@@ -377,7 +377,7 @@ setup_vnc_opts(const char *vnc_addr, const char 
*tls_creds_dir,
         g_string_append(opts_str, ",non-adaptive=on");
     }
 
-    opts = qemu_opts_parse_noisily(olist, opts_str->str, true);
+    opts = qemu_opts_parse_list_noisily(olist, opts_str->str, true);
     if (!opts) {
         return false;
     }
diff --git a/util/qemu-option.c b/util/qemu-option.c
index c8e552823b..c762eb20a3 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -971,6 +971,20 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list, 
const char *params,
     return qemu_opts_parse_list(list, params, permit_abbrev, NULL);
 }
 
+/**
+ * Create a QemuOpts in @list and with options parsed from @params.
+ * If @permit_abbrev, the first key=value in @params may omit key=,
+ * and is treated as if key was @list->implied_opt_name.
+ * Report errors with error_report_err().  This is inappropriate in
+ * QMP context.  Do not use this function there!
+ * Return the new QemuOpts on success, null pointer on error.
+ */
+QemuOpts *qemu_opts_parse_list_noisily(QemuOptsList *list, const char *params,
+                                       bool permit_abbrev)
+{
+    return qemu_opts_parse_list(list, params, permit_abbrev, NULL);
+}
+
 static bool qemu_opts_from_qdict_entry(QemuOpts *opts,
                                        const QDictEntry *entry,
                                        Error **errp)
-- 
2.53.0


Reply via email to