#include "chardev/spice.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
+#include "qemu/module.h"
#include "qemu/option.h"
#include <spice/protocol.h>
SpiceChardev *scd;
} SpiceCharSource;
-static QLIST_HEAD(, SpiceChardev) spice_chars =
- QLIST_HEAD_INITIALIZER(spice_chars);
-
static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
{
SpiceChardev *scd = container_of(sin, SpiceChardev, sin);
return;
}
scd->sin.base.sif = &vmc_interface.base;
- qemu_spice_add_interface(&scd->sin.base);
+ qemu_spice.add_interface(&scd->sin.base);
scd->active = true;
trace_spice_vmc_register_interface(scd);
}
vmc_unregister_interface(s);
- if (s->next.le_prev) {
- QLIST_REMOVE(s, next);
- }
-
g_free((char *)s->sin.subtype);
g_free((char *)s->sin.portname);
}
s->active = false;
s->sin.subtype = g_strdup(subtype);
-
- QLIST_INSERT_HEAD(&spice_chars, s, next);
}
static void qemu_chr_open_spice_vmc(Chardev *chr,
chr_open(chr, type);
}
-void qemu_chr_open_spice_port(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
+static void qemu_chr_open_spice_port(Chardev *chr,
+ ChardevBackend *backend,
+ bool *be_opened,
+ Error **errp)
{
ChardevSpicePort *spiceport = backend->u.spiceport.data;
const char *name = spiceport->fqdn;
return;
}
+ if (!using_spice) {
+ error_setg(errp, "spice not enabled");
+ return;
+ }
+
chr_open(chr, "port");
*be_opened = false;
s = SPICE_CHARDEV(chr);
s->sin.portname = g_strdup(name);
- if (using_spice) {
- /* spice server already created */
- vmc_register_interface(s);
- }
-}
-
-void qemu_spice_register_ports(void)
-{
- SpiceChardev *s;
-
- QLIST_FOREACH(s, &spice_chars, next) {
- if (s->sin.portname == NULL) {
- continue;
- }
- vmc_register_interface(s);
- }
+ vmc_register_interface(s);
}
static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
.class_init = char_spice_class_init,
.abstract = true,
};
+module_obj(TYPE_CHARDEV_SPICE);
static void char_spicevmc_class_init(ObjectClass *oc, void *data)
{
.parent = TYPE_CHARDEV_SPICE,
.class_init = char_spicevmc_class_init,
};
+module_obj(TYPE_CHARDEV_SPICEVMC);
static void char_spiceport_class_init(ObjectClass *oc, void *data)
{
.parent = TYPE_CHARDEV_SPICE,
.class_init = char_spiceport_class_init,
};
+module_obj(TYPE_CHARDEV_SPICEPORT);
static void register_types(void)
{
}
type_init(register_types);
+
+module_dep("ui-spice-core");