From patchwork Fri Apr 12 12:20:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Kotov X-Patchwork-Id: 10898105 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 6812517E0 for ; Fri, 12 Apr 2019 12:22:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F1D228E6D for ; Fri, 12 Apr 2019 12:22:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 433D228E7A; Fri, 12 Apr 2019 12:22:36 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 711D928E6E for ; Fri, 12 Apr 2019 12:22:35 +0000 (UTC) Received: from localhost ([127.0.0.1]:35541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvCU-0007SC-Nm for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Apr 2019 08:22:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvAt-00067C-Ry for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEvAs-000716-Sz for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:55 -0400 Received: from forwardcorp1o.mail.yandex.net ([2a02:6b8:0:1a2d::193]:38406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvAs-0006zQ-Et for qemu-devel@nongnu.org; Fri, 12 Apr 2019 08:20:54 -0400 Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id A4EA92E1492; Fri, 12 Apr 2019 15:20:51 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:10]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yEKrHqEP7I-KpMSx8Gh; Fri, 12 Apr 2019 15:20:51 +0300 Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1555071651; bh=X5GmXqb1cHMB9+SLJFdxNHUQLC1wO/RQ408daMmcNII=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=G1FXis1JNaL87fH98myOLMYLAjuGzP6L6oow0QuX98QOsX+IS//oChKacPzy2E1Om e6sClb7vZOMhv24lILwi0OdzcMQ8JiWygs8tR7+v73LhJvDEAKCOY1ECauBqbCeSCz e8ec9Gg0tbzGQ4uBvfDxwg1+38ZT7lnxBljzqbeE= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:3404:6cb5:5ab:ed68]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id m4LakqlT7Q-Ko0WmlCv; Fri, 12 Apr 2019 15:20:50 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Fri, 12 Apr 2019 15:20:26 +0300 Message-Id: <20190412122028.7067-2-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190412122028.7067-1-yury-kotov@yandex-team.ru> References: <20190412122028.7067-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:6b8:0:1a2d::193 Subject: [Qemu-devel] [PATCH 1/3] monitor: Add monitor_recv_fd function to work with sent fds X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:All patches CC here" , yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Yury Kotov --- include/monitor/monitor.h | 1 + monitor.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index c1b40a9cac..9b9e593fb3 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -25,6 +25,7 @@ void monitor_cleanup(void); int monitor_suspend(Monitor *mon); void monitor_resume(Monitor *mon); +int monitor_recv_fd(Monitor *mon, Error **errp); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); diff --git a/monitor.c b/monitor.c index 4807bbe811..3ebbc08e5c 100644 --- a/monitor.c +++ b/monitor.c @@ -2206,9 +2206,8 @@ void qmp_getfd(const char *fdname, Error **errp) mon_fd_t *monfd; int fd, tmp_fd; - fd = qemu_chr_fe_get_msgfd(&cur_mon->chr); + fd = monitor_recv_fd(cur_mon, errp); if (fd == -1) { - error_setg(errp, QERR_FD_NOT_SUPPLIED); return; } @@ -2266,6 +2265,15 @@ void qmp_closefd(const char *fdname, Error **errp) error_setg(errp, QERR_FD_NOT_FOUND, fdname); } +int monitor_recv_fd(Monitor *mon, Error **errp) +{ + int fd = qemu_chr_fe_get_msgfd(&cur_mon->chr); + if (fd == -1) { + error_setg(errp, QERR_FD_NOT_SUPPLIED); + } + return fd; +} + int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp) { mon_fd_t *monfd; @@ -2335,9 +2343,8 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque, Monitor *mon = cur_mon; AddfdInfo *fdinfo; - fd = qemu_chr_fe_get_msgfd(&mon->chr); + fd = monitor_recv_fd(mon, errp); if (fd == -1) { - error_setg(errp, QERR_FD_NOT_SUPPLIED); goto error; }