From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606298935; cv=none; d=zohomail.com; s=zohoarc; b=Tpy5FUVJonp8NHoWNDE8vnEsyFNlAxLrkao1KWx6GF8Pk7mfuUoDm754UZjSb3RvUgSGGTHDM1Fs2i2PVSHYkGQqe+uCGRskpI0VgNotvKb2yh06lVVGe3KOeSx3Fwg2GUHO8ZTHXkbXwvQcMoDL5Peh3MLfULkcdnVVLA9Nbq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606298935; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NSc9KIWokFq/Ju/2Oi+1Zj159QVUkHXXJwebK4Rf+7Y=; b=aZ5CaHlZn824yu7nKDVW++04fRoin+dqY180ZSi9DjtoQoFE+1Rk0swTxfEQnBl/I3/yEwEDeI4D8Dknr9t43sLsyB0+ih8oLLujDSmIcstRqQyaAWr4XLblRsVdjjiEHBNp1Yc9aKZQU0+b0tPrkitROLoP9Xt2sZdFLH9pgqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606298935022500.925183616485; Wed, 25 Nov 2020 02:08:55 -0800 (PST) Received: from localhost ([::1]:46050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrjK-0007Cz-9T for importer@patchew.org; Wed, 25 Nov 2020 05:08:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khrhc-0005tO-9b for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrha-0002vx-6P for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-fvaqY5j1NM24HSEVD3cZWg-1; Wed, 25 Nov 2020 05:07:02 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9181E51EE for ; Wed, 25 Nov 2020 10:07:01 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B40160BE5; Wed, 25 Nov 2020 10:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NSc9KIWokFq/Ju/2Oi+1Zj159QVUkHXXJwebK4Rf+7Y=; b=AZpjOeJUhg+yCKYIXIajpC0qM0Mb/I3bqRwurgracirjpd9eBDoXr9dEyLpyCrUK1OZOvQ Z5V+bNJx8bHh68aVJZ8/tYNS/hzHZDX1LUS86Bm72H70V3q3Su7kuBA1YVsZ9raPEr+xSl 5Vxtq3ZBBF79XWfikV1MXDdlYlQY3xY= X-MC-Unique: fvaqY5j1NM24HSEVD3cZWg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 1/8] libvhost-user: replace qemu/bswap.h with glibc endian.h Date: Wed, 25 Nov 2020 14:06:33 +0400 Message-Id: <20201125100640.366523-2-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Stefan Hajnoczi --- contrib/libvhost-user/libvhost-user.c | 77 ++++++++++++++------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 5c73ffdd6b..1c1cfbf1e7 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "qemu/compiler.h" =20 #if defined(__linux__) @@ -42,7 +43,6 @@ =20 #include "qemu/atomic.h" #include "qemu/osdep.h" -#include "qemu/bswap.h" #include "qemu/memfd.h" =20 #include "libvhost-user.h" @@ -1081,7 +1081,7 @@ vu_set_vring_addr_exec(VuDev *dev, VhostUserMsg *vmsg) return false; } =20 - vq->used_idx =3D lduw_le_p(&vq->vring.used->idx); + vq->used_idx =3D le16toh(vq->vring.used->idx); =20 if (vq->last_avail_idx !=3D vq->used_idx) { bool resume =3D dev->iface->queue_is_processed_in_order && @@ -1198,7 +1198,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) return 0; } =20 - vq->used_idx =3D lduw_le_p(&vq->vring.used->idx); + vq->used_idx =3D le16toh(vq->vring.used->idx); vq->resubmit_num =3D 0; vq->resubmit_list =3D NULL; vq->counter =3D 0; @@ -2031,13 +2031,13 @@ vu_queue_started(const VuDev *dev, const VuVirtq *v= q) static inline uint16_t vring_avail_flags(VuVirtq *vq) { - return lduw_le_p(&vq->vring.avail->flags); + return le16toh(vq->vring.avail->flags); } =20 static inline uint16_t vring_avail_idx(VuVirtq *vq) { - vq->shadow_avail_idx =3D lduw_le_p(&vq->vring.avail->idx); + vq->shadow_avail_idx =3D le16toh(vq->vring.avail->idx); =20 return vq->shadow_avail_idx; } @@ -2045,7 +2045,7 @@ vring_avail_idx(VuVirtq *vq) static inline uint16_t vring_avail_ring(VuVirtq *vq, int i) { - return lduw_le_p(&vq->vring.avail->ring[i]); + return le16toh(vq->vring.avail->ring[i]); } =20 static inline uint16_t @@ -2133,12 +2133,12 @@ virtqueue_read_next_desc(VuDev *dev, struct vring_d= esc *desc, int i, unsigned int max, unsigned int *next) { /* If this descriptor says it doesn't chain, we're done. */ - if (!(lduw_le_p(&desc[i].flags) & VRING_DESC_F_NEXT)) { + if (!(le16toh(desc[i].flags) & VRING_DESC_F_NEXT)) { return VIRTQUEUE_READ_DESC_DONE; } =20 /* Check they're not leading us off end of descriptors. */ - *next =3D lduw_le_p(&desc[i].next); + *next =3D le16toh(desc[i].next); /* Make sure compiler knows to grab that: we don't want it changing! */ smp_wmb(); =20 @@ -2181,8 +2181,8 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, uns= igned int *in_bytes, } desc =3D vq->vring.desc; =20 - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_INDIRECT) { - if (ldl_le_p(&desc[i].len) % sizeof(struct vring_desc)) { + if (le16toh(desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (le32toh(desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); goto err; } @@ -2195,8 +2195,8 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, uns= igned int *in_bytes, =20 /* loop over the indirect descriptor table */ indirect =3D 1; - desc_addr =3D ldq_le_p(&desc[i].addr); - desc_len =3D ldl_le_p(&desc[i].len); + desc_addr =3D le64toh(desc[i].addr); + desc_len =3D le32toh(desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2223,10 +2223,10 @@ vu_queue_get_avail_bytes(VuDev *dev, VuVirtq *vq, u= nsigned int *in_bytes, goto err; } =20 - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_WRITE) { - in_total +=3D ldl_le_p(&desc[i].len); + if (le16toh(desc[i].flags) & VRING_DESC_F_WRITE) { + in_total +=3D le32toh(desc[i].len); } else { - out_total +=3D ldl_le_p(&desc[i].len); + out_total +=3D le32toh(desc[i].len); } if (in_total >=3D max_in_bytes && out_total >=3D max_out_bytes= ) { goto done; @@ -2377,7 +2377,7 @@ vring_used_flags_set_bit(VuVirtq *vq, int mask) =20 flags =3D (uint16_t *)((char*)vq->vring.used + offsetof(struct vring_used, flags)); - stw_le_p(flags, lduw_le_p(flags) | mask); + *flags =3D htole16(le16toh(*flags) | mask); } =20 static inline void @@ -2387,17 +2387,20 @@ vring_used_flags_unset_bit(VuVirtq *vq, int mask) =20 flags =3D (uint16_t *)((char*)vq->vring.used + offsetof(struct vring_used, flags)); - stw_le_p(flags, lduw_le_p(flags) & ~mask); + *flags =3D htole16(le16toh(*flags) & ~mask); } =20 static inline void vring_set_avail_event(VuVirtq *vq, uint16_t val) { + uint16_t *avail; + if (!vq->notification) { return; } =20 - stw_le_p(&vq->vring.used->ring[vq->vring.num], val); + avail =3D (uint16_t *)&vq->vring.used->ring[vq->vring.num]; + *avail =3D htole16(val); } =20 void @@ -2487,15 +2490,15 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned= int idx, size_t sz) struct vring_desc desc_buf[VIRTQUEUE_MAX_SIZE]; int rc; =20 - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_INDIRECT) { - if (ldl_le_p(&desc[i].len) % sizeof(struct vring_desc)) { + if (le16toh(desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (le32toh(desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); return NULL; } =20 /* loop over the indirect descriptor table */ - desc_addr =3D ldq_le_p(&desc[i].addr); - desc_len =3D ldl_le_p(&desc[i].len); + desc_addr =3D le64toh(desc[i].addr); + desc_len =3D le32toh(desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2517,11 +2520,11 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned= int idx, size_t sz) =20 /* Collect all the descriptors */ do { - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_WRITE) { + if (le16toh(desc[i].flags) & VRING_DESC_F_WRITE) { if (!virtqueue_map_desc(dev, &in_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, - ldq_le_p(&desc[i].addr), - ldl_le_p(&desc[i].len))) { + le64toh(desc[i].addr), + le32toh(desc[i].len))) { return NULL; } } else { @@ -2531,8 +2534,8 @@ vu_queue_map_desc(VuDev *dev, VuVirtq *vq, unsigned i= nt idx, size_t sz) } if (!virtqueue_map_desc(dev, &out_num, iov, VIRTQUEUE_MAX_SIZE, false, - ldq_le_p(&desc[i].addr), - ldl_le_p(&desc[i].len))) { + le64toh(desc[i].addr), + le32toh(desc[i].len))) { return NULL; } } @@ -2731,15 +2734,15 @@ vu_log_queue_fill(VuDev *dev, VuVirtq *vq, max =3D vq->vring.num; i =3D elem->index; =20 - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_INDIRECT) { - if (ldl_le_p(&desc[i].len) % sizeof(struct vring_desc)) { + if (le16toh(desc[i].flags) & VRING_DESC_F_INDIRECT) { + if (le32toh(desc[i].len) % sizeof(struct vring_desc)) { vu_panic(dev, "Invalid size for indirect buffer table"); return; } =20 /* loop over the indirect descriptor table */ - desc_addr =3D ldq_le_p(&desc[i].addr); - desc_len =3D ldl_le_p(&desc[i].len); + desc_addr =3D le64toh(desc[i].addr); + desc_len =3D le32toh(desc[i].len); max =3D desc_len / sizeof(struct vring_desc); read_len =3D desc_len; desc =3D vu_gpa_to_va(dev, &read_len, desc_addr); @@ -2765,9 +2768,9 @@ vu_log_queue_fill(VuDev *dev, VuVirtq *vq, return; } =20 - if (lduw_le_p(&desc[i].flags) & VRING_DESC_F_WRITE) { - min =3D MIN(ldl_le_p(&desc[i].len), len); - vu_log_write(dev, ldq_le_p(&desc[i].addr), min); + if (le16toh(desc[i].flags) & VRING_DESC_F_WRITE) { + min =3D MIN(le32toh(desc[i].len), len); + vu_log_write(dev, le64toh(desc[i].addr), min); len -=3D min; } =20 @@ -2792,15 +2795,15 @@ vu_queue_fill(VuDev *dev, VuVirtq *vq, =20 idx =3D (idx + vq->used_idx) % vq->vring.num; =20 - stl_le_p(&uelem.id, elem->index); - stl_le_p(&uelem.len, len); + uelem.id =3D htole32(elem->index); + uelem.len =3D htole32(len); vring_used_write(dev, vq, &uelem, idx); } =20 static inline void vring_used_idx_set(VuDev *dev, VuVirtq *vq, uint16_t val) { - stw_le_p(&vq->vring.used->idx, val); + vq->vring.used->idx =3D htole16(val); vu_log_write(dev, vq->vring.log_guest_addr + offsetof(struct vring_used, id= x), sizeof(vq->vring.used->idx)); --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606298941; cv=none; d=zohomail.com; s=zohoarc; b=lnK6UBjekDbtuBpr6sMO4fZm/IAR3G1DVY7psOrw0fNboI1bmFys9K+Q2nja7I3TgaAEM36IAqRtZ0dr5wEzPnKRyJg2AtpFnn/7aQU5uOh/JZoiSDtrfZw7Xvw2zKX9w/xO6N6yyAXC35am5dcIpYnXk7KXtBVhUdl/EM/ovo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606298941; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=73kRW6OtmRhGC0QRECE6dE6dl6vC7QWsXeROUjaRrSc=; b=SQd6NtwKIOC3aCCkRnpbEV1F9hCj2fuZ73EYY8cHDcpuH9VZX8vIASSiRykjti1XmqStveAa+ORCBEfGxs2Doz4Ku7LeXsZvta9D4dCBM9/liz6ZUY9mb+ANJoGOXMSrYCX3QrTxBvlV71w3aoCRwPAOfAEmffVlFMXbOLU9iRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606298941580698.5789049349635; Wed, 25 Nov 2020 02:09:01 -0800 (PST) Received: from localhost ([::1]:46720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrjQ-0007TW-O7 for importer@patchew.org; Wed, 25 Nov 2020 05:09:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khrht-00065v-V6 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrhp-00030C-E1 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:25 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-205-Ues1Db9RP1CAWIlMy4bqwg-1; Wed, 25 Nov 2020 05:07:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B624D85C734 for ; Wed, 25 Nov 2020 10:07:17 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E07665D6AC; Wed, 25 Nov 2020 10:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=73kRW6OtmRhGC0QRECE6dE6dl6vC7QWsXeROUjaRrSc=; b=Kr3gqM4CGAk51wsfPXadkuCM36ou3id6qAHwWIzuLDN3S6I9l4K8s8HwgxraABOrMuP659 EavZcQkFuoPL9u7LjXdax2aRvrYf2nsksay/VZB/S7DSYtWpIVpw/NPp0SyTpB1OSkcKy8 kx1WSgCFrVX3c0JcGade1aiswpBV0tQ= X-MC-Unique: Ues1Db9RP1CAWIlMy4bqwg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 2/8] libvhost-user: replace qemu/memfd.h usage Date: Wed, 25 Nov 2020 14:06:34 +0400 Message-Id: <20201125100640.366523-3-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Undo the damage from commit 5f9ff1eff3 ("libvhost-user: Support tracking inflight I/O in shared memory") which introduced glib dependency through osdep.h inclusion. libvhost-user.c tries to stay free from glib usage. Use glibc memfd_create directly when available (assumed so when MFD_ALLOW_SEALING is defined). A following commit will make the project standalone and check for memfd API at configure time, instead of a panic at runtime. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- contrib/libvhost-user/libvhost-user.c | 50 +++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 1c1cfbf1e7..54aabd1878 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -42,8 +42,6 @@ #endif =20 #include "qemu/atomic.h" -#include "qemu/osdep.h" -#include "qemu/memfd.h" =20 #include "libvhost-user.h" =20 @@ -1615,11 +1613,45 @@ vu_inflight_queue_size(uint16_t queue_size) sizeof(uint16_t), INFLIGHT_ALIGNMENT); } =20 +#ifdef MFD_ALLOW_SEALING +static void * +memfd_alloc(const char *name, size_t size, unsigned int flags, int *fd) +{ + void *ptr; + int ret; + + *fd =3D memfd_create(name, MFD_ALLOW_SEALING); + if (*fd < 0) { + return NULL; + } + + ret =3D ftruncate(*fd, size); + if (ret < 0) { + close(*fd); + return NULL; + } + + ret =3D fcntl(*fd, F_ADD_SEALS, flags); + if (ret < 0) { + close(*fd); + return NULL; + } + + ptr =3D mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0); + if (ptr =3D=3D MAP_FAILED) { + close(*fd); + return NULL; + } + + return ptr; +} +#endif + static bool vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg) { - int fd; - void *addr; + int fd =3D -1; + void *addr =3D NULL; uint64_t mmap_size; uint16_t num_queues, queue_size; =20 @@ -1637,9 +1669,13 @@ vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg) =20 mmap_size =3D vu_inflight_queue_size(queue_size) * num_queues; =20 - addr =3D qemu_memfd_alloc("vhost-inflight", mmap_size, - F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL, - &fd, NULL); +#ifdef MFD_ALLOW_SEALING + addr =3D memfd_alloc("vhost-inflight", mmap_size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL, + &fd); +#else + vu_panic(dev, "Not implemented: memfd support is missing"); +#endif =20 if (!addr) { vu_panic(dev, "Failed to alloc vhost inflight area"); --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606299027; cv=none; d=zohomail.com; s=zohoarc; b=JBsc7fG7hjXmqp02+OiL0MDFPSD+QaS+okUc/V5FLkK/taJ+6pn9TcZO1vYsOtE/krmg8shC386xyC4L5loOCsG1i+c20bpY/Bnzhwts2ZGrk1puXWpMTKghJ0Qcfv+IzuseBLDczA6C8H+SQ8bVqVxpPtoDGuVNPcFf0yc3xa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606299027; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=resTmBOu2Trljsiz3+dhH63iJotQEOPJ9vQNSilVKmM=; b=VXIzpJl/4nNK6xIaQiLvnNuwagvN60bt6trAsBrV+7R/FTpdH5s22oVX7hW3ZYQ6XOeUIHqHqWHaxk05AenG4jI1XBR70pqzPZm1Q26FOhSEgLxvHDjGuvdD/oHHa7lLvEuXCEMVfiCQTNw5zeSEDrwufQhnRs3H2s76eMzN6+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606299027418832.3137289920708; Wed, 25 Nov 2020 02:10:27 -0800 (PST) Received: from localhost ([::1]:53542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrkm-0001n3-Ss for importer@patchew.org; Wed, 25 Nov 2020 05:10:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khri5-0006E8-CI for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khri3-00034q-Q6 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-mfpR-fjMNWmb5f3q65MwGA-1; Wed, 25 Nov 2020 05:07:33 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62C45805BE6 for ; Wed, 25 Nov 2020 10:07:32 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 805C519C78; Wed, 25 Nov 2020 10:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=resTmBOu2Trljsiz3+dhH63iJotQEOPJ9vQNSilVKmM=; b=iPYlOgFTNrsAW56E56x3VLdpL/sOQyzmSSeaiLV+QXgHEAUgMvtvMjAm3v3gtnFOZOGEqA BTYXQLAuhKHzgX38B8IoS7AHh+jx1VaARbXwRcJdkMlLf6x0t8+GvaJwdF5g89j9ts5oyc ejg7WY999gtBRL2GipsWN3zb+psYLWM= X-MC-Unique: mfpR-fjMNWmb5f3q65MwGA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 3/8] libvhost-user: remove qemu/compiler.h usage Date: Wed, 25 Nov 2020 14:06:35 +0400 Message-Id: <20201125100640.366523-4-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- contrib/libvhost-user/libvhost-user.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/= libvhost-user.c index 54aabd1878..fab7ca17ee 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -27,7 +27,6 @@ #include #include #include -#include "qemu/compiler.h" =20 #if defined(__linux__) #include @@ -60,6 +59,10 @@ /* Round number up to multiple */ #define ALIGN_UP(n, m) ALIGN_DOWN((n) + (m) - 1, (m)) =20 +#ifndef unlikely +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + /* Align each region to cache line size in inflight buffer */ #define INFLIGHT_ALIGNMENT 64 =20 --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606299066; cv=none; d=zohomail.com; s=zohoarc; b=REfM3cOLnSyQ6YU2DT6E9Og9DT8TO/8VhyLvLX9IJ8PjCHETV4chR5eIoSPaduAGbaSoJNCkqO0gEAd3TF68YXd1tt0sg/0I1ZDgVz6ljLtbvvsmn4ZNUP/ezHYBjaI/zbh9kooDKVnoQ0Rl4rtXrzbp4mmXlCVX0wZnFkziRzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606299066; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b1lHrR7UqS992aHmKmG+9NvlnLrwHyHJ4vTokZv2bKc=; b=NRtIkOXS26Iqu7HOlKXD853M7yjtQXpW/8VHEF6bGucB3X03W/LHB/HFzn/DR2tMRGYOYo3yUEjVa7wi+lpbcrBv1x0YDLptZWyrtGFvB1OT3GKApT16BjYoGR4qwA1uCd6zeQS2E9CrYGKwrcwqFyJDvn817Ea4eG7S4WB4OGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606299066130791.8167565838678; Wed, 25 Nov 2020 02:11:06 -0800 (PST) Received: from localhost ([::1]:55174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrlR-0002Qx-Eb for importer@patchew.org; Wed, 25 Nov 2020 05:11:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khriQ-0006Ru-Jt for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khriO-0003As-U8 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:07:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-ztK8R0zyOqiCVd3FTVoYrg-1; Wed, 25 Nov 2020 05:07:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB144180E492 for ; Wed, 25 Nov 2020 10:07:51 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4E3D5D6AC; Wed, 25 Nov 2020 10:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298874; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b1lHrR7UqS992aHmKmG+9NvlnLrwHyHJ4vTokZv2bKc=; b=S3bhdIxq7sZkKnkjrTXYDN/Z5N21czQDsS9/W8kFdFC6Ku8/tesgt02bH7vlwCnSBTPyN/ e9oAFuZxO3hYfJri2OicDSWKFVN8BevtAAPNX1DnwMhYw4uB9PVTQ38gvqv29Ugj7uhpVI ny3bMz0pV8x4fRvYUU7ZVKFnT9P19vQ= X-MC-Unique: ztK8R0zyOqiCVd3FTVoYrg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 4/8] libvhost-user: drop qemu/osdep.h dependency Date: Wed, 25 Nov 2020 14:06:36 +0400 Message-Id: <20201125100640.366523-5-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- contrib/libvhost-user/libvhost-user-glib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-= user/libvhost-user-glib.c index 0df2ec9271..efc9d814e3 100644 --- a/contrib/libvhost-user/libvhost-user-glib.c +++ b/contrib/libvhost-user/libvhost-user-glib.c @@ -12,10 +12,16 @@ * later. See the COPYING file in the top-level directory. */ =20 -#include "qemu/osdep.h" - #include "libvhost-user-glib.h" =20 +#ifndef container_of +#define container_of(ptr, type, member) \ + __extension__({ \ + void *__mptr =3D (void *)(ptr); \ + ((type *)(__mptr - offsetof(type, member))); \ + }) +#endif + /* glib event loop integration for libvhost-user and misc callbacks */ =20 G_STATIC_ASSERT((int)G_IO_IN =3D=3D (int)VU_WATCH_IN); --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606298974; cv=none; d=zohomail.com; s=zohoarc; b=Jf0pIdjLY+LwzfDHhVcPYd5jPmyMO9HQU7u26oQNUDuOH2S1PvRvHeKVz5ablHcMCnt7sITwvRiJJpOoorecHOsTJsOi+kHp7mN0LM6iHMNEv5u6sok0xAl580rfCtQsi6ZQ/1T1KBGICtsS4u/EVBNB81FkLJcxljS+gNGdAQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606298974; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h1PMhDLpdZmGcu8jrP3o/BiP8fsmPEU1l5yc8ZBG95Y=; b=T5796iP2n2GCTf8YDK7HAmaiR+CL84T76Byp5uw/507dWEr/dL0qqQiWHescROivxl/tcIhr4vEo7VWntqPzfMYetu0WX5c+LHiZtdvV8MqRGgaV4A+ZWGLIZZrM7q4yUgMctU7rj3EbxJnzeX90GqeHUp0SDlP2BlWfbByCyoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606298974329184.52503969937857; Wed, 25 Nov 2020 02:09:34 -0800 (PST) Received: from localhost ([::1]:49402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrjx-00007i-JE for importer@patchew.org; Wed, 25 Nov 2020 05:09:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khrig-0006s0-Lu for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrid-0003FT-O6 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-569-ZM15GZV6OQC14P9tAiXjFg-1; Wed, 25 Nov 2020 05:08:08 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A2681005D44 for ; Wed, 25 Nov 2020 10:08:08 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4297E60855; Wed, 25 Nov 2020 10:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h1PMhDLpdZmGcu8jrP3o/BiP8fsmPEU1l5yc8ZBG95Y=; b=ZbI3T8QcGhgRoKC92GaoA05WCx1UbNgZSo5+q219LkGwbM9DeRS89k/Zo+8ocyel7HPmTt LZ8YVQHdozGwkGdSqxdCERqvIygAkbox6hUBLaDYavDJfdOkfHJ4tkh5rHb+TzTyDPY4gs enXuR2rLdDlrj8zWhOvi8mHlT1FlheQ= X-MC-Unique: ZM15GZV6OQC14P9tAiXjFg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 5/8] libvhost-user: make it a meson subproject Date: Wed, 25 Nov 2020 14:06:37 +0400 Message-Id: <20201125100640.366523-6-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau By making libvhost-user a subproject, check it builds standalone (without the global QEMU cflags etc). Note that the library still relies on QEMU include/qemu/atomic.h and linux_headers/. Signed-off-by: Marc-Andr=C3=A9 Lureau --- meson.build | 7 ++++++- contrib/vhost-user-gpu/vugpu.h | 2 +- include/qemu/vhost-user-server.h | 2 +- .../libvhost-user/libvhost-user-glib.h | 0 .../libvhost-user/libvhost-user.h | 0 block/export/vhost-user-blk-server.c | 2 +- contrib/vhost-user-blk/vhost-user-blk.c | 3 +-- contrib/vhost-user-input/main.c | 3 +-- contrib/vhost-user-scsi/vhost-user-scsi.c | 2 +- .../libvhost-user/libvhost-user-glib.c | 0 .../libvhost-user/libvhost-user.c | 0 tests/vhost-user-bridge.c | 2 +- tools/virtiofsd/fuse_virtio.c | 2 +- contrib/libvhost-user/meson.build | 4 ---- contrib/vhost-user-blk/meson.build | 3 +-- contrib/vhost-user-gpu/meson.build | 3 +-- contrib/vhost-user-input/meson.build | 3 +-- contrib/vhost-user-scsi/meson.build | 3 +-- subprojects/libvhost-user/meson.build | 20 +++++++++++++++++++ tests/meson.build | 3 +-- tools/virtiofsd/meson.build | 3 +-- 21 files changed, 40 insertions(+), 27 deletions(-) rename {contrib =3D> subprojects}/libvhost-user/libvhost-user-glib.h (100%) rename {contrib =3D> subprojects}/libvhost-user/libvhost-user.h (100%) rename {contrib =3D> subprojects}/libvhost-user/libvhost-user-glib.c (100%) rename {contrib =3D> subprojects}/libvhost-user/libvhost-user.c (100%) delete mode 100644 contrib/libvhost-user/meson.build create mode 100644 subprojects/libvhost-user/meson.build diff --git a/meson.build b/meson.build index 5062407c70..1b14998691 100644 --- a/meson.build +++ b/meson.build @@ -1476,7 +1476,12 @@ trace_events_subdirs +=3D [ 'util', ] =20 -subdir('contrib/libvhost-user') +vhost_user =3D not_found +if 'CONFIG_VHOST_USER' in config_host + libvhost_user =3D subproject('libvhost-user') + vhost_user =3D libvhost_user.get_variable('vhost_user_dep') +endif + subdir('qapi') subdir('qobject') subdir('stubs') diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h index 3153c9a6de..bdf9a74b46 100644 --- a/contrib/vhost-user-gpu/vugpu.h +++ b/contrib/vhost-user-gpu/vugpu.h @@ -17,7 +17,7 @@ =20 #include "qemu/osdep.h" =20 -#include "contrib/libvhost-user/libvhost-user-glib.h" +#include "libvhost-user-glib.h" #include "standard-headers/linux/virtio_gpu.h" =20 #include "qemu/queue.h" diff --git a/include/qemu/vhost-user-server.h b/include/qemu/vhost-user-ser= ver.h index 0da4c2cc4c..121ea1dedf 100644 --- a/include/qemu/vhost-user-server.h +++ b/include/qemu/vhost-user-server.h @@ -11,7 +11,7 @@ #ifndef VHOST_USER_SERVER_H #define VHOST_USER_SERVER_H =20 -#include "contrib/libvhost-user/libvhost-user.h" +#include "subprojects/libvhost-user/libvhost-user.h" /* only for the type = definitions */ #include "io/channel-socket.h" #include "io/channel-file.h" #include "io/net-listener.h" diff --git a/contrib/libvhost-user/libvhost-user-glib.h b/subprojects/libvh= ost-user/libvhost-user-glib.h similarity index 100% rename from contrib/libvhost-user/libvhost-user-glib.h rename to subprojects/libvhost-user/libvhost-user-glib.h diff --git a/contrib/libvhost-user/libvhost-user.h b/subprojects/libvhost-u= ser/libvhost-user.h similarity index 100% rename from contrib/libvhost-user/libvhost-user.h rename to subprojects/libvhost-user/libvhost-user.h diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user= -blk-server.c index 62672d1cb9..a3d95ca012 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" #include "block/block.h" -#include "contrib/libvhost-user/libvhost-user.h" +#include "subprojects/libvhost-user/libvhost-user.h" /* only for the type = definitions */ #include "standard-headers/linux/virtio_blk.h" #include "qemu/vhost-user-server.h" #include "vhost-user-blk-server.h" diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-b= lk/vhost-user-blk.c index dc981bf945..6abd7835a8 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -17,8 +17,7 @@ =20 #include "qemu/osdep.h" #include "standard-headers/linux/virtio_blk.h" -#include "contrib/libvhost-user/libvhost-user-glib.h" -#include "contrib/libvhost-user/libvhost-user.h" +#include "libvhost-user-glib.h" =20 #if defined(__linux__) #include diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/mai= n.c index 6020c6f33a..3ea840cf44 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -12,8 +12,7 @@ #include "qemu/iov.h" #include "qemu/bswap.h" #include "qemu/sockets.h" -#include "contrib/libvhost-user/libvhost-user.h" -#include "contrib/libvhost-user/libvhost-user-glib.h" +#include "libvhost-user-glib.h" #include "standard-headers/linux/virtio_input.h" #include "qapi/error.h" =20 diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user= -scsi/vhost-user-scsi.c index 0f9ba4b2a2..306434df70 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -15,7 +15,7 @@ #define inline __attribute__((gnu_inline)) /* required for libiscsi v1.9.= 0 */ #include #undef inline -#include "contrib/libvhost-user/libvhost-user-glib.h" +#include "libvhost-user-glib.h" #include "standard-headers/linux/virtio_scsi.h" =20 =20 diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/subprojects/libvh= ost-user/libvhost-user-glib.c similarity index 100% rename from contrib/libvhost-user/libvhost-user-glib.c rename to subprojects/libvhost-user/libvhost-user-glib.c diff --git a/contrib/libvhost-user/libvhost-user.c b/subprojects/libvhost-u= ser/libvhost-user.c similarity index 100% rename from contrib/libvhost-user/libvhost-user.c rename to subprojects/libvhost-user/libvhost-user.c diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index bd43607a4d..24815920b2 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -34,7 +34,7 @@ #include "qemu/ctype.h" #include "qemu/iov.h" #include "standard-headers/linux/virtio_net.h" -#include "contrib/libvhost-user/libvhost-user.h" +#include "libvhost-user.h" =20 #define VHOST_USER_BRIDGE_DEBUG 1 =20 diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 83ba07c6cd..623812c432 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -35,7 +35,7 @@ #include #include =20 -#include "contrib/libvhost-user/libvhost-user.h" +#include "libvhost-user.h" =20 struct fv_VuDev; struct fv_QueueInfo { diff --git a/contrib/libvhost-user/meson.build b/contrib/libvhost-user/meso= n.build deleted file mode 100644 index a261e7665f..0000000000 --- a/contrib/libvhost-user/meson.build +++ /dev/null @@ -1,4 +0,0 @@ -libvhost_user =3D static_library('vhost-user', - files('libvhost-user.c', 'libvhost-user-gli= b.c'), - build_by_default: false) -vhost_user =3D declare_dependency(link_with: libvhost_user) diff --git a/contrib/vhost-user-blk/meson.build b/contrib/vhost-user-blk/me= son.build index 5db8cc3fe2..601ea15ef5 100644 --- a/contrib/vhost-user-blk/meson.build +++ b/contrib/vhost-user-blk/meson.build @@ -1,6 +1,5 @@ # FIXME: broken on 32-bit architectures executable('vhost-user-blk', files('vhost-user-blk.c'), - link_with: libvhost_user, - dependencies: qemuutil, + dependencies: [qemuutil, vhost_user], build_by_default: false, install: false) diff --git a/contrib/vhost-user-gpu/meson.build b/contrib/vhost-user-gpu/me= son.build index c487ca72c1..2fc2320b52 100644 --- a/contrib/vhost-user-gpu/meson.build +++ b/contrib/vhost-user-gpu/meson.build @@ -2,8 +2,7 @@ if 'CONFIG_TOOLS' in config_host and 'CONFIG_VIRGL' in conf= ig_host \ and 'CONFIG_GBM' in config_host and 'CONFIG_LINUX' in config_host \ and pixman.found() executable('vhost-user-gpu', files('vhost-user-gpu.c', 'virgl.c', 'vugbm= .c'), - link_with: libvhost_user, - dependencies: [qemuutil, pixman, gbm, virgl], + dependencies: [qemuutil, pixman, gbm, virgl, vhost_user], install: true, install_dir: get_option('libexecdir')) =20 diff --git a/contrib/vhost-user-input/meson.build b/contrib/vhost-user-inpu= t/meson.build index 1eeb1329d9..21a9ed4f15 100644 --- a/contrib/vhost-user-input/meson.build +++ b/contrib/vhost-user-input/meson.build @@ -1,5 +1,4 @@ executable('vhost-user-input', files('main.c'), - link_with: libvhost_user, - dependencies: qemuutil, + dependencies: [qemuutil, vhost_user], build_by_default: targetos =3D=3D 'linux', install: false) diff --git a/contrib/vhost-user-scsi/meson.build b/contrib/vhost-user-scsi/= meson.build index 257cbffc8e..044c50bf43 100644 --- a/contrib/vhost-user-scsi/meson.build +++ b/contrib/vhost-user-scsi/meson.build @@ -1,7 +1,6 @@ if 'CONFIG_LIBISCSI' in config_host executable('vhost-user-scsi', files('vhost-user-scsi.c'), - link_with: libvhost_user, - dependencies: [qemuutil, libiscsi], + dependencies: [qemuutil, libiscsi, vhost_user], build_by_default: targetos =3D=3D 'linux', install: false) endif diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-u= ser/meson.build new file mode 100644 index 0000000000..f9ecc534cf --- /dev/null +++ b/subprojects/libvhost-user/meson.build @@ -0,0 +1,20 @@ +project('libvhost-user', 'c', + license: 'GPL-2.0-or-later', + default_options: ['c_std=3Dgnu99']) + +glib =3D dependency('glib-2.0') +inc =3D include_directories('../../include', '../../linux-headers') + +vhost_user =3D static_library('vhost-user', + files('libvhost-user.c'), + include_directories: inc, + c_args: '-D_GNU_SOURCE') + +vhost_user_glib =3D static_library('vhost-user-glib', + files('libvhost-user-glib.c'), + include_directories: inc, + link_with: vhost_user, + dependencies: glib) + +vhost_user_dep =3D declare_dependency(link_with: vhost_user_glib, + include_directories: include_directori= es('.')) diff --git a/tests/meson.build b/tests/meson.build index afeb6be689..1fa068f27b 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -264,8 +264,7 @@ endforeach if have_tools and 'CONFIG_VHOST_USER' in config_host and 'CONFIG_LINUX' in= config_host executable('vhost-user-bridge', sources: files('vhost-user-bridge.c'), - link_with: [libvhost_user], - dependencies: [qemuutil]) + dependencies: [qemuutil, vhost_user]) endif =20 if have_system and 'CONFIG_POSIX' in config_host diff --git a/tools/virtiofsd/meson.build b/tools/virtiofsd/meson.build index 17edecf55c..c134ba633f 100644 --- a/tools/virtiofsd/meson.build +++ b/tools/virtiofsd/meson.build @@ -8,8 +8,7 @@ executable('virtiofsd', files( 'helper.c', 'passthrough_ll.c', 'passthrough_seccomp.c'), - link_with: libvhost_user, - dependencies: [seccomp, qemuutil, libcap_ng], + dependencies: [seccomp, qemuutil, libcap_ng, vhost_user], install: true, install_dir: get_option('libexecdir')) =20 --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606299106; cv=none; d=zohomail.com; s=zohoarc; b=PUitBPR2JQOLXEVlkbaq5r610wbTf6b+l3x1FEI9Df+wvGz0tv+FPJvaQ4Dd5Tqtvfvc8w2D7RIa1RO5PyaD132nSjGa06nPcL0MsEvITu8wO48lrjK7pO7zGghL8iR+DFLYEr0OmeN279qG3rWFcgrEbyZlFJEnHOmBO7XF3lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606299106; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=k6VQ6/DfUhWSynwws5TGz3r8SvlBgX0wp8f5Keo//KQ=; b=U9bm7ENMYY30PBHNSF9XFLaLQZc8ERpBUYIPj2WlV4k/+ug1JK4zzugAgbBKl4YIgs4ORd1KZ3iM5mOQrdvecvkFiVdaBUa0EDVOwN7PRej+SbszS816SCHw0L/tToaq1U3VpQq/Mg5ALyLX30Pu7t7RPgoQG6FUvU0B2yDRZoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606299106196469.1826691146624; Wed, 25 Nov 2020 02:11:46 -0800 (PST) Received: from localhost ([::1]:57888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrm5-0003cC-Gb for importer@patchew.org; Wed, 25 Nov 2020 05:11:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khriu-0007MZ-PV for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrit-0003LA-3d for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-yFD87WaNPTC1Gh1Rh6i1Ug-1; Wed, 25 Nov 2020 05:08:24 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 699001005D51 for ; Wed, 25 Nov 2020 10:08:23 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3026C5C1B4; Wed, 25 Nov 2020 10:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k6VQ6/DfUhWSynwws5TGz3r8SvlBgX0wp8f5Keo//KQ=; b=Bf6zg8ZyLzqOfBQFbWDVfE4qfUOmXz4bmSTnyNLk5xP14kETysvGB0Md8A+N0qALAzE0tZ kn9/LmyVaUf0G+j7fICTYY5JmKXlu8M3j3jiAdX9Dth//y5QCv8pbFEJjQ09MQChxHLcYx +acZFvkJMc1fm2SDd0KeRuS5z57C/dk= X-MC-Unique: yFD87WaNPTC1Gh1Rh6i1Ug-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] libvhost-user: check memfd API Date: Wed, 25 Nov 2020 14:06:38 +0400 Message-Id: <20201125100640.366523-7-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Do not compile potentially panicking code, instead check memfd API is present during configure time. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- subprojects/libvhost-user/libvhost-user.c | 6 ------ subprojects/libvhost-user/meson.build | 12 ++++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index fab7ca17ee..09741a7b49 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1616,7 +1616,6 @@ vu_inflight_queue_size(uint16_t queue_size) sizeof(uint16_t), INFLIGHT_ALIGNMENT); } =20 -#ifdef MFD_ALLOW_SEALING static void * memfd_alloc(const char *name, size_t size, unsigned int flags, int *fd) { @@ -1648,7 +1647,6 @@ memfd_alloc(const char *name, size_t size, unsigned i= nt flags, int *fd) =20 return ptr; } -#endif =20 static bool vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg) @@ -1672,13 +1670,9 @@ vu_get_inflight_fd(VuDev *dev, VhostUserMsg *vmsg) =20 mmap_size =3D vu_inflight_queue_size(queue_size) * num_queues; =20 -#ifdef MFD_ALLOW_SEALING addr =3D memfd_alloc("vhost-inflight", mmap_size, F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL, &fd); -#else - vu_panic(dev, "Not implemented: memfd support is missing"); -#endif =20 if (!addr) { vu_panic(dev, "Failed to alloc vhost inflight area"); diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-u= ser/meson.build index f9ecc534cf..ac228b5ba6 100644 --- a/subprojects/libvhost-user/meson.build +++ b/subprojects/libvhost-user/meson.build @@ -2,7 +2,19 @@ project('libvhost-user', 'c', license: 'GPL-2.0-or-later', default_options: ['c_std=3Dgnu99']) =20 +cc =3D meson.get_compiler('c') + glib =3D dependency('glib-2.0') +foreach h, syms: { + 'sys/mman.h': ['memfd_create', 'MFD_ALLOW_SEALING'], + 'sys/fcntl.h': ['F_SEAL_GROW', 'F_SEAL_SHRINK', 'F_SEAL_SEAL'] } + foreach sym: syms + cc.has_header_symbol(h, sym, + args: ['-D_GNU_SOURCE'], + required: true) + endforeach +endforeach + inc =3D include_directories('../../include', '../../linux-headers') =20 vhost_user =3D static_library('vhost-user', --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606300063; cv=none; d=zohomail.com; s=zohoarc; b=B+lKVBvBqWCx07t7P3SnilnIbZbOd46bBQ9Db9dNfeoxY9x26gr72QjPlJIg34Qu7R3WG9tD9T7URLSXeEUCWg0TdVWhfRCgFxw2t8GhVI7x/Mvjsb0QgoocPfiEkxGjVYiqkB+vwq6z6wBBcJYv7hvICTy2FKRivOM/Xav2lCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606300063; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1WInulEBNYJrSEae5i+nZvQ2xAyWD7JOEfJhEKhriP0=; b=YeobaByyz4ihC+KGxh+3yCs7AmGpmxW3pqj8r2N8/JbVMhCQXgVt0+RUcGdjyXBg4zkDhbdidsqpNG6D36v+I3GUtNRT4VQAR8seUHEijop8/fXsT9chzrQqoPchDlrjnBxxyoE9YaY/MmiWj7SpIZSEv7OG1DyoI2kAfNsCmt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606300063513332.9732761399147; Wed, 25 Nov 2020 02:27:43 -0800 (PST) Received: from localhost ([::1]:43150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khs1V-0001Ko-S7 for importer@patchew.org; Wed, 25 Nov 2020 05:27:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khrj9-0007kI-W1 for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrj8-0003PJ-8I for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-jbOmF7MHNNm4O_OsVV-QIw-1; Wed, 25 Nov 2020 05:08:38 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82DE41005E46 for ; Wed, 25 Nov 2020 10:08:37 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91F9619C78; Wed, 25 Nov 2020 10:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1WInulEBNYJrSEae5i+nZvQ2xAyWD7JOEfJhEKhriP0=; b=UVPR9u2ycv4SnOqhWnYjgoVIpGffpiLVYg/gCDNf4uLHMGLr6uof01gIOtLJjoFwgp3wJD 5x94dWUcNTlB+JrNHSObN23X3zPkx59U6f8CBjBikK+ZaphNtKwVjnNC5eakzhCIfNXtGh tSgOEFpv87307dISbNdEDgV51suyIuc= X-MC-Unique: jbOmF7MHNNm4O_OsVV-QIw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 7/8] libvhost-user: add a simple link test without glib Date: Wed, 25 Nov 2020 14:06:39 +0400 Message-Id: <20201125100640.366523-8-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- subprojects/libvhost-user/link-test.c | 45 +++++++++++++++++++++++++++ subprojects/libvhost-user/meson.build | 4 +++ 2 files changed, 49 insertions(+) create mode 100644 subprojects/libvhost-user/link-test.c diff --git a/subprojects/libvhost-user/link-test.c b/subprojects/libvhost-u= ser/link-test.c new file mode 100644 index 0000000000..e01d6eb1fa --- /dev/null +++ b/subprojects/libvhost-user/link-test.c @@ -0,0 +1,45 @@ +/* + * A trivial unit test to check linking without glib. A real test suite sh= ould + * probably based off libvhost-user-glib instead. + */ +#include +#include +#include "libvhost-user.h" + +static void +panic(VuDev *dev, const char *err) +{ + abort(); +} + +static void +set_watch(VuDev *dev, int fd, int condition, + vu_watch_cb cb, void *data) +{ + abort(); +} + +static void +remove_watch(VuDev *dev, int fd) +{ + abort(); +} + +static const VuDevIface iface =3D { + 0, +}; + +int +main(int argc, const char *argv[]) +{ + bool rc; + uint16_t max_queues =3D 2; + int socket =3D 0; + VuDev dev =3D { 0, }; + + rc =3D vu_init(&dev, max_queues, socket, panic, NULL, set_watch, remov= e_watch, &iface); + assert(rc =3D=3D true); + vu_deinit(&dev); + + return 0; +} diff --git a/subprojects/libvhost-user/meson.build b/subprojects/libvhost-u= ser/meson.build index ac228b5ba6..76e83c0cec 100644 --- a/subprojects/libvhost-user/meson.build +++ b/subprojects/libvhost-user/meson.build @@ -22,6 +22,10 @@ vhost_user =3D static_library('vhost-user', include_directories: inc, c_args: '-D_GNU_SOURCE') =20 +executable('link-test', files('link-test.c'), + link_whole: vhost_user, + include_directories: inc) + vhost_user_glib =3D static_library('vhost-user-glib', files('libvhost-user-glib.c'), include_directories: inc, --=20 2.29.0 From nobody Thu May 2 01:48:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606299057; cv=none; d=zohomail.com; s=zohoarc; b=EaZqS+/wFNg8kVvV27T8r3Yevhs7WLGFohUGwOiUum0sYKtGlfUzEkHmCJ01k00E9Wl3v0PsJFta4JOe3Oi6vOkLNBv2rx/16wyqa3VEvoAHtw0jp5Mr0btG//75VIpHF0lIN/P0/CqG1dU/btKQoDU9waqgU4sWtfR4go0KTHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606299057; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=al6H++3zUEjGIG8qVSO39K/S1Yku6SF0SEQjSENo0I4=; b=ZxFI0KewwD8FAVQhOfwIwAjDYvm8lt8lQ03RSXwyBp6B7z5ot1vZT/6YL2NRRarJ+6CS7HLDzURr1yge6pHJ9UbyYTKAbLkuCK3UI+GUAnXIcLh1QKhRY4UB3c0HlhSvFcgHAkd0GZh+MUBbYGDgztard01PexjH4qXDB3kar1A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606299057600163.89201317989398; Wed, 25 Nov 2020 02:10:57 -0800 (PST) Received: from localhost ([::1]:54458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khrlI-00029R-PC for importer@patchew.org; Wed, 25 Nov 2020 05:10:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khrjM-00080a-EP for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khrjK-0003TV-Oz for qemu-devel@nongnu.org; Wed, 25 Nov 2020 05:08:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-aaN3gar7NMO8xIKBaZZm4w-1; Wed, 25 Nov 2020 05:08:52 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1111803F4B for ; Wed, 25 Nov 2020 10:08:51 +0000 (UTC) Received: from localhost (unknown [10.36.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id D488F4D; Wed, 25 Nov 2020 10:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606298934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=al6H++3zUEjGIG8qVSO39K/S1Yku6SF0SEQjSENo0I4=; b=d0dgaCkkAfP9kNUlqQJ3sU9clebNVHVEz75X8MhkItB7aY6tL96Vh3c3w0yONWYrPXiNCG bw4aIGnWkExiqkU9gyXW5LHExmzsGZROPWZFiiH/ORXn4AdQM5y3BltM9pV+1Dw3GnGt7S YFnzqzdrpAQlT3jiITjbKi4B64srROg= X-MC-Unique: aaN3gar7NMO8xIKBaZZm4w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PATCH v2 8/8] .gitlab-ci: add build-libvhost-user Date: Wed, 25 Nov 2020 14:06:40 +0400 Message-Id: <20201125100640.366523-9-marcandre.lureau@redhat.com> In-Reply-To: <20201125100640.366523-1-marcandre.lureau@redhat.com> References: <20201125100640.366523-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=216.205.24.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?= , "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Hajnoczi --- .gitlab-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0173e82b1..e517506c35 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -455,6 +455,17 @@ check-dco: variables: GIT_DEPTH: 1000 =20 +build-libvhost-user: + stage: build + image: $CI_REGISTRY_IMAGE/qemu/fedora:latest + before_script: + - dnf install -y meson ninja-build + script: + - mkdir subprojects/libvhost-user/build + - cd subprojects/libvhost-user/build + - meson + - ninja + pages: image: $CI_REGISTRY_IMAGE/qemu/ubuntu2004:latest stage: test --=20 2.29.0