From patchwork Sat Nov 30 15:49:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 295585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 774B52C009A for ; Sun, 1 Dec 2013 02:49:25 +1100 (EST) Received: from localhost ([::1]:52376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmmnJ-0000wS-IF for incoming@patchwork.ozlabs.org; Sat, 30 Nov 2013 10:49:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vmmn0-0000vj-Ec for qemu-devel@nongnu.org; Sat, 30 Nov 2013 10:49:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vmmmz-0000Us-IG for qemu-devel@nongnu.org; Sat, 30 Nov 2013 10:49:02 -0500 Received: from mail-oa0-x229.google.com ([2607:f8b0:4003:c02::229]:58952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vmmmz-0000Uf-Cw for qemu-devel@nongnu.org; Sat, 30 Nov 2013 10:49:01 -0500 Received: by mail-oa0-f41.google.com with SMTP id j17so11614536oag.0 for ; Sat, 30 Nov 2013 07:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=cYkRQbMSqdMkY/lB/ajNjVG0AlY4DW6N8auCVH789MU=; b=MF1+BRHpw6sPczvGjRcd/T08U9bftRmVcNLtcHBwMyfZgbXm5il87bIr/c+Va53yps iN42wowY0SBpPv8A0gYLH8CZKEH54V9iZPLQEja7tDHD3XpChjObHUeE+pVmsSSMUMyh 521J1H93nbBf33LDhZYNG0A1eVgnl0IPxUJS6iWsHYVeLE58sBeqIOlV0YbjbUHK/p03 rpAQko88qEo5cNA3GZkmb874eJ2BA3XduCtfe0bPdrcvquqMQGpffbnnsT+lStt1Df1f B2dtYn7ypOrCmw4FnPkhtduv24O8JJ5xfGkaR4iOI14gAOxm+mh3ezfMUmgiOypy2v6i Hb/A== MIME-Version: 1.0 X-Received: by 10.60.44.36 with SMTP id b4mr27608oem.53.1385826540299; Sat, 30 Nov 2013 07:49:00 -0800 (PST) Received: by 10.182.102.66 with HTTP; Sat, 30 Nov 2013 07:49:00 -0800 (PST) In-Reply-To: <5298B152.10805@redhat.com> References: <1385737124-13964-1-git-send-email-marcandre.lureau@gmail.com> <1385737124-13964-10-git-send-email-marcandre.lureau@gmail.com> <5298B152.10805@redhat.com> Date: Sat, 30 Nov 2013 16:49:00 +0100 Message-ID: From: =?ISO-8859-1?Q?Marc=2DAndr=E9_Lureau?= To: Paolo Bonzini X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c02::229 Cc: =?ISO-8859-1?Q?Marc=2DAndr=E9_Lureau?= , qemu-devel@nongnu.org, Gerd Hoffmann Subject: Re: [Qemu-devel] [PATCH 09/13] nbd: don't change socket block during negotiate X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Fri, Nov 29, 2013 at 4:22 PM, Paolo Bonzini wrote: > If you remove this here, you need to remove also the matching > socket_set_nonblock, Ok > Also, there are two callers: > > - nbd.c: you can add nbd_socket_block/nonblock around > nbd_receive_negotiate in nbd_open. > > - qemu-nbd.c: here the socket can remain in blocking mode. In fact it > is blocking before the call to nbd_receive_negotiate, because > unix_connect_opts is missing a call to qemu_set_block (bug!). I suggest > that you add the call to qemu_set_nonblock there, and add qemu_set_block > in nbd_client_thread. Sorry, I guess I assumed wrongly that the sync nbd reader and writer would handle all cases. So you suggest this block/unblock: (I haven't reviewed all callers of unix_connect_opts(), I am not sure that's what you meant) Other option would be to move the nonblock to unix_socket_outgoing. diff --git a/block/nbd-client.c b/block/nbd-client.c index 1abfc6a..693110d 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -348,6 +348,7 @@ int nbd_client_session_init(NbdClientSession *client, int ret; /* NBD handshake */ + qemu_set_block(sock); ret = nbd_receive_negotiate(sock, client->export_name, &client->nbdflags, &client->size, &client->blocksize); diff --git a/qemu-nbd.c b/qemu-nbd.c index c26c98e..008fbf0 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -224,6 +224,7 @@ static void *nbd_client_thread(void *arg) goto out; } + qemu_set_block(sock); ret = nbd_receive_negotiate(sock, NULL, &nbdflags, &size, &blocksize); if (ret < 0) { diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 6b97dc1..81f2660 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -747,6 +747,8 @@ int unix_connect_opts(QemuOpts *opts, Error **errp, } } while (rc == -EINTR); + qemu_set_nonblock(sock); + if (connect_state != NULL && QEMU_SOCKET_RC_INPROGRESS(rc)) { connect_state->fd = sock; qemu_set_fd_handler2(sock, NULL, NULL, wait_for_connect,