From patchwork Tue May 27 12:03:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Nikolaev X-Patchwork-Id: 352884 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 8B364140098 for ; Tue, 27 May 2014 22:04:26 +1000 (EST) Received: from localhost ([::1]:33808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpG7E-0003hO-Cp for incoming@patchwork.ozlabs.org; Tue, 27 May 2014 08:04:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpG6g-0002s6-HE for qemu-devel@nongnu.org; Tue, 27 May 2014 08:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpG6a-00072Q-Aj for qemu-devel@nongnu.org; Tue, 27 May 2014 08:03:50 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:52940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpG6a-00072M-4C for qemu-devel@nongnu.org; Tue, 27 May 2014 08:03:44 -0400 Received: by mail-wi0-f181.google.com with SMTP id n15so1573526wiw.2 for ; Tue, 27 May 2014 05:03:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=qlLfKszRPCIFDCD/dlEBIZMy935MZ7a6peHWUcruMW0=; b=CbFeLWg8ct474lgXtj3HktARy16lqThIZFJoWtvjqJKYSDXcejtcwKEz7e7kl64KHj I6Df77Nn/hA2XgqfTio/VuNx6QE9BhBwbCUENdaXYDYLI12gnAeUqUqxkpk+HChPQzdU X2v9ApxRnnZqz3zE/qYWm5LFWYpbAJBweDH4HPuZ1ZLDVf66irkzAUn88TKeKVbZIxZl QHvHT2Zb35FzsKKyIsVQ1h7gm+EWmLLOguA+1g5bBuCMilXHvLHQiAW9kNroxbJxBdUa 6eWtQkRzR18GrcyZcxsuHZMjeEzGV5aV+sPv93Qz2oiTMXCMDxuybVG4UqEBhU2Y01qW QeBw== X-Gm-Message-State: ALoCoQnONYagJPe22oqSyGAFqFpQ1XxNDNlSmImoc6v/iuqhNf9KDyHMBxpkKlOMBpkM5PlvuEoR X-Received: by 10.180.107.130 with SMTP id hc2mr24612962wib.7.1401192222725; Tue, 27 May 2014 05:03:42 -0700 (PDT) Received: from [0.0.14.236] ([82.146.27.14]) by mx.google.com with ESMTPSA id gp15sm34545487wjc.10.2014.05.27.05.03.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 May 2014 05:03:42 -0700 (PDT) From: Nikolay Nikolaev To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org Date: Tue, 27 May 2014 15:03:35 +0300 Message-ID: <20140527120330.15172.91211.stgit@3820> In-Reply-To: <20140527120050.15172.94908.stgit@3820> References: <20140527120050.15172.94908.stgit@3820> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.181 Cc: a.motakis@virtualopensystems.com, luke@snabb.co, tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v10 01/18] Add kvm_eventfds_enabled function 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 Add a function to check if the eventfd capability is present in KVM in the host kernel. Signed-off-by: Antonios Motakis Signed-off-by: Nikolay Nikolaev Acked-by: Paolo Bonzini --- include/sysemu/kvm.h | 11 +++++++++++ kvm-all.c | 4 ++++ kvm-stub.c | 1 + 3 files changed, 16 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index e7ad9d1..1c7f5f6 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -43,6 +43,7 @@ extern bool kvm_allowed; extern bool kvm_kernel_irqchip; extern bool kvm_async_interrupts_allowed; extern bool kvm_halt_in_kernel_allowed; +extern bool kvm_eventfds_allowed; extern bool kvm_irqfds_allowed; extern bool kvm_msi_via_irqfd_allowed; extern bool kvm_gsi_routing_allowed; @@ -83,6 +84,15 @@ extern bool kvm_readonly_mem_allowed; #define kvm_halt_in_kernel() (kvm_halt_in_kernel_allowed) /** + * kvm_eventfds_enabled: + * + * Returns: true if we can use eventfds to receive notifications + * from a KVM CPU (ie the kernel supports eventds and we are running + * with a configuration where it is meaningful to use them). + */ +#define kvm_eventfds_enabled() (kvm_eventfds_allowed) + +/** * kvm_irqfds_enabled: * * Returns: true if we can use irqfds to inject interrupts into @@ -128,6 +138,7 @@ extern bool kvm_readonly_mem_allowed; #define kvm_irqchip_in_kernel() (false) #define kvm_async_interrupts_enabled() (false) #define kvm_halt_in_kernel() (false) +#define kvm_eventfds_enabled() (false) #define kvm_irqfds_enabled() (false) #define kvm_msi_via_irqfd_enabled() (false) #define kvm_gsi_routing_allowed() (false) diff --git a/kvm-all.c b/kvm-all.c index a343ede..9649cd3 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -112,6 +112,7 @@ KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; bool kvm_halt_in_kernel_allowed; +bool kvm_eventfds_allowed; bool kvm_irqfds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; @@ -1504,6 +1505,9 @@ int kvm_init(MachineClass *mc) (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0); #endif + kvm_eventfds_allowed = + (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0); + ret = kvm_arch_init(s); if (ret < 0) { goto err; diff --git a/kvm-stub.c b/kvm-stub.c index 8acda86..3fb17f2 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -22,6 +22,7 @@ KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; +bool kvm_eventfds_allowed; bool kvm_irqfds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed;