From patchwork Fri Dec 26 08:05:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 5542421 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 356189F2E2 for ; Fri, 26 Dec 2014 08:08:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68A2E20154 for ; Fri, 26 Dec 2014 08:08:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 838F820034 for ; Fri, 26 Dec 2014 08:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751404AbaLZIIQ (ORCPT ); Fri, 26 Dec 2014 03:08:16 -0500 Received: from mga02.intel.com ([134.134.136.20]:20926 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbaLZIIP (ORCPT ); Fri, 26 Dec 2014 03:08:15 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 26 Dec 2014 00:08:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="433582968" Received: from tchen0-linux.bj.intel.com ([10.238.135.72]) by FMSMGA003.fm.intel.com with ESMTP; 25 Dec 2014 23:56:32 -0800 From: Tiejun Chen To: pbonzini@redhat.com Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-trivial@nongnu.org Subject: [PATCH] kvm_irqchip_assign_irqfd: just set irqfd in case of kvm_irqfds_enabled() Date: Fri, 26 Dec 2014 16:05:26 +0800 Message-Id: <1419581126-12927-1-git-send-email-tiejun.chen@intel.com> X-Mailer: git-send-email 1.9.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should avoid to set irqfd{} unconditionally. Signed-off-by: Tiejun Chen --- kvm-all.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 18cc6b4..5b9786b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1257,21 +1257,21 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg) static int kvm_irqchip_assign_irqfd(KVMState *s, int fd, int rfd, int virq, bool assign) { - struct kvm_irqfd irqfd = { - .fd = fd, - .gsi = virq, - .flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN, - }; + struct kvm_irqfd irqfd = {}; + + if (!kvm_irqfds_enabled()) { + return -ENOSYS; + } + + irqfd.fd = fd; + irqfd.gsi = virq; + irqfd.flags = assign ? 0 : KVM_IRQFD_FLAG_DEASSIGN; if (rfd != -1) { irqfd.flags |= KVM_IRQFD_FLAG_RESAMPLE; irqfd.resamplefd = rfd; } - if (!kvm_irqfds_enabled()) { - return -ENOSYS; - } - return kvm_vm_ioctl(s, KVM_IRQFD, &irqfd); }