diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-10-14 14:11:17 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-10-15 11:14:40 +0200 |
commit | 93ab5844b2cd5367966d7b5bae154e0d3303b504 (patch) | |
tree | fdc01b73d9999cb0970d77105fd24a44b25efceb /chardev | |
parent | 70122d62302c97bcd205956a544b8e79f2a4a50f (diff) | |
download | qemu-93ab5844b2cd5367966d7b5bae154e0d3303b504.zip qemu-93ab5844b2cd5367966d7b5bae154e0d3303b504.tar.gz qemu-93ab5844b2cd5367966d7b5bae154e0d3303b504.tar.bz2 |
chardev/spice: simplify chardev setup
Initialize spice before chardevs. That allows to register the spice
chardevs directly in the init function and removes the need to maintain
a linked list of chardevs just for registration.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20201014121120.13482-5-kraxel@redhat.com
Diffstat (limited to 'chardev')
-rw-r--r-- | chardev/spice.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/chardev/spice.c b/chardev/spice.c index 051c23a..7d1fb17 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -14,9 +14,6 @@ typedef struct SpiceCharSource { 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); @@ -216,8 +213,6 @@ static void char_spice_finalize(Object *obj) vmc_unregister_interface(s); - QLIST_SAFE_REMOVE(s, next); - g_free((char *)s->sin.subtype); g_free((char *)s->sin.portname); } @@ -256,8 +251,6 @@ static void chr_open(Chardev *chr, const char *subtype) 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, @@ -310,28 +303,18 @@ static void qemu_chr_open_spice_port(Chardev *chr, 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, |