]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure
authorMarkus Armbruster <armbru@redhat.com>
Thu, 12 Mar 2015 06:45:10 +0000 (07:45 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 9 Jun 2015 05:40:23 +0000 (07:40 +0200)
When the argument is non-zero, qemu_opt_foreach() stops on callback
returning non-zero, and returns that value.

When the argument is zero, it doesn't stop, and returns the callback's
value from the last iteration.

The two callers that pass zero could just as well pass one:

* qemu_spice_init()'s callback add_channel() either returns zero or
  exit()s.

* config_write_opts()'s callback config_write_opt() always returns
  zero.

Drop the parameter, and always stop.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
include/qemu/option.h
net/vhost-user.c
qdev-monitor.c
ui/spice-core.c
util/qemu-config.c
util/qemu-option.c
vl.c

index a3850b23a4c5c93285611272be568df4e4b7a5f6..a3cf4c198123e721b54ea0488a631537dd28c26d 100644 (file)
@@ -101,8 +101,7 @@ void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val,
 void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
                          Error **errp);
 typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque);
-int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
-                     int abort_on_failure);
+int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque);
 
 QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id);
 QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id,
index cce168af2f890d66f9efef5af887881ec9dc389c..167082e76e12160bea6cc1e4cf7624c602650756 100644 (file)
@@ -189,7 +189,7 @@ static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *op
 
     /* inspect chardev opts */
     memset(&props, 0, sizeof(props));
-    if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, true) != 0) {
+    if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props)) {
         return NULL;
     }
 
index 9f17c81d9f51bad8e8a067a57591cf463fc3e97d..b7a21505771fd75895a9546c90665895c2072ed7 100644 (file)
@@ -564,7 +564,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
     }
 
     /* set properties */
-    if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
+    if (qemu_opt_foreach(opts, set_property, dev)) {
         object_unparent(OBJECT(dev));
         object_unref(OBJECT(dev));
         return NULL;
index 2e8384e6530af1f98484297b8d3c3cd11e0c0d79..60818d9960faf4f50c8742990c2126e75b7bdb22 100644 (file)
@@ -782,7 +782,7 @@ void qemu_spice_init(void)
     spice_server_set_playback_compression
         (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1));
 
-    qemu_opt_foreach(opts, add_channel, &tls_port, 0);
+    qemu_opt_foreach(opts, add_channel, &tls_port);
 
     spice_server_set_name(spice_server, qemu_name);
     spice_server_set_uuid(spice_server, qemu_uuid);
index a88461f6b71c4d83a47dfe7f1b2775ac7434aa04..aff4cb37c08b1470c61485879fe9da3342e10f9e 100644 (file)
@@ -353,7 +353,7 @@ static int config_write_opts(void *opaque, QemuOpts *opts, Error **errp)
     } else {
         fprintf(data->fp, "[%s]\n", data->list->name);
     }
-    qemu_opt_foreach(opts, config_write_opt, data, 0);
+    qemu_opt_foreach(opts, config_write_opt, data);
     fprintf(data->fp, "\n");
     return 0;
 }
index 07b03e313a1b1666fd709895236dc2aac3c9db71..296e2b3fae838d84e5a6956eaf04307cd558124a 100644 (file)
@@ -596,18 +596,23 @@ void qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val,
     QTAILQ_INSERT_TAIL(&opts->head, opt, next);
 }
 
-int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
-                     int abort_on_failure)
+/**
+ * For each member of @opts, call @func(name, value, @opaque).
+ * When @func() returns non-zero, break the loop and return that value.
+ * Return zero when the loop completes.
+ */
+int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque)
 {
     QemuOpt *opt;
-    int rc = 0;
+    int rc;
 
     QTAILQ_FOREACH(opt, &opts->head, next) {
         rc = func(opt->name, opt->str, opaque);
-        if (abort_on_failure  &&  rc != 0)
-            break;
+        if (rc) {
+            return rc;
+        }
     }
-    return rc;
+    return 0;
 }
 
 QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
diff --git a/vl.c b/vl.c
index b3c17228e62305c0d40fd86ae986ef3dfae925a4..b12e6ffc9768d3ee1915e1eb8f03e710a2463b42 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4070,8 +4070,8 @@ int main(int argc, char **argv, char **envp)
     }
 
     machine_opts = qemu_get_machine_opts();
-    if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
-                         1) < 0) {
+    if (qemu_opt_foreach(machine_opts, machine_set_property,
+                         current_machine)) {
         object_unref(OBJECT(current_machine));
         exit(1);
     }