Commit 1640b200 authored by Markus Armbruster's avatar Markus Armbruster
Browse files

QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure



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: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent 8809cfc3
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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;
}
Loading