Commit 3ef91576 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/berrange/tags/qio-next-pull-request' into staging



# gpg: Signature made Wed 07 Mar 2018 11:24:41 GMT
# gpg:                using RSA key BE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/qio-next-pull-request:
  qio: non-default context for TLS handshake
  qio: non-default context for async conn
  qio: non-default context for threaded qtask
  qio: store gsources for net listeners
  qio: introduce qio_channel_add_watch_{full|source}
  qio: rename qio_task_thread_result

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 854a4436 1939ccda
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -707,6 +707,7 @@ static void tcp_chr_tls_init(Chardev *chr)
    qio_channel_tls_handshake(tioc,
                              tcp_chr_tls_handshake,
                              chr,
                              NULL,
                              NULL);
}

@@ -871,7 +872,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
    tcp_chr_set_client_ioc_name(chr, sioc);
    qio_channel_socket_connect_async(sioc, s->addr,
                                     qemu_chr_socket_connected,
                                     chr, NULL);
                                     chr, NULL, NULL);

    return false;
}
@@ -955,7 +956,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
        tcp_chr_set_client_ioc_name(chr, sioc);
        qio_channel_socket_connect_async(sioc, s->addr,
                                         qemu_chr_socket_connected,
                                         chr, NULL);
                                         chr, NULL, NULL);
    } else {
        if (s->is_listen) {
            char *name;
+12 −3
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
 * @callback: the function to invoke on completion
 * @opaque: user data to pass to @callback
 * @destroy: the function to free @opaque
 * @context: the context to run the async task. If %NULL, the default
 *           context will be used.
 *
 * Attempt to connect to the address @addr. This method
 * will run in the background so the caller will regain
@@ -113,7 +115,8 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
                                      SocketAddress *addr,
                                      QIOTaskFunc callback,
                                      gpointer opaque,
                                      GDestroyNotify destroy);
                                      GDestroyNotify destroy,
                                      GMainContext *context);


/**
@@ -138,6 +141,8 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
 * @callback: the function to invoke on completion
 * @opaque: user data to pass to @callback
 * @destroy: the function to free @opaque
 * @context: the context to run the async task. If %NULL, the default
 *           context will be used.
 *
 * Attempt to listen to the address @addr. This method
 * will run in the background so the caller will regain
@@ -150,7 +155,8 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
                                     SocketAddress *addr,
                                     QIOTaskFunc callback,
                                     gpointer opaque,
                                     GDestroyNotify destroy);
                                     GDestroyNotify destroy,
                                     GMainContext *context);


/**
@@ -179,6 +185,8 @@ int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
 * @callback: the function to invoke on completion
 * @opaque: user data to pass to @callback
 * @destroy: the function to free @opaque
 * @context: the context to run the async task. If %NULL, the default
 *           context will be used.
 *
 * Attempt to initialize a datagram socket bound to
 * @localAddr and communicating with peer @remoteAddr.
@@ -194,7 +202,8 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
                                    SocketAddress *remoteAddr,
                                    QIOTaskFunc callback,
                                    gpointer opaque,
                                    GDestroyNotify destroy);
                                    GDestroyNotify destroy,
                                    GMainContext *context);


/**
+4 −1
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@ qio_channel_tls_new_client(QIOChannel *master,
 * @func: the callback to invoke when completed
 * @opaque: opaque data to pass to @func
 * @destroy: optional callback to free @opaque
 * @context: the context that TLS handshake will run with. If %NULL,
 *           the default context will be used
 *
 * Perform the TLS session handshake. This method
 * will return immediately and the handshake will
@@ -126,7 +128,8 @@ qio_channel_tls_new_client(QIOChannel *master,
void qio_channel_tls_handshake(QIOChannelTLS *ioc,
                               QIOTaskFunc func,
                               gpointer opaque,
                               GDestroyNotify destroy);
                               GDestroyNotify destroy,
                               GMainContext *context);

/**
 * qio_channel_tls_get_session:
+44 −0
Original line number Diff line number Diff line
@@ -648,6 +648,50 @@ guint qio_channel_add_watch(QIOChannel *ioc,
                            gpointer user_data,
                            GDestroyNotify notify);

/**
 * qio_channel_add_watch_full:
 * @ioc: the channel object
 * @condition: the I/O condition to monitor
 * @func: callback to invoke when the source becomes ready
 * @user_data: opaque data to pass to @func
 * @notify: callback to free @user_data
 * @context: the context to run the watch source
 *
 * Similar as qio_channel_add_watch(), but allows to specify context
 * to run the watch source.
 *
 * Returns: the source ID
 */
guint qio_channel_add_watch_full(QIOChannel *ioc,
                                 GIOCondition condition,
                                 QIOChannelFunc func,
                                 gpointer user_data,
                                 GDestroyNotify notify,
                                 GMainContext *context);

/**
 * qio_channel_add_watch_source:
 * @ioc: the channel object
 * @condition: the I/O condition to monitor
 * @func: callback to invoke when the source becomes ready
 * @user_data: opaque data to pass to @func
 * @notify: callback to free @user_data
 * @context: gcontext to bind the source to
 *
 * Similar as qio_channel_add_watch(), but allows to specify context
 * to run the watch source, meanwhile return the GSource object
 * instead of tag ID, with the GSource referenced already.
 *
 * Note: callers is responsible to unref the source when not needed.
 *
 * Returns: the source pointer
 */
GSource *qio_channel_add_watch_source(QIOChannel *ioc,
                                      GIOCondition condition,
                                      QIOChannelFunc func,
                                      gpointer user_data,
                                      GDestroyNotify notify,
                                      GMainContext *context);

/**
 * qio_channel_attach_aio_context:
+20 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ struct QIONetListener {

    char *name;
    QIOChannelSocket **sioc;
    gulong *io_tag;
    GSource **io_source;
    size_t nsioc;

    bool connected;
@@ -120,17 +120,35 @@ void qio_net_listener_add(QIONetListener *listener,
                          QIOChannelSocket *sioc);

/**
 * qio_net_listener_set_client_func:
 * qio_net_listener_set_client_func_full:
 * @listener: the network listener object
 * @func: the callback function
 * @data: opaque data to pass to @func
 * @notify: callback to free @data
 * @context: the context that the sources will be bound to.  If %NULL,
 *           the default context will be used.
 *
 * Register @func to be invoked whenever a new client
 * connects to the listener. @func will be invoked
 * passing in the QIOChannelSocket instance for the
 * client.
 */
void qio_net_listener_set_client_func_full(QIONetListener *listener,
                                           QIONetListenerClientFunc func,
                                           gpointer data,
                                           GDestroyNotify notify,
                                           GMainContext *context);

/**
 * qio_net_listener_set_client_func:
 * @listener: the network listener object
 * @func: the callback function
 * @data: opaque data to pass to @func
 * @notify: callback to free @data
 *
 * Wrapper of qio_net_listener_set_client_func_full(), only that the
 * sources will always be bound to default main context.
 */
void qio_net_listener_set_client_func(QIONetListener *listener,
                                      QIONetListenerClientFunc func,
                                      gpointer data,
Loading