CharDriverState *qemu_chr_open_spice(QemuOpts *opts) { CharDriverState *chr; SpiceCharDriver *s; const char* name = qemu_opt_get(opts, "name"); uint32_t debug = qemu_opt_get_number(opts, "debug", 0); const char** psubtype = spice_server_char_device_recognized_subtypes(); const char *subtype = NULL; if (name == NULL) { fprintf(stderr, "spice-qemu-char: missing name parameter\n"); print_allowed_subtypes(); return NULL; } for(;*psubtype != NULL; ++psubtype) { if (strcmp(name, *psubtype) == 0) { subtype = *psubtype; break; } } if (subtype == NULL) { fprintf(stderr, "spice-qemu-char: unsupported name: %s\n", name); print_allowed_subtypes(); return NULL; } chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(SpiceCharDriver)); s->chr = chr; s->debug = debug; s->active = false; s->sin.subtype = subtype; chr->opaque = s; chr->chr_write = spice_chr_write; chr->chr_close = spice_chr_close; chr->chr_guest_open = spice_chr_guest_open; chr->chr_guest_close = spice_chr_guest_close; #if SPICE_SERVER_VERSION < 0x000901 /* See comment in vmc_state() */ if (strcmp(subtype, "vdagent") == 0) { qemu_chr_generic_open(chr); } #endif return chr; }
CharDriverState *qemu_chr_open_spice_vmc(const char *type) { CharDriverState *chr; SpiceCharDriver *s; const char **psubtype = spice_server_char_device_recognized_subtypes(); if (type == NULL) { fprintf(stderr, "spice-qemu-char: missing name parameter\n"); print_allowed_subtypes(); return NULL; } for (; *psubtype != NULL; ++psubtype) { if (strcmp(type, *psubtype) == 0) { break; } } if (*psubtype == NULL) { fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type); print_allowed_subtypes(); return NULL; } chr = qemu_mallocz(sizeof(CharDriverState)); s = qemu_mallocz(sizeof(SpiceCharDriver)); s->chr = chr; s->active = false; s->sin.subtype = *psubtype; chr->opaque = s; chr->chr_write = spice_chr_write; chr->chr_add_watch = spice_chr_add_watch; chr->chr_close = spice_chr_close; chr->chr_guest_open = spice_chr_guest_open; chr->chr_guest_close = spice_chr_guest_close; #if SPICE_SERVER_VERSION < 0x000901 /* See comment in vmc_state() */ if (strcmp(type, "vdagent") == 0) { qemu_chr_generic_open(chr); } #endif return chr; }
CharDriverState *chr_baum_init(QemuOpts *opts) { BaumDriverState *baum; CharDriverState *chr; brlapi_handle_t *handle; #ifdef CONFIG_SDL SDL_SysWMinfo info; #endif int tty; baum = qemu_mallocz(sizeof(BaumDriverState)); baum->chr = chr = qemu_mallocz(sizeof(CharDriverState)); chr->opaque = baum; chr->chr_write = baum_write; chr->chr_send_event = baum_send_event; chr->chr_accept_input = baum_accept_input; handle = qemu_mallocz(brlapi_getHandleSize()); baum->brlapi = handle; baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL); if (baum->brlapi_fd == -1) { brlapi_perror("baum_init: brlapi_openConnection"); goto fail_handle; } baum->cellCount_timer = qemu_new_timer(vm_clock, baum_cellCount_timer_cb, baum); if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) { brlapi_perror("baum_init: brlapi_getDisplaySize"); goto fail; } #ifdef CONFIG_SDL memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) tty = info.info.x11.wmwindow; else #endif tty = BRLAPI_TTY_DEFAULT; if (brlapi__enterTtyMode(handle, tty, NULL) == -1) { brlapi_perror("baum_init: brlapi_enterTtyMode"); goto fail; } qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum); qemu_chr_generic_open(chr); return chr; fail: qemu_free_timer(baum->cellCount_timer); brlapi__closeConnection(handle); fail_handle: free(handle); free(chr); free(baum); return NULL; }