Commit 8be7e7e4 authored by Luiz Capitulino's avatar Luiz Capitulino
Browse files

qemu-option: qemu_opts_create(): use error_set()



This commit converts qemu_opts_create() from qerror_report() to
error_set().

Currently, most calls to qemu_opts_create() can't fail, so most
callers don't need any changes.

The two cases where code checks for qemu_opts_create() erros are:

 1. Initialization code in vl.c. All of them print their own
    error messages directly to stderr, no need to pass the Error
    object

 2. The functions opts_parse(), qemu_opts_from_qdict() and
    qemu_chr_parse_compat() make use of the error information and
    they can be called from HMP or QMP. In this case, to allow for
    incremental conversion, we propagate the error up using
    qerror_report_err(), which keeps the QError semantics

Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
Reviewed-By: default avatarLaszlo Ersek <lersek@redhat.com>
parent 783e9b48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -569,7 +569,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
        break;
    case IF_VIRTIO:
        /* add virtio block device */
        opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
        opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, NULL);
        if (arch_type == QEMU_ARCH_S390X) {
            qemu_opt_set(opts, "driver", "virtio-blk-s390");
        } else {
+1 −1
Original line number Diff line number Diff line
@@ -584,7 +584,7 @@ static USBDevice *usb_msd_init(USBBus *bus, const char *filename)

    /* parse -usbdevice disk: syntax into drive opts */
    snprintf(id, sizeof(id), "usb%d", nr++);
    opts = qemu_opts_create(qemu_find_opts("drive"), id, 0);
    opts = qemu_opts_create(qemu_find_opts("drive"), id, 0, NULL);

    p1 = strchr(filename, ':');
    if (p1++) {
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ int select_watchdog(const char *p)
    QLIST_FOREACH(model, &watchdog_list, entry) {
        if (strcasecmp(model->wdt_name, p) == 0) {
            /* add the device */
            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0);
            opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, NULL);
            qemu_opt_set(opts, "driver", p);
            return 0;
        }
+6 −2
Original line number Diff line number Diff line
@@ -2584,10 +2584,14 @@ QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
    int pos;
    const char *p;
    QemuOpts *opts;
    Error *local_err = NULL;

    opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1);
    if (NULL == opts)
    opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1, &local_err);
    if (error_is_set(&local_err)) {
        qerror_report_err(local_err);
        error_free(local_err);
        return NULL;
    }

    if (strstart(filename, "mon:", &p)) {
        filename = p;
+3 −3
Original line number Diff line number Diff line
@@ -709,7 +709,7 @@ int qemu_global_option(const char *str)
        return -1;
    }

    opts = qemu_opts_create(&qemu_global_opts, NULL, 0);
    opts = qemu_opts_create(&qemu_global_opts, NULL, 0, NULL);
    qemu_opt_set(opts, "driver", driver);
    qemu_opt_set(opts, "property", property);
    qemu_opt_set(opts, "value", str+offset+1);
@@ -781,7 +781,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
            list = find_list(lists, group);
            if (list == NULL)
                goto out;
            opts = qemu_opts_create(list, id, 1);
            opts = qemu_opts_create(list, id, 1, NULL);
            continue;
        }
        if (sscanf(line, "[%63[^]]]", group) == 1) {
@@ -789,7 +789,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname)
            list = find_list(lists, group);
            if (list == NULL)
                goto out;
            opts = qemu_opts_create(list, NULL, 0);
            opts = qemu_opts_create(list, NULL, 0, NULL);
            continue;
        }
        if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) {
Loading