From patchwork Tue Sep 29 16:34:39 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: 524568 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E8797140D6E for ; Thu, 1 Oct 2015 06:48:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=XibB1Jlf; dkim-atps=neutral Received: from localhost ([::1]:32969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhOIs-0002V9-Iy for incoming@patchwork.ozlabs.org; Wed, 30 Sep 2015 16:48:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgxsJ-0002Db-30 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgxsE-0003uP-UQ for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:35:30 -0400 Received: from mail-qk0-x231.google.com ([2607:f8b0:400d:c09::231]:35322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgxsE-0003uJ-QK for qemu-devel@nongnu.org; Tue, 29 Sep 2015 12:35:26 -0400 Received: by qkap81 with SMTP id p81so5570901qka.2 for ; Tue, 29 Sep 2015 09:35:26 -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=XibB1JlfrlwEB4z2Wk4EoK/Kdtmou2TVwitf9YIWTzdsuSY8z23ZyUprTz6vIf0GKy rYiisSXHE0M0Di0jx6tTnf68ecGDkh/FEq2fZ9S3rVPRGXQkSCDdhwZ8xm3swQpnPcds KrJyZ5zDOBton1Ue8MEmLrubsK8y25ZA98g8LV+nOmt79JYcsE9G6JFEQi+HjNY64sJQ CdDYYBy9bJ4gXYR0q1N8IMG2n/ON8g4uDvREfhXhhAk+HzSsR4DnNYKgAGzW6IpNGLxu aCH3N3ddq8HYd44suZHwCb/Gw2XBjDkR0PXHr/plf9xX7KVaLmpLWWZJtA/mHjYO31gM tHGg== X-Received: by 10.55.15.3 with SMTP id z3mr30005652qkg.29.1443544526524; Tue, 29 Sep 2015 09:35:26 -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 t48sm9611793qgd.15.2015.09.29.09.35.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Sep 2015 09:35:25 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2015 18:34:39 +0200 Message-Id: <1443544494-28737-10-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443544494-28737-1-git-send-email-marcandre.lureau@redhat.com> References: <1443544494-28737-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). X-Received-From: 2607:f8b0:400d:c09::231 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 v6 09/24] 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 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;