From patchwork Thu Aug 10 16:04:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 800261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xStVc6TCXz9t2k for ; Fri, 11 Aug 2017 02:14:00 +1000 (AEST) Received: from localhost ([::1]:53930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfq5u-0004yF-KP for incoming@patchwork.ozlabs.org; Thu, 10 Aug 2017 12:13:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dfpzG-0006OC-BA for qemu-devel@nongnu.org; Thu, 10 Aug 2017 12:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dfpzB-0003mc-Nm for qemu-devel@nongnu.org; Thu, 10 Aug 2017 12:07:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dfpz5-0003j7-JB; Thu, 10 Aug 2017 12:06:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F8DC160B6E; Thu, 10 Aug 2017 16:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9F8DC160B6E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from t460.lcy.redhat.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED61E8AD70; Thu, 10 Aug 2017 16:06:47 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 10 Aug 2017 17:04:48 +0100 Message-Id: <20170810160451.32723-6-berrange@redhat.com> In-Reply-To: <20170810160451.32723-1-berrange@redhat.com> References: <20170810160451.32723-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 10 Aug 2017 16:06:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/8] migration: convert socket server to QIONetListener X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Max Reitz , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of creating a QIOChannelSocket directly for the migration server socket, use a QIONetListener. This provides the ability to listen on multiple sockets at the same time, so enables full support for IPv4/IPv6 dual stack. Signed-off-by: Daniel P. Berrange --- migration/socket.c | 44 ++++++++++++++------------------------------ tests/test-sockets-proto.c | 3 +-- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/migration/socket.c b/migration/socket.c index 757d3821a1..34811addc5 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -24,6 +24,7 @@ #include "migration.h" #include "qemu-file.h" #include "io/channel-socket.h" +#include "io/net-listener.h" #include "trace.h" @@ -130,53 +131,36 @@ void unix_start_outgoing_migration(MigrationState *s, } -static gboolean socket_accept_incoming_migration(QIOChannel *ioc, - GIOCondition condition, - gpointer opaque) +static void socket_accept_incoming_migration(QIONetListener *listener, + QIOChannelSocket *cioc, + gpointer opaque) { - QIOChannelSocket *sioc; - Error *err = NULL; - - sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), - &err); - if (!sioc) { - error_report("could not accept migration connection (%s)", - error_get_pretty(err)); - goto out; - } - trace_migration_socket_incoming_accepted(); - qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming"); - migration_channel_process_incoming(QIO_CHANNEL(sioc)); - object_unref(OBJECT(sioc)); + qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming"); + migration_channel_process_incoming(QIO_CHANNEL(cioc)); -out: /* Close listening socket as its no longer needed */ - qio_channel_close(ioc, NULL); - return FALSE; /* unregister */ + qio_net_listener_disconnect(listener); + + object_unref(OBJECT(listener)); } static void socket_start_incoming_migration(SocketAddress *saddr, Error **errp) { - QIOChannelSocket *listen_ioc = qio_channel_socket_new(); + QIONetListener *listener = qio_net_listener_new(); - qio_channel_set_name(QIO_CHANNEL(listen_ioc), - "migration-socket-listener"); + qio_net_listener_set_name(listener, "migration-socket-listener"); - if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) { - object_unref(OBJECT(listen_ioc)); + if (qio_net_listener_open_sync(listener, saddr, errp) < 0) { + object_unref(OBJECT(listener)); qapi_free_SocketAddress(saddr); return; } - qio_channel_add_watch(QIO_CHANNEL(listen_ioc), - G_IO_IN, - socket_accept_incoming_migration, - listen_ioc, - (GDestroyNotify)object_unref); + qio_net_listener_set_client_func(listener, socket_accept_incoming_migration, NULL, NULL); qapi_free_SocketAddress(saddr); } diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c index 1d6beda59f..1495369696 100644 --- a/tests/test-sockets-proto.c +++ b/tests/test-sockets-proto.c @@ -70,8 +70,7 @@ typedef struct { static QSocketsData test_data[] = { /* Migrate with "" address */ /* XXX all settings with =off are disabled due to inet_parse() bug */ - /* XXX multilistener bug - should be .ipv6 = 1 */ - { .ipv4 = 1, .ipv6 = -1, .error = false, + { .ipv4 = 1, .ipv6 = 1, .error = false, .name = "/sockets/migrate/wildcard/all", .args = "-incoming tcp::9000" }, { .ipv4 = 1, .ipv6 = 0, .error = false,