Skip to contentSkip to conversation

virt/kvm: change kvm_assign_device() to print return value when iommu_attach_device() fails

PATCH Applied Shuah Khan 3 participants 4 messages Oct 9, 2012 – Oct 10, 2012 KVM

lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

PATCH 1/1 virt/kvm: change kvm_assign_device() to print return value when iommu_attach_device() fails

Change existing kernel error message to include return value from iommu_attach_device() when it fails. This will help debug device assignment failures more effectively.

---
 virt/kvm/iommu.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
virt/kvm/iommu.c +1 -5
index 037cb67..18e1e30 100644
@@ -168,11 +168,7 @@ int kvm_assign_device(struct kvm *kvm,
 
 	r = iommu_attach_device(domain, &pdev->dev);
 	if (r) {
-		printk(KERN_ERR "assign device %x:%x:%x.%x failed",
-			pci_domain_nr(pdev->bus),
-			pdev->bus->number,
-			PCI_SLOT(pdev->devfn),
-			PCI_FUNC(pdev->devfn));
+		dev_err(&pdev->dev, "kvm assign device failed ret %d", r);
 		return r;
 	}
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 15 lines · Shuah Khan

Change existing kernel error message to include return value from iommu_attach_device() when it fails. This will help debug device assignment failures more effectively.

---
 virt/kvm/iommu.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
virt/kvm/iommu.c +0 -0
index 037cb67..18e1e30 100644
@@ -168,11 +168,7 @@ int kvm_assign_device(struct kvm *kvm,
 

virt/kvm/iommu.c int kvm_assign_device(struct kvm *kvm, · line 173

Quoted 10 lines
virt/kvm/iommu.c +1 -5
 	r = iommu_attach_device(domain, &pdev->dev);
 	if (r) {
-		printk(KERN_ERR "assign device %x:%x:%x.%x failed",
-			pci_domain_nr(pdev->bus),
-			pdev->bus->number,
-			PCI_SLOT(pdev->devfn),
-			PCI_FUNC(pdev->devfn));
+		dev_err(&pdev->dev, "kvm assign device failed ret %d", r);
 		return r;
 	}

Why removal of domain,bus,slot,func from the message?

#2 lore raw
Quoted 16 lines · Marcelo Tosatti
Quoted 15 lines · Shuah Khan

Change existing kernel error message to include return value from iommu_attach_device() when it fails. This will help debug device assignment failures more effectively.

---
 virt/kvm/iommu.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
virt/kvm/iommu.c +0 -0
index 037cb67..18e1e30 100644
@@ -168,11 +168,7 @@ int kvm_assign_device(struct kvm *kvm,
 
Quoted 13 lines

virt/kvm/iommu.c int kvm_assign_device(struct kvm *kvm, · line 173

Quoted 10 lines
virt/kvm/iommu.c +1 -5
      r = iommu_attach_device(domain, &pdev->dev);
      if (r) {
-             printk(KERN_ERR "assign device %x:%x:%x.%x failed",
-                     pci_domain_nr(pdev->bus),
-                     pdev->bus->number,
-                     PCI_SLOT(pdev->devfn),
-                     PCI_FUNC(pdev->devfn));
+             dev_err(&pdev->dev, "kvm assign device failed ret %d", r);
              return r;
      }

Why removal of domain,bus,slot,func from the message?

dev_err() includes that information like this:

pci 0000:00:1d.0: assign device failed ret 0

Without the removal of domain,bus,slot,func from the message:

It will look like:

pci 0000:00:1d.0: assign device 0:0:1d.0 failed ret 0

Initially I left it in there and after testing, realized it is duplicate information and decided to remove it.

-- Shuah