Re: [PATCH] enable PCI multiple-segments for pass-through device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wright,
Thanks for your comments. I have updated the qemu-options.hx and used
following new CAP. Updated version is also attached.

Index: qemu-kvm/hw/device-assignment.c
===================================================================
--- qemu-kvm.orig/hw/device-assignment.c
+++ qemu-kvm/hw/device-assignment.c
@@ -809,6 +809,16 @@ static int assign_device(AssignedDevice
    struct kvm_assigned_pci_dev assigned_dev_data;
    int r;

+#ifdef KVM_CAP_PCI_SEGMENT
+    /* Only pass non-zero PCI segment to capable module */
+    if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) &&
+        dev->h_segnr) {
+        fprintf(stderr, "Can't assign device inside non-zero PCI segment "
+                "as this KVM module doesn't support it.\n");
+        return -ENODEV;
+    }
+#endif
+
    memset(&assigned_dev_data, 0, sizeof(assigned_dev_data));
    assigned_dev_data.assigned_dev_id  =
    calc_assigned_dev_id(dev->h_segnr, dev->h_busnr, dev->h_devfn);
Index: qemu-kvm/kvm/include/linux/kvm.h
===================================================================
--- qemu-kvm.orig/kvm/include/linux/kvm.h
+++ qemu-kvm/kvm/include/linux/kvm.h
@@ -498,6 +498,8 @@ struct kvm_ioeventfd {
#define KVM_CAP_S390_PSW 42
#define KVM_CAP_PPC_SEGSTATE 43

+#define KVM_CAP_PCI_SEGMENT 47
+
#ifdef KVM_CAP_IRQ_ROUTING

struct kvm_irq_routing_irqchip {


Index: linux-2.6/include/linux/kvm.h
===================================================================
--- linux-2.6.orig/include/linux/kvm.h
+++ linux-2.6/include/linux/kvm.h
@@ -500,6 +500,7 @@ struct kvm_ioeventfd {
#define KVM_CAP_HYPERV 44
#define KVM_CAP_HYPERV_VAPIC 45
#define KVM_CAP_HYPERV_SPIN 46
+#define KVM_CAP_PCI_SEGMENT 47

#ifdef KVM_CAP_IRQ_ROUTING

Index: linux-2.6/arch/x86/kvm/x86.c
===================================================================
--- linux-2.6.orig/arch/x86/kvm/x86.c
+++ linux-2.6/arch/x86/kvm/x86.c
@@ -1569,6 +1569,7 @@ int kvm_dev_ioctl_check_extension(long e
    case KVM_CAP_HYPERV:
    case KVM_CAP_HYPERV_VAPIC:
    case KVM_CAP_HYPERV_SPIN:
+    case KVM_CAP_PCI_SEGMENT:
        r = 1;
        break;
    case KVM_CAP_COALESCED_MMIO:


Chris Wright wrote:
 * Zhai, Edwin (edwin.zhai@xxxxxxxxx) wrote:
> These 2 patches enable optional parameter(default 0) - PCI segment(or > domain) besides BDF, when assigning PCI device to guest.
>
> Signed-off-by: Zhai Edwin <edwin.zhai@xxxxxxxxx>

 Looks good.  For compatibility, an old userspace will zero the padding
 and keep the default 0 segment when running w/ a new kernel, a new
 userspace won't be able to pass a non-zero segment value to an old
 kernel.  If that latter bit matters, need a capability to express this
 change.  Looks like qemu-options.hx needs an update too.  Otherwise...

 Acked-by: Chris Wright <chrisw@xxxxxxxxxxxx>


Attachment: kvm_vtd_multi_seg_qemu_v2.patch
Description: Binary data

Attachment: kvm_vtd_multi_seg_kmod_v2.patch
Description: Binary data


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux