aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-12-08 16:51:47 +0300
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-01-31 13:01:46 +0400
commit2c3a5dcbf8c9254835c76e867c9a560fec0753b9 (patch)
treec48872ed7663e3e393c6968f2b9a6759e7561593 /qemu-char.c
parent819aad230a50e9d5c9814f9390ef8e19f1f24c48 (diff)
char-socket: convert to finalize
Notice that finalize() will be run after a failure to open(), so cleanup code must be adjusted. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 1c4fcf3a6e..a00bbb0a1c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3446,9 +3446,10 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp)
return qemu_chr_wait_connected(be->chr, errp);
}
-static void tcp_chr_free(Chardev *chr)
+static void char_socket_finalize(Object *obj)
{
- SocketChardev *s = SOCKET_CHARDEV(chr);
+ Chardev *chr = CHARDEV(obj);
+ SocketChardev *s = SOCKET_CHARDEV(obj);
tcp_chr_free_connection(chr);
@@ -4886,7 +4887,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
s->listen_ioc = sioc;
if (is_waitconnect &&
qemu_chr_wait_connected(chr, errp) < 0) {
- goto error;
+ return;
}
if (!s->ioc) {
s->listen_tag = qio_channel_add_watch(
@@ -4904,9 +4905,6 @@ error:
if (sioc) {
object_unref(OBJECT(sioc));
}
- if (s->tls_creds) {
- object_unref(OBJECT(s->tls_creds));
- }
}
static const CharDriver socket_driver = {
@@ -4928,13 +4926,13 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
cc->chr_add_client = tcp_chr_add_client;
cc->chr_add_watch = tcp_chr_add_watch;
cc->chr_update_read_handler = tcp_chr_update_read_handler;
- cc->chr_free = tcp_chr_free;
}
static const TypeInfo char_socket_type_info = {
.name = TYPE_CHARDEV_SOCKET,
.parent = TYPE_CHARDEV,
.instance_size = sizeof(SocketChardev),
+ .instance_finalize = char_socket_finalize,
.class_init = char_socket_class_init,
};