static int virtcon_parse(const char *devname)

{

    QemuOptsList *device = qemu_find_opts("device");

    static int index = 0;

    char label[32];

    QemuOpts *bus_opts, *dev_opts;



    if (strcmp(devname, "none") == 0)

        return 0;

    if (index == MAX_VIRTIO_CONSOLES) {

        fprintf(stderr, "qemu: too many virtio consoles\n");

        exit(1);

    }



    bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    if (arch_type == QEMU_ARCH_S390X) {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort);

    } else {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort);

    }



    dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);



    snprintf(label, sizeof(label), "virtcon%d", index);

    virtcon_hds[index] = qemu_chr_new(label, devname, NULL);

    if (!virtcon_hds[index]) {

        fprintf(stderr, "qemu: could not connect virtio console"

                " to character backend '%s'\n", devname);

        return -1;

    }

    qemu_opt_set(dev_opts, "chardev", label, &error_abort);



    index++;

    return 0;

}

static int virtcon_parse(const char *devname)

{

    QemuOptsList *device = qemu_find_opts("device");

    static int index = 0;

    char label[32];

    QemuOpts *bus_opts, *dev_opts;



    if (strcmp(devname, "none") == 0)

        return 0;

    if (index == MAX_VIRTIO_CONSOLES) {

        fprintf(stderr, "qemu: too many virtio consoles\n");

        exit(1);

    }



    bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    if (arch_type == QEMU_ARCH_S390X) {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort);

    } else {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort);

    }



    dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);



    snprintf(label, sizeof(label), "virtcon%d", index);

    virtcon_hds[index] = qemu_chr_new(label, devname, NULL);

    if (!virtcon_hds[index]) {

        fprintf(stderr, "qemu: could not connect virtio console"

                " to character backend '%s'\n", devname);

        return -1;

    }

    qemu_opt_set(dev_opts, "chardev", label, &error_abort);



    index++;

    return 0;

}

static int FUNC_0(const char *VAR_0)

{

    QemuOptsList *device = qemu_find_opts("device");

    static int VAR_1 = 0;

    char VAR_2[32];

    QemuOpts *bus_opts, *dev_opts;



    if (strcmp(VAR_0, "none") == 0)

        return 0;

    if (VAR_1 == MAX_VIRTIO_CONSOLES) {

        fprintf(stderr, "qemu: too many virtio consoles\n");

        exit(1);

    }



    bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    if (arch_type == QEMU_ARCH_S390X) {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort);

    } else {

        qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort);

    }



    dev_opts = qemu_opts_create(device, NULL, 0, &error_abort);

    qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort);



    snprintf(VAR_2, sizeof(VAR_2), "virtcon%d", VAR_1);

    virtcon_hds[VAR_1] = qemu_chr_new(VAR_2, VAR_0, NULL);

    if (!virtcon_hds[VAR_1]) {

        fprintf(stderr, "qemu: could not connect virtio console"

                " to character backend '%s'\n", VAR_0);

        return -1;

    }

    qemu_opt_set(dev_opts, "chardev", VAR_2, &error_abort);



    VAR_1++;

    return 0;

}

static int FUNC_0(const char *VAR_0)
{ QemuOptsList *device = qemu_find_opts("device"); static int VAR_1 = 0; char VAR_2[32]; QemuOpts *bus_opts, *dev_opts; if (strcmp(VAR_0, "none") == 0)
return 0; if (VAR_1 == MAX_VIRTIO_CONSOLES) { fprintf(stderr, "qemu: too many virtio consoles\n"); exit(1); } bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(bus_opts, "driver", "virtio-serial-s390", &error_abort); } else { qemu_opt_set(bus_opts, "driver", "virtio-serial-pci", &error_abort); } dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole", &error_abort); snprintf(VAR_2, sizeof(VAR_2), "virtcon%d", VAR_1); virtcon_hds[VAR_1] = qemu_chr_new(VAR_2, VAR_0, NULL); if (!virtcon_hds[VAR_1]) { fprintf(stderr, "qemu: could not connect virtio console"
" to character backend '%s'\n", VAR_0); return -1; } qemu_opt_set(dev_opts, "chardev", VAR_2, &error_abort); VAR_1++; return 0; }