mirror of https://github.com/xqemu/xqemu.git
spice-qemu-char: factor out CharDriverState creation
Make the CharDriverState creation code reusable by spicevmc port. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
07a54d704e
commit
71b423f4b9
|
@ -186,13 +186,32 @@ static void print_allowed_subtypes(void)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
|
static CharDriverState *chr_open(QemuOpts *opts, const char *subtype)
|
||||||
{
|
{
|
||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
SpiceCharDriver *s;
|
SpiceCharDriver *s;
|
||||||
const char* name = qemu_opt_get(opts, "name");
|
|
||||||
uint32_t debug = qemu_opt_get_number(opts, "debug", 0);
|
uint32_t debug = qemu_opt_get_number(opts, "debug", 0);
|
||||||
const char** psubtype = spice_server_char_device_recognized_subtypes();
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
return chr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
|
||||||
|
{
|
||||||
|
CharDriverState *chr;
|
||||||
|
const char *name = qemu_opt_get(opts, "name");
|
||||||
|
const char **psubtype = spice_server_char_device_recognized_subtypes();
|
||||||
const char *subtype = NULL;
|
const char *subtype = NULL;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
|
@ -212,17 +231,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
chr = g_malloc0(sizeof(CharDriverState));
|
chr = chr_open(opts, subtype);
|
||||||
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 SPICE_SERVER_VERSION < 0x000901
|
||||||
/* See comment in vmc_state() */
|
/* See comment in vmc_state() */
|
||||||
|
|
Loading…
Reference in New Issue