#include "trace.h"
#include "ui/qemu-spice.h"
#include "chardev/char.h"
+#include "chardev/spice.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
+#include "qemu/module.h"
#include "qemu/option.h"
-#include <spice.h>
#include <spice/protocol.h>
-
-typedef struct SpiceChardev {
- Chardev parent;
-
- SpiceCharDeviceInstance sin;
- bool active;
- bool blocked;
- const uint8_t *datapos;
- int datalen;
- QLIST_ENTRY(SpiceChardev) next;
-} SpiceChardev;
-
-#define TYPE_CHARDEV_SPICE "chardev-spice"
-#define TYPE_CHARDEV_SPICEVMC "chardev-spicevmc"
-#define TYPE_CHARDEV_SPICEPORT "chardev-spiceport"
-
-#define SPICE_CHARDEV(obj) OBJECT_CHECK(SpiceChardev, (obj), TYPE_CHARDEV_SPICE)
-
typedef struct SpiceCharSource {
GSource source;
SpiceChardev *scd;
vmc_unregister_interface(s);
- if (s->next.le_prev) {
- QLIST_REMOVE(s, next);
- }
+ QLIST_SAFE_REMOVE(s, next);
g_free((char *)s->sin.subtype);
g_free((char *)s->sin.portname);
chr_open(chr, type);
}
-static void qemu_chr_open_spice_port(Chardev *chr,
- ChardevBackend *backend,
- bool *be_opened,
- Error **errp)
+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;
*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)