From nobody Sun Feb 8 05:29:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506971961612411.9191119339429; Mon, 2 Oct 2017 12:19:21 -0700 (PDT) Received: from localhost ([::1]:53838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz6FE-0003v5-QJ for importer@patchew.org; Mon, 02 Oct 2017 15:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz6Bl-0001gZ-6h for qemu-devel@nongnu.org; Mon, 02 Oct 2017 15:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz6Bk-0000TA-4e for qemu-devel@nongnu.org; Mon, 02 Oct 2017 15:15:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46470) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz6Bj-0000Rw-S6 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 15:15:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 01CC37E430 for ; Mon, 2 Oct 2017 19:15:35 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-189.ams2.redhat.com [10.36.117.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0E0A60246; Mon, 2 Oct 2017 19:15:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 01CC37E430 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dgilbert@redhat.com From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, mst@redhat.com, marcandre.lureau@redhat.com, maxime.coquelin@redhat.com Date: Mon, 2 Oct 2017 20:15:21 +0100 Message-Id: <20171002191521.15748-5-dgilbert@redhat.com> In-Reply-To: <20171002191521.15748-1-dgilbert@redhat.com> References: <20171002191521.15748-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 02 Oct 2017 19:15:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] libvhost-user: Support VHOST_USER_SET_SLAVE_REQ_FD X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Allow the qemu to pass us a slave fd. We don't do anything with it yet. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Marc-Andr=C3=A9 Lureau --- contrib/libvhost-user/libvhost-user.c | 27 ++++++++++++++++++++++++++- contrib/libvhost-user/libvhost-user.h | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 1901311a70..756b60c4b3 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -703,7 +703,8 @@ vu_set_vring_err_exec(VuDev *dev, VhostUserMsg *vmsg) static bool vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) { - uint64_t features =3D 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD; + uint64_t features =3D 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | + 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ; =20 if (dev->iface->get_protocol_features) { features |=3D dev->iface->get_protocol_features(dev); @@ -757,6 +758,23 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vms= g) } =20 static bool +vu_set_slave_req_fd(VuDev *dev, VhostUserMsg *vmsg) +{ + if (vmsg->fd_num !=3D 1) { + vu_panic(dev, "Invalid slave_req_fd message (%d fd's)", vmsg->fd_n= um); + return false; + } + + if (dev->slave_fd !=3D -1) { + close(dev->slave_fd); + } + dev->slave_fd =3D vmsg->fds[0]; + DPRINT("Got slave_fd: %d\n", vmsg->fds[0]); + + return false; +} + +static bool vu_process_message(VuDev *dev, VhostUserMsg *vmsg) { int do_reply =3D 0; @@ -819,6 +837,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg) return vu_get_queue_num_exec(dev, vmsg); case VHOST_USER_SET_VRING_ENABLE: return vu_set_vring_enable_exec(dev, vmsg); + case VHOST_USER_SET_SLAVE_REQ_FD: + return vu_set_slave_req_fd(dev, vmsg); case VHOST_USER_NONE: break; default: @@ -892,6 +912,10 @@ vu_deinit(VuDev *dev) =20 =20 vu_close_log(dev); + if (dev->slave_fd !=3D -1) { + close(dev->slave_fd); + dev->slave_fd =3D -1; + } =20 if (dev->sock !=3D -1) { close(dev->sock); @@ -922,6 +946,7 @@ vu_init(VuDev *dev, dev->remove_watch =3D remove_watch; dev->iface =3D iface; dev->log_call_fd =3D -1; + dev->slave_fd =3D -1; for (i =3D 0; i < VHOST_MAX_NR_VIRTQUEUE; i++) { dev->vq[i] =3D (VuVirtq) { .call_fd =3D -1, .kick_fd =3D -1, .err_fd =3D -1, diff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/= libvhost-user.h index c2fc6da720..7534e97f92 100644 --- a/contrib/libvhost-user/libvhost-user.h +++ b/contrib/libvhost-user/libvhost-user.h @@ -226,6 +226,7 @@ struct VuDev { VuDevRegion regions[VHOST_MEMORY_MAX_NREGIONS]; VuVirtq vq[VHOST_MAX_NR_VIRTQUEUE]; int log_call_fd; + int slave_fd; uint64_t log_size; uint8_t *log_table; uint64_t features; --=20 2.13.6