Received: from eggs.gnu.org ([208.118.235.92]:46966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TT6My-0006iK-Ue for qemu-devel@nongnu.org; Tue, 30 Oct 2012 03:36:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TT6Mx-00037K-T6 for qemu-devel@nongnu.org; Tue, 30 Oct 2012 03:36:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18190) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TT6Mx-000378-K0 for qemu-devel@nongnu.org; Tue, 30 Oct 2012 03:36:15 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9U7aDIe029879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 30 Oct 2012 03:36:14 -0400 From: Markus Armbruster References: <1351519903-26607-1-git-send-email-quintela@redhat.com> <1351519903-26607-8-git-send-email-quintela@redhat.com> <87objlp97t.fsf@blackfin.pond.sub.org> <87r4ohkwvj.fsf@elfo.mitica> Date: Tue, 30 Oct 2012 08:36:11 +0100 In-Reply-To: <87r4ohkwvj.fsf@elfo.mitica> (Juan Quintela's message of "Mon, 29 Oct 2012 18:32:00 +0100") Message-ID: <87y5ioh0no.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 07/18] migration: make writes blocking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: quintela@redhat.com Cc: owasserm@redhat.com, mtosatti@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com, avi@redhat.com Juan Quintela writes: > Markus Armbruster wrote: >> Juan Quintela writes: >> >>> Move all the writes to the migration_thread, and make writings >>> blocking. Notice that are still using the iothread for everything >>> that we do. >> [...] >>> diff --git a/qemu-sockets.c b/qemu-sockets.c >>> index cfed9c5..61b6e95 100644 >>> --- a/qemu-sockets.c >>> +++ b/qemu-sockets.c >>> @@ -276,9 +276,6 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, >>> return -1; >>> } >>> qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); >>> - if (connect_state != NULL) { >>> - socket_set_nonblock(sock); >>> - } >>> /* connect to peer */ >>> do { >>> rc = 0; >>> @@ -732,7 +729,6 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, >>> connect_state = g_malloc0(sizeof(*connect_state)); >>> connect_state->callback = callback; >>> connect_state->opaque = opaque; >>> - socket_set_nonblock(sock); >>> } >>> >>> memset(&un, 0, sizeof(un)); >> >> Doesn't this break inet_nonblocking_connect() and >> unix_nonblocking_connect()? >> >> In your cover letter, you wrote: >> >> Note: Writes has become blocking, and I have to change the "remove" >> the feature now in qemu-sockets.c. Checked that migration was the >> only user of that feature. If new users appear, they just need to add >> the socket_set_nonblock() by hand. >> >> Yes, migration-{tcp,unix} are their only users, but if they want a >> blocking socket now, why not use inet_connect() and unix_connect()? >> >> New users can't "just add socket_set_nonblock()". They'd have to add it >> right where you deleted it: between qemu_socket() and connect(). Else >> the connect() is blocking. > > Grrr. > > So, is there any way to make a connection that is non-blocking, but then > writes are blocking? Which operations on the migration socket do you need to block, and which ones do you need not to block? If connect() should block, use inet_connect() / unix_connect(). The returned socket will be blocking. You can then switch to non-blocking mode (and possibly back) at appropriate times. If connect() should not block, use inet_nonblocking_connect() and so forth.