From patchwork Wed Nov 21 11:21:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10692445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9E1C16B1 for ; Wed, 21 Nov 2018 11:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9479B2B96D for ; Wed, 21 Nov 2018 11:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82F962B9D8; Wed, 21 Nov 2018 11:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2933A2B96D for ; Wed, 21 Nov 2018 11:23:01 +0000 (UTC) Received: from localhost ([::1]:38543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPQay-0007ed-AO for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Nov 2018 06:23:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPQaB-0007EM-BY for qemu-devel@nongnu.org; Wed, 21 Nov 2018 06:22:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPQa6-0008Sz-B5 for qemu-devel@nongnu.org; Wed, 21 Nov 2018 06:22:11 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:32940) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPQa6-0008S4-2k for qemu-devel@nongnu.org; Wed, 21 Nov 2018 06:22:06 -0500 Received: by mail-pl1-x644.google.com with SMTP id z23so5127330plo.0 for ; Wed, 21 Nov 2018 03:22:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rfQYfWDVlMpdMOo8/yoOzCChBSgYI0gGxDOMZ4at65o=; b=s2CcM5jB+elkFNQf7pXk7ODSTMgGZssmPWjd6FFfSSf+qFKwRjpIf6tFJCV5N4Fhhu S+2Ks4rzgXXO7jxgAC1leLjuXNq9tJq3eLHxNHRoeRObLIDIJtkbjDQcc5VLt5UbgTtc m+Pmq9CGXP0lmKcb4k2U9E866OHyoDBD6pWqz1c7FOgJJRfV7pwkynorUovzCSFYhyx7 w6Njm3B6xi+ARw+WWwfUdruvdabC2FcH36cv+UFlLR6YPXJsQhf3eOKTitTtSduoLLac 6m6ZBTQEKArKc84G1YwkE3OJyZCiuuAaF9UVLKJI1JmDtYIYa/w8reFhIm0uFdAAb8gV viQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rfQYfWDVlMpdMOo8/yoOzCChBSgYI0gGxDOMZ4at65o=; b=YAxQtNA+wvAU7XW+oTfZs3bhk0JXew8tqtT8a6A62kqrITIqxVZFf+k09sav+wdlzu /Mb0DVavi1MVlbR+HiQgkR+wyHFNUfa1IOm6DiE/QKQUI+b9adBzXomwk3oJ92+ZlX4x dVXgMlUPJJ24uwINUy55Bk9+PBxqDX6eMDpSws+//P37PaiR7Jqw0WMZWDbwYvhpd5/0 G4afUPAJk2bSg16w+Kf79ANdCBaobjfRo8gAFFGFXaAz+VTtkeFTeQuFs5ksraOAC6sI IwRVJgBVaF+dAB0TOl22akarhTbscRz2cplnRK3Hu5dfTHLys4QT40TOvKpzZ9R2vSco AZrw== X-Gm-Message-State: AA+aEWZ18JruCv5kDrtBVhpuZigA6NuuryIsY+BJqR9f67ds5CssZcuj I1dU30vIjhoqX+T1173dlwI= X-Google-Smtp-Source: AFSGD/VjODkTZIEKq8y6W8sl9QbDwBQKukflgY26f1co+OgWNZ3kt3StAkTMvvCAZRSNUhl+sUuu/w== X-Received: by 2002:a62:d74d:: with SMTP id v13mr1972927pfl.34.1542799324601; Wed, 21 Nov 2018 03:22:04 -0800 (PST) Received: from localhost.localdomain.localdomain ([103.129.255.252]) by smtp.gmail.com with ESMTPSA id v191sm60362366pgb.77.2018.11.21.03.22.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:22:04 -0800 (PST) From: Li Qiang To: jasowang@redhat.com, mst@redhat.com Date: Wed, 21 Nov 2018 03:21:59 -0800 Message-Id: <1542799319-2595-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [PATCH] net: tap: use qemu_set_nonblock 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: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The fcntl will change the flags directly, use qemu_set_nonblock() instead. Signed-off-by: Li Qiang Reviewed-by: Daniel P. Berrangé Acked-by: Michael S. Tsirkin --- net/tap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/tap.c b/net/tap.c index cc8525f154..e8aadd8d4b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -592,7 +592,7 @@ int net_init_bridge(const Netdev *netdev, const char *name, return -1; } - fcntl(fd, F_SETFL, O_NONBLOCK); + qemu_set_nonblock(fd); vnet_hdr = tap_probe_vnet_hdr(fd); s = net_tap_fd_init(peer, "bridge", name, fd, vnet_hdr); @@ -707,7 +707,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } return; } - fcntl(vhostfd, F_SETFL, O_NONBLOCK); + qemu_set_nonblock(vhostfd); } options.opaque = (void *)(uintptr_t)vhostfd; @@ -791,7 +791,7 @@ int net_init_tap(const Netdev *netdev, const char *name, return -1; } - fcntl(fd, F_SETFL, O_NONBLOCK); + qemu_set_nonblock(fd); vnet_hdr = tap_probe_vnet_hdr(fd); @@ -839,7 +839,7 @@ int net_init_tap(const Netdev *netdev, const char *name, goto free_fail; } - fcntl(fd, F_SETFL, O_NONBLOCK); + qemu_set_nonblock(fd); if (i == 0) { vnet_hdr = tap_probe_vnet_hdr(fd); @@ -887,7 +887,7 @@ free_fail: return -1; } - fcntl(fd, F_SETFL, O_NONBLOCK); + qemu_set_nonblock(fd); vnet_hdr = tap_probe_vnet_hdr(fd); net_init_tap_one(tap, peer, "bridge", name, ifname,