+
+void qemu_spice_register_ports(void)
+{
+ SpiceCharDriver *s;
+
+ QLIST_FOREACH(s, &spice_chars, next) {
+ if (s->sin.portname == NULL) {
+ continue;
+ }
+ vmc_register_interface(s);
+ }
+}
+#endif
+
+static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
+ Error **errp)
+{
+ const char *name = qemu_opt_get(opts, "name");
+
+ if (name == NULL) {
+ error_setg(errp, "chardev: spice channel: no name given");
+ return;
+ }
+ backend->spicevmc = g_new0(ChardevSpiceChannel, 1);
+ backend->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");
+
+ if (name == NULL) {
+ error_setg(errp, "chardev: spice port: no name given");
+ return;
+ }
+ backend->spiceport = g_new0(ChardevSpicePort, 1);
+ backend->spiceport->fqdn = g_strdup(name);
+}
+
+static void register_types(void)
+{
+ register_char_driver_qapi("spicevmc", CHARDEV_BACKEND_KIND_SPICEVMC,
+ qemu_chr_parse_spice_vmc);
+ register_char_driver_qapi("spiceport", CHARDEV_BACKEND_KIND_SPICEPORT,
+ qemu_chr_parse_spice_port);
+}
+
+type_init(register_types);