-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) {
- error_report("too many virtio consoles");
- exit(1);
- }
-
- bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);
- qemu_opt_set(bus_opts, "driver", "virtio-serial", &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_mux_mon(label, devname);
- if (!virtcon_hds[index]) {
- error_report("could not connect virtio console"
- " to character backend '%s'", devname);
- return -1;
- }
- qemu_opt_set(dev_opts, "chardev", label, &error_abort);
-
- index++;
- return 0;
-}
-