From patchwork Fri Oct 9 15:17:24 2015 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: 528484 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 69B98140E43 for ; Sat, 10 Oct 2015 12:46:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=zCreKmFa; dkim-atps=neutral Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkjEj-0005Fw-F9 for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 21:46:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkbmY-0007Hc-TY for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 13:48:38 -0400 Received: from localhost ([::1]:40362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkbSE-0000yL-Qz for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 13:27:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZR8-0001u6-Px for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkZR5-0007uG-J3 for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:22 -0400 Received: from mail-qg0-x22c.google.com ([2607:f8b0:400d:c04::22c]:33845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZR5-0007uC-FE for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:19 -0400 Received: by qgez77 with SMTP id z77so71526281qge.1 for ; Fri, 09 Oct 2015 08:18:19 -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-type:content-transfer-encoding; bh=blO+gSn4R/685DXAM9M6BibW4vmgJ/S0Yk49eLXpiAc=; b=zCreKmFa6/sBa38Eia+gDnVyVv+232ykVOMLBGEZqBWuUDVuv4atNdscUig8gjkcwt 2zWJQD5z+iyXamWcTqQ5ZijjRFlGdEj43UlqbGNsk6zngnuIyX1YMXjAn6pK6mR7B+N1 c4nC+P0uCMY4iLm2tU/lFlaOxARzAy5/yKYziXxJjSOKHm3QbUssM9xetG6ckyVjHyDu KQVSc5Qqh0/ahGgDLa77J418LaRjSpMVzLPlB4wDdJumacXOfifTdPQJMn65pRMmfIXw QPrUIlpQA/61ymFNYD7IOIU5MfJg20AqvaSrokkSzofgsWY+zvAIfEEqlhad419ldhO7 S7uw== X-Received: by 10.140.96.84 with SMTP id j78mr15920375qge.94.1444403899073; Fri, 09 Oct 2015 08:18:19 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id g77sm837174qgd.5.2015.10.09.08.18.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2015 08:18:18 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 9 Oct 2015 17:17:24 +0200 Message-Id: <1444403861-3240-11-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444403861-3240-1-git-send-email-marcandre.lureau@redhat.com> References: <1444403861-3240-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). Cc: haifeng.lin@huawei.com, mst@redhat.com, thibaut.collet@6wind.com, jasowang@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH v8 10/27] vhost-user: add vhost_user_requires_shm_log() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 From: Marc-André Lureau Check if the backend has VHOST_USER_PROTOCOL_F_LOG_SHMFD feature and require a shared log. Signed-off-by: Marc-André Lureau --- hw/virtio/vhost-user.c | 14 ++++++++++++-- include/hw/virtio/vhost-backend.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index fd4fcbf..01e51a0 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -25,9 +25,10 @@ #define VHOST_MEMORY_MAX_NREGIONS 8 #define VHOST_USER_F_PROTOCOL_FEATURES 30 -#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x1ULL -#define VHOST_USER_PROTOCOL_F_MQ 0 +#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x3ULL +#define VHOST_USER_PROTOCOL_F_MQ 0 +#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 typedef enum VhostUserRequest { VHOST_USER_NONE = 0, @@ -453,6 +454,14 @@ static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx) return idx; } +static bool vhost_user_requires_shm_log(struct vhost_dev *dev) +{ + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); + + return virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_LOG_SHMFD); +} + const VhostOps user_ops = { .backend_type = VHOST_BACKEND_TYPE_USER, .vhost_call = vhost_user_call, @@ -462,4 +471,5 @@ const VhostOps user_ops = { .vhost_backend_set_vring_enable = vhost_user_set_vring_enable, .vhost_set_log_base = vhost_set_log_base, + .vhost_requires_shm_log = vhost_user_requires_shm_log, }; diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index c6b688a..649766a 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -11,6 +11,8 @@ #ifndef VHOST_BACKEND_H_ #define VHOST_BACKEND_H_ +#include + typedef enum VhostBackendType { VHOST_BACKEND_TYPE_NONE = 0, VHOST_BACKEND_TYPE_KERNEL = 1, @@ -28,6 +30,7 @@ typedef int (*vhost_backend_get_vq_index)(struct vhost_dev *dev, int idx); typedef int (*vhost_backend_set_vring_enable)(struct vhost_dev *dev, int enable); typedef int (*vhost_set_log_base_op)(struct vhost_dev *dev, uint64_t base); +typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); typedef struct VhostOps { VhostBackendType backend_type; @@ -39,6 +42,7 @@ typedef struct VhostOps { vhost_backend_set_vring_enable vhost_backend_set_vring_enable; vhost_set_log_base_op vhost_set_log_base; + vhost_requires_shm_log_op vhost_requires_shm_log; } VhostOps; extern const VhostOps user_ops;