From patchwork Mon Jun 6 16:45:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9158903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3214360572 for ; Mon, 6 Jun 2016 17:14:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215D5252D5 for ; Mon, 6 Jun 2016 17:14:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15C102834F; Mon, 6 Jun 2016 17:14:26 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D3E55252D5 for ; Mon, 6 Jun 2016 17:14:24 +0000 (UTC) Received: from localhost ([::1]:44020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9y6Z-0001CV-QN for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 13:14:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xed-0004Il-RL for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9xeY-0005ZN-PN for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:30 -0400 Received: from mail-qg0-x244.google.com ([2607:f8b0:400d:c04::244]:36789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xeY-0005ZE-Kh for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:26 -0400 Received: by mail-qg0-x244.google.com with SMTP id k43so5932484qgk.3 for ; Mon, 06 Jun 2016 09:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+EKRnlzrqZqfFxrAIzdN64njLbtlIN1cYo19xf/J6E=; b=Xfp1J0WSi+B522pLNiHP3tVOzcT56c94WhFOK4qQ+NRUdyjVr438yoiW638qUwb1bw hnBqj42tCHdsU7gKWKob/tnXFj859O63VrS2NiagB6gbiT1tQauhiluxzVD/KK7bt6hu XNwBKGe2H6gaX7h8YRr2OJWihJ4hHeL940b0FNhWIqx6X033/BGMeVQp5dr90T5AhN62 NXSqM342vT2KpJDHlHufx8oG+Q039vF5V4A3GjFGKnmE9/eN3Ae8DI4oGpAASNJuOxe0 RMAQ7AiKxrYhtKRXZD4rnUugh0e0dHpjIjGoSndYaqjHrbxbU7UBjSix70QURKmfPWlv 0SEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=c+EKRnlzrqZqfFxrAIzdN64njLbtlIN1cYo19xf/J6E=; b=kgpDAwEPo1ZWIIsZrFleYuSF6fdnNDjIDQo+sj8dIvLYWwgUvUeMdmJdtRa/dak7hE ppEoJGQF0pM/WKDmiop25Bxdo0ryFT0CuPi3bFB87jWG7Heja9kgpqprIYkVL3csNIKj MquPBSGPANPEw8TRetrBt3yc+r80HhJAdEjW1cAlG7xXl0a2b3UY1o/c+QQJz3dW6zgX 4H0XazAeXSzuxFMxeIcUNFNSuOAVZdWU0JDntAcHfDQdBx/zeD0C5Iq3YarV3QIECHCK fZktCzFj6H3dBmlwyVi7UXNYFqg0Nc+PWA9YttwEyRoUezc8quLS+JKy64C7hRY7Cwou 9WvQ== X-Gm-Message-State: ALyK8tLR6z2/DKdFVebtsRToRTAGm0m0qe5JCoCPN1M5t8ebmwddpIQ9v2tH8vjFeXOyvw== X-Received: by 10.140.107.198 with SMTP id h64mr15651623qgf.36.1465231526184; Mon, 06 Jun 2016 09:45:26 -0700 (PDT) Received: from localhost (APoitiers-110-1-1-130.w193-248.abo.wanadoo.fr. [193.248.103.130]) by smtp.gmail.com with ESMTPSA id j36sm1909866qgd.9.2016.06.06.09.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 09:45:25 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 18:45:02 +0200 Message-Id: <1465231508-30183-5-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465231508-30183-1-git-send-email-marcandre.lureau@redhat.com> References: <1465231508-30183-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::244 Subject: [Qemu-devel] [PATCH 04/10] qemu-char: add qemu_chr_disconnect to close a fd accepted by listen fd 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: Tetsuya Mukawa , Ilya Maximets , Yuanhan Liu , jonshin@cisco.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Tetsuya Mukawa The patch introduces qemu_chr_disconnect(). The function is used for closing a fd accepted by listen fd. Though we already have qemu_chr_delete(), but it closes not only accepted fd but also listen fd. This new function is used when we still want to keep listen fd. Signed-off-by: Tetsuya Mukawa Reviewed-by: Marc-André Lureau Tested-by: Yuanhan Liu Reviewed-by: Yuanhan Liu --- include/sysemu/char.h | 7 +++++++ qemu-char.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 307fd8f..2c39987 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -75,6 +75,7 @@ struct CharDriverState { IOReadHandler *chr_read; void *handler_opaque; void (*chr_close)(struct CharDriverState *chr); + void (*chr_disconnect)(struct CharDriverState *chr); void (*chr_accept_input)(struct CharDriverState *chr); void (*chr_set_echo)(struct CharDriverState *chr, bool echo); void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open); @@ -143,6 +144,12 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); */ CharDriverState *qemu_chr_new(const char *label, const char *filename, void (*init)(struct CharDriverState *s)); +/** + * @qemu_chr_disconnect: + * + * Close a fd accpeted by character backend. + */ +void qemu_chr_disconnect(CharDriverState *chr); /** * @qemu_chr_new_noreplay: diff --git a/qemu-char.c b/qemu-char.c index b597ee1..6efbc0d 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -4012,6 +4012,13 @@ void qemu_chr_fe_release(CharDriverState *s) s->avail_connections++; } +void qemu_chr_disconnect(CharDriverState *chr) +{ + if (chr->chr_disconnect) { + chr->chr_disconnect(chr); + } +} + static void qemu_chr_free_common(CharDriverState *chr) { g_free(chr->filename); @@ -4405,6 +4412,7 @@ static CharDriverState *qmp_chardev_open_socket(const char *id, chr->chr_write = tcp_chr_write; chr->chr_sync_read = tcp_chr_sync_read; chr->chr_close = tcp_chr_close; + chr->chr_disconnect = tcp_chr_disconnect; chr->get_msgfds = tcp_get_msgfds; chr->set_msgfds = tcp_set_msgfds; chr->chr_add_client = tcp_chr_add_client;