chardev: use chardev's gcontext for async connect
Generalize the function to create the async QIO task connection. Also, fix the context pointer to use the chardev's gcontext. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20180306053320.15401-7-peterx@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c7278b4355
commit
3e7d4d20d3
@ -902,11 +902,22 @@ cleanup:
|
|||||||
object_unref(OBJECT(sioc));
|
object_unref(OBJECT(sioc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tcp_chr_connect_async(Chardev *chr)
|
||||||
|
{
|
||||||
|
SocketChardev *s = SOCKET_CHARDEV(chr);
|
||||||
|
QIOChannelSocket *sioc;
|
||||||
|
|
||||||
|
sioc = qio_channel_socket_new();
|
||||||
|
tcp_chr_set_client_ioc_name(chr, sioc);
|
||||||
|
qio_channel_socket_connect_async(sioc, s->addr,
|
||||||
|
qemu_chr_socket_connected,
|
||||||
|
chr, NULL, chr->gcontext);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean socket_reconnect_timeout(gpointer opaque)
|
static gboolean socket_reconnect_timeout(gpointer opaque)
|
||||||
{
|
{
|
||||||
Chardev *chr = CHARDEV(opaque);
|
Chardev *chr = CHARDEV(opaque);
|
||||||
SocketChardev *s = SOCKET_CHARDEV(opaque);
|
SocketChardev *s = SOCKET_CHARDEV(opaque);
|
||||||
QIOChannelSocket *sioc;
|
|
||||||
|
|
||||||
g_source_unref(s->reconnect_timer);
|
g_source_unref(s->reconnect_timer);
|
||||||
s->reconnect_timer = NULL;
|
s->reconnect_timer = NULL;
|
||||||
@ -915,11 +926,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sioc = qio_channel_socket_new();
|
tcp_chr_connect_async(chr);
|
||||||
tcp_chr_set_client_ioc_name(chr, sioc);
|
|
||||||
qio_channel_socket_connect_async(sioc, s->addr,
|
|
||||||
qemu_chr_socket_connected,
|
|
||||||
chr, NULL, NULL);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -999,11 +1006,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s->reconnect_time) {
|
if (s->reconnect_time) {
|
||||||
sioc = qio_channel_socket_new();
|
tcp_chr_connect_async(chr);
|
||||||
tcp_chr_set_client_ioc_name(chr, sioc);
|
|
||||||
qio_channel_socket_connect_async(sioc, s->addr,
|
|
||||||
qemu_chr_socket_connected,
|
|
||||||
chr, NULL, NULL);
|
|
||||||
} else {
|
} else {
|
||||||
if (s->is_listen) {
|
if (s->is_listen) {
|
||||||
char *name;
|
char *name;
|
||||||
|
Loading…
Reference in New Issue
Block a user