From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 2/9] msix: make kvm specific initialization a function Date: Mon, 20 Sep 2010 17:06:43 +0200 Message-ID: <1284995210-32432-3-git-send-email-avi@redhat.com> References: <1284995210-32432-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org, "Michael S. Tsirkin" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:12114 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755273Ab0ITPGw (ORCPT ); Mon, 20 Sep 2010 11:06:52 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8KF6qKl000541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 20 Sep 2010 11:06:52 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8KF6p1K023410 for ; Mon, 20 Sep 2010 11:06:51 -0400 In-Reply-To: <1284995210-32432-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- hw/msix.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/msix.c b/hw/msix.c index 312439a..2e2ce5a 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -48,6 +48,17 @@ int msix_supported; #ifdef CONFIG_KVM /* KVM specific MSIX helpers */ + +static void kvm_msix_init(PCIDevice *dev) +{ +#ifdef KVM_CAP_IRQCHIP + if (kvm_enabled() && kvm_irqchip_in_kernel()) { + dev->msix_irq_entries = qemu_malloc(dev->msix_entries_nr * + sizeof *dev->msix_irq_entries); + } +#endif +} + static void kvm_msix_free(PCIDevice *dev) { int vector, changed = 0; @@ -150,6 +161,7 @@ static void kvm_msix_del(PCIDevice *dev, unsigned vector) } #else +static void kvm_msix_init(PCIDevice *dev) {} static void kvm_msix_free(PCIDevice *dev) {} static void kvm_msix_update(PCIDevice *dev, int vector, int was_masked, int is_masked) {} @@ -394,12 +406,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries, if (ret) goto err_config; -#ifdef KVM_CAP_IRQCHIP - if (kvm_enabled() && kvm_irqchip_in_kernel()) { - dev->msix_irq_entries = qemu_malloc(nentries * - sizeof *dev->msix_irq_entries); - } -#endif + kvm_msix_init(dev); dev->cap_present |= QEMU_PCI_CAP_MSIX; return 0; -- 1.7.2.3