From nobody Wed Nov 12 01:54:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1567579884; cv=none; d=zoho.com; s=zohoarc; b=ivNBvfUBTUwWGnvbVOFAW2ZCUH1oe/96qkKP3wMGfNEjVsmiTEnZBi6IXV0/NGf1yeynJN2VW+inSJXT6TKeBL9mXNsB8R1qaObfOo9kXqKQLNXqEl+Pwr/8+yYTifgfE742MS6NxSF6V9adRlPQfzxxiFIzoCLciIwLI3CJ8rY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567579884; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=ULiVf+jyOVK63DvPnfZEkpALabwDKPjy62kSVOpeUl4=; b=S6oCUe3k8fUAnoUDnug2QbIcdigW1QTIoxb2x0HwwEmUqOyH/tsn84V1mvb1b97zZ+30z038L1gKrI3/HzFfkcGHbFG6cT8jHa9DZbYst1UODh0qkZM1QTNMT5+HRbss0X80kRS0UVPs62F6LKtscjss4SHpTTp/GgR4TAVRvvQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156757988416923.59824788840831; Tue, 3 Sep 2019 23:51:24 -0700 (PDT) Received: from localhost ([::1]:53900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5P8S-0007Ho-GF for importer@patchew.org; Wed, 04 Sep 2019 02:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45438) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5P7e-0006pw-TI for qemu-devel@nongnu.org; Wed, 04 Sep 2019 02:50:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5P7d-00054e-Px for qemu-devel@nongnu.org; Wed, 04 Sep 2019 02:50:30 -0400 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2]:49520 helo=sipsolutions.net) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5P7d-00052p-JK for qemu-devel@nongnu.org; Wed, 04 Sep 2019 02:50:29 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.1) (envelope-from ) id 1i5P7X-0007vs-TB; Wed, 04 Sep 2019 08:50:24 +0200 From: Johannes Berg To: qemu-devel@nongnu.org Date: Wed, 4 Sep 2019 09:50:21 +0300 Message-Id: <20190904065021.1360-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:4f8:191:4433::2 Subject: [Qemu-devel] [PATCH] libvhost-user: introduce and use vu_has_protocol_feature() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Johannes Berg , Tiwei Bie , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Johannes Berg This simplifies the various has_feature() checks, we already have vu_has_feature() but it checks features, not protocol features. Signed-off-by: Johannes Berg Reviewed-by: Tiwei Bie --- contrib/libvhost-user/libvhost-user.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index fcf4a8a00ed2..fba291c13db4 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -94,6 +94,11 @@ bool vu_has_feature(VuDev *dev, return has_feature(dev->features, fbit); } =20 +static inline bool vu_has_protocol_feature(VuDev *dev, unsigned int fbit) +{ + return has_feature(dev->protocol_features, fbit); +} + static const char * vu_request_to_string(unsigned int req) { @@ -951,8 +956,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) { int i =3D 0; =20 - if (!has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD= )) { return 0; } =20 @@ -1097,8 +1101,7 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq *= vq, int fd, =20 vmsg.fd_num =3D fd_num; =20 - if (!has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)) { + if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD)= ) { return false; } =20 @@ -2199,8 +2202,7 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned i= nt idx, size_t sz) static int vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int desc_idx) { - if (!has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD= )) { return 0; } =20 @@ -2217,8 +2219,7 @@ vu_queue_inflight_get(VuDev *dev, VuVirtq *vq, int de= sc_idx) static int vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, int desc_idx) { - if (!has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD= )) { return 0; } =20 @@ -2234,8 +2235,7 @@ vu_queue_inflight_pre_put(VuDev *dev, VuVirtq *vq, in= t desc_idx) static int vu_queue_inflight_post_put(VuDev *dev, VuVirtq *vq, int desc_idx) { - if (!has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD)) { + if (!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD= )) { return 0; } =20 --=20 2.23.0