int qemu_chr_open_spice(QemuOpts *opts, CharDriverState **_chr)

{

    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 -EINVAL;

    }

    for(;*psubtype != NULL; ++psubtype) {

        if (strcmp(name, *psubtype) == 0) {

            subtype = *psubtype;

            break;

        }

    }

    if (subtype == NULL) {

        fprintf(stderr, "spice-qemu-char: unsupported name\n");

        print_allowed_subtypes();

        return -EINVAL;

    }



    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



    *_chr = chr;

    return 0;

}

int qemu_chr_open_spice(QemuOpts *opts, CharDriverState **_chr)

{

    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 -EINVAL;

    }

    for(;*psubtype != NULL; ++psubtype) {

        if (strcmp(name, *psubtype) == 0) {

            subtype = *psubtype;

            break;

        }

    }

    if (subtype == NULL) {

        fprintf(stderr, "spice-qemu-char: unsupported name\n");

        print_allowed_subtypes();

        return -EINVAL;

    }



    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

    

    if (strcmp(subtype, "vdagent") == 0) {

        qemu_chr_generic_open(chr);

    }

#endif



    *_chr = chr;

    return 0;

}

    *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     return 0;     return 0;         return -EINVAL;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0;     *_chr = chr;     return 0; int qemu_chr_open_spice(QemuOpts *opts, CharDriverState **_chr)         return -EINVAL;         return -EINVAL;     *_chr = chr;     return 0;
int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)

{

    CharDriverState *chr;

    SpiceCharDriver *s;

    const char* VAR_2 = qemu_opt_get(VAR_0, "VAR_2");

    uint32_t debug = qemu_opt_get_number(VAR_0, "debug", 0);

    const char** VAR_3 = spice_server_char_device_recognized_subtypes();

    const char *VAR_4 = NULL;



    if (VAR_2 == NULL) {

        fprintf(stderr, "spice-qemu-char: missing VAR_2 parameter\n");

        print_allowed_subtypes();

        return -EINVAL;

    }

    for(;*VAR_3 != NULL; ++VAR_3) {

        if (strcmp(VAR_2, *VAR_3) == 0) {

            VAR_4 = *VAR_3;

            break;

        }

    }

    if (VAR_4 == NULL) {

        fprintf(stderr, "spice-qemu-char: unsupported VAR_2\n");

        print_allowed_subtypes();

        return -EINVAL;

    }



    chr = g_malloc0(sizeof(CharDriverState));

    s = g_malloc0(sizeof(SpiceCharDriver));

    s->chr = chr;

    s->debug = debug;

    s->active = false;

    s->sin.VAR_4 = VAR_4;

    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

    

    if (strcmp(VAR_4, "vdagent") == 0) {

        qemu_chr_generic_open(chr);

    }

#endif



    *VAR_1 = chr;

    return 0;

}

int FUNC_0(QemuOpts *VAR_0, CharDriverState **VAR_1)
{ CharDriverState *chr; SpiceCharDriver *s; const char* VAR_2 = qemu_opt_get(VAR_0, "VAR_2"); uint32_t debug = qemu_opt_get_number(VAR_0, "debug", 0); const char** VAR_3 = spice_server_char_device_recognized_subtypes(); const char *VAR_4 = NULL; if (VAR_2 == NULL) { fprintf(stderr, "spice-qemu-char: missing VAR_2 parameter\n"); print_allowed_subtypes(); return -EINVAL; } for(;*VAR_3 != NULL; ++VAR_3) { if (strcmp(VAR_2, *VAR_3) == 0) { VAR_4 = *VAR_3; break; } } if (VAR_4 == NULL) { fprintf(stderr, "spice-qemu-char: unsupported VAR_2\n"); print_allowed_subtypes(); return -EINVAL; } chr = g_malloc0(sizeof(CharDriverState)); s = g_malloc0(sizeof(SpiceCharDriver)); s->chr = chr; s->debug = debug; s->active = false; s->sin.VAR_4 = VAR_4; 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
if (strcmp(VAR_4, "vdagent") == 0) { qemu_chr_generic_open(chr); } #endif
*VAR_1 = chr; return 0; }