-#include "config-host.h"
+#include "qemu/osdep.h"
#include "trace.h"
#include "ui/qemu-spice.h"
#include "sysemu/char.h"
#include <spice.h>
#include <spice/protocol.h>
-#include "qemu/osdep.h"
typedef struct SpiceCharDriver {
CharDriverState* chr;
return read_bytes;
}
-static void spice_chr_close(struct CharDriverState *chr)
+static void spice_chr_free(struct CharDriverState *chr)
{
SpiceCharDriver *s = chr->opaque;
#endif
}
-static void spice_chr_fe_event(struct CharDriverState *chr, int event)
-{
-#if SPICE_SERVER_VERSION >= 0x000c02
- SpiceCharDriver *s = chr->opaque;
-
- spice_server_port_event(&s->sin, event);
-#endif
-}
-
static void print_allowed_subtypes(void)
{
const char** 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_free = spice_chr_free;
chr->chr_set_fe_open = set_fe_open;
- chr->explicit_be_open = true;
- chr->chr_fe_event = spice_chr_fe_event;
chr->chr_accept_input = spice_chr_accept_input;
QLIST_INSERT_HEAD(&spice_chars, s, next);
static CharDriverState *qemu_chr_open_spice_vmc(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
+ bool *be_opened,
Error **errp)
{
- const char *type = backend->u.spicevmc->type;
+ ChardevSpiceChannel *spicevmc = backend->u.spicevmc.data;
+ const char *type = spicevmc->type;
const char **psubtype = spice_server_char_device_recognized_subtypes();
- ChardevCommon *common = qapi_ChardevSpiceChannel_base(backend->u.spicevmc);
+ ChardevCommon *common = qapi_ChardevSpiceChannel_base(spicevmc);
for (; *psubtype != NULL; ++psubtype) {
if (strcmp(type, *psubtype) == 0) {
return NULL;
}
+ *be_opened = false;
return chr_open(type, spice_vmc_set_fe_open, common, errp);
}
static CharDriverState *qemu_chr_open_spice_port(const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
+ bool *be_opened,
Error **errp)
{
- const char *name = backend->u.spiceport->fqdn;
- ChardevCommon *common = qapi_ChardevSpicePort_base(backend->u.spiceport);
+ ChardevSpicePort *spiceport = backend->u.spiceport.data;
+ const char *name = spiceport->fqdn;
+ ChardevCommon *common = qapi_ChardevSpicePort_base(spiceport);
CharDriverState *chr;
SpiceCharDriver *s;
if (!chr) {
return NULL;
}
+ *be_opened = false;
s = chr->opaque;
s->sin.portname = g_strdup(name);
Error **errp)
{
const char *name = qemu_opt_get(opts, "name");
+ ChardevSpiceChannel *spicevmc;
if (name == NULL) {
error_setg(errp, "chardev: spice channel: no name given");
return;
}
- backend->u.spicevmc = g_new0(ChardevSpiceChannel, 1);
- backend->u.spicevmc->type = g_strdup(name);
+ spicevmc = backend->u.spicevmc.data = g_new0(ChardevSpiceChannel, 1);
+ qemu_chr_parse_common(opts, qapi_ChardevSpiceChannel_base(spicevmc));
+ spicevmc->type = g_strdup(name);
}
static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend,
Error **errp)
{
const char *name = qemu_opt_get(opts, "name");
+ ChardevSpicePort *spiceport;
if (name == NULL) {
error_setg(errp, "chardev: spice port: no name given");
return;
}
- backend->u.spiceport = g_new0(ChardevSpicePort, 1);
- backend->u.spiceport->fqdn = g_strdup(name);
+ spiceport = backend->u.spiceport.data = g_new0(ChardevSpicePort, 1);
+ qemu_chr_parse_common(opts, qapi_ChardevSpicePort_base(spiceport));
+ spiceport->fqdn = g_strdup(name);
}
static void register_types(void)