From mboxrd@z Thu Jan 1 00:00:00 1970 From: muli@il.ibm.com Subject: [PATCH 1/6] device assignment: add ioctl wrappers Date: Tue, 28 Oct 2008 12:06:45 +0200 Message-ID: <1225188410-2222-2-git-send-email-muli@il.ibm.com> References: <1225188410-2222-1-git-send-email-muli@il.ibm.com> Cc: kvm@vger.kernel.org, anthony@codemonkey.ws, weidong.han@intel.com, benami@il.ibm.com, muli@il.ibm.com, amit.shah@redhat.com, allen.m.kay@intel.com To: avi@redhat.com Return-path: Received: from mtagate4.uk.ibm.com ([195.212.29.137]:45109 "EHLO mtagate4.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752543AbYJ1KIH (ORCPT ); Tue, 28 Oct 2008 06:08:07 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate4.uk.ibm.com (8.13.8/8.13.8) with ESMTP id m9SA7tPE070068 for ; Tue, 28 Oct 2008 10:07:55 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m9SA7sC9544876 for ; Tue, 28 Oct 2008 10:07:55 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m9SA6rEr015188 for ; Tue, 28 Oct 2008 10:06:54 GMT In-Reply-To: <1225188410-2222-1-git-send-email-muli@il.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Amit Shah [muli: return -errno instead of ioctl retval] Signed-off-by: Amit Shah Signed-off-by: Muli Ben-Yehuda --- libkvm/libkvm.c | 25 +++++++++++++++++++++++++ libkvm/libkvm.h | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c index 444b97f..e7dba8a 100644 --- a/libkvm/libkvm.c +++ b/libkvm/libkvm.c @@ -1112,3 +1112,28 @@ int kvm_unregister_coalesced_mmio(kvm_context_t kvm, uint64_t addr, uint32_t siz return -ENOSYS; } +#ifdef KVM_CAP_DEVICE_ASSIGNMENT +int kvm_assign_pci_device(kvm_context_t kvm, + struct kvm_assigned_pci_dev *assigned_dev) +{ + int ret; + + ret = ioctl(kvm->vm_fd, KVM_ASSIGN_PCI_DEVICE, assigned_dev); + if (ret < 0) + return -errno; + + return ret; +} + +int kvm_assign_irq(kvm_context_t kvm, + struct kvm_assigned_irq *assigned_irq) +{ + int ret; + + ret = ioctl(kvm->vm_fd, KVM_ASSIGN_IRQ, assigned_irq); + if (ret < 0) + return -errno; + + return ret; +} +#endif diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index 423ce31..53d67f2 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -686,4 +686,31 @@ int kvm_s390_interrupt(kvm_context_t kvm, int slot, int kvm_s390_set_initial_psw(kvm_context_t kvm, int slot, psw_t psw); int kvm_s390_store_status(kvm_context_t kvm, int slot, unsigned long addr); #endif + +#ifdef KVM_CAP_DEVICE_ASSIGNMENT +/*! + * \brief Notifies host kernel about a PCI device to be assigned to a guest + * + * Used for PCI device assignment, this function notifies the host + * kernel about the assigning of the physical PCI device to a guest. + * + * \param kvm Pointer to the current kvm_context + * \param assigned_dev Parameters, like bus, devfn number, etc + */ +int kvm_assign_pci_device(kvm_context_t kvm, + struct kvm_assigned_pci_dev *assigned_dev); + +/*! + * \brief Notifies host kernel about changes to IRQ for an assigned device + * + * Used for PCI device assignment, this function notifies the host + * kernel about the changes in IRQ number for an assigned physical + * PCI device. + * + * \param kvm Pointer to the current kvm_context + * \param assigned_irq Parameters, like dev id, host irq, guest irq, etc + */ +int kvm_assign_irq(kvm_context_t kvm, + struct kvm_assigned_irq *assigned_irq); +#endif #endif -- 1.5.6.5