Skip to contentSkip to conversation

Include errno values in printfs for some xc_ calls.

RFC PATCH In review Konrad Rzeszutek Wilk 3 participants 10 messages Mar 13, 2015 – Mar 16, 2015

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Include errno values in printfs for some xc_ calls.

Hey,

I've just posted on xen-devel patches that make these two set of xc_* function conform to the style of returning -1 for error and stashing the Exx in errno. See:
http://lists.xen.org/archives/html/xen-devel/2015-03/msg01766.html

and
http://lists.xen.org/archives/html/xen-devel/2015-03/msg01769.html
(xc_domain_add_to_physmap fails uses do_memory_op).

 hw/xen/xen_pt.c     | 4 ++--
 hw/xen/xen_pt_msi.c | 4 ++--
 xen-hvm.c           | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
#1 lore raw

RFC PATCH 1/2 xen/hw/passthrough: Use errno instead of ret for xc_physdev_map_* calls

As the libxc library follows (mostly) the return negative for failure and stashes the error value in errno.

---
 hw/xen/xen_pt.c     | 4 ++--
 hw/xen/xen_pt_msi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_pt.c +2 -2
index c1bf357..d2c187d 100644
@@ -691,8 +691,8 @@ static int xen_pt_initfn(PCIDevice *d)
     rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
 
     if (rc < 0) {
-        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (rc: %d)\n",
-                   machine_irq, pirq, rc);
+        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
+                   machine_irq, pirq, errno);
 
         /* Disable PCI intx assertion (turn on bit10 of devctl) */
         xen_host_pci_set_word(&s->real_device,
hw/xen/xen_pt_msi.c +2 -2
index 9ed9321..b01921a 100644
@@ -132,8 +132,8 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
                                      msix_entry, table_base);
         if (rc) {
             XEN_PT_ERR(&s->dev,
-                       "Mapping of MSI%s (rc: %i, vec: %#x, entry %#x)\n",
-                       is_msix ? "-X" : "", rc, gvec, msix_entry);
+                       "Mapping of MSI%s (err: %i, vec: %#x, entry %#x)\n",
+                       is_msix ? "-X" : "", errno, gvec, msix_entry);
             return rc;
         }
     }
Signature · 1 line
2.1.0
Acked-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH RFC v1 1/2] xen/hw/passthrough: Use errno instead of ret for xc_physdev_map_* calls

Quoted 4 lines · Konrad Rzeszutek Wilk

As the libxc library follows (mostly) the return negative for failure and stashes the error value in errno.

I'll add it to my queue

Quoted 37 lines
 hw/xen/xen_pt.c     | 4 ++--
 hw/xen/xen_pt_msi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_pt.c +2 -2
index c1bf357..d2c187d 100644
@@ -691,8 +691,8 @@ static int xen_pt_initfn(PCIDevice *d)
     rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
 
     if (rc < 0) {
-        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (rc: %d)\n",
-                   machine_irq, pirq, rc);
+        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
+                   machine_irq, pirq, errno);
 
         /* Disable PCI intx assertion (turn on bit10 of devctl) */
         xen_host_pci_set_word(&s->real_device,
hw/xen/xen_pt_msi.c +2 -2
index 9ed9321..b01921a 100644
@@ -132,8 +132,8 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
                                      msix_entry, table_base);
         if (rc) {
             XEN_PT_ERR(&s->dev,
-                       "Mapping of MSI%s (rc: %i, vec: %#x, entry %#x)\n",
-                       is_msix ? "-X" : "", rc, gvec, msix_entry);
+                       "Mapping of MSI%s (err: %i, vec: %#x, entry %#x)\n",
+                       is_msix ? "-X" : "", errno, gvec, msix_entry);
             return rc;
         }
     }
Signature · 1 line
2.1.0
#3 lore raw

Re: [PATCH RFC v1 1/2] xen/hw/passthrough: Use errno instead of ret for xc_physdev_map_* calls

Quoted 9 lines · Stefano Stabellini
Quoted 4 lines · Konrad Rzeszutek Wilk

As the libxc library follows (mostly) the return negative for failure and stashes the error value in errno.

I'll add it to my queue

Thank you.

Quoted 39 lines
Quoted 39 lines

 hw/xen/xen_pt.c     | 4 ++--
 hw/xen/xen_pt_msi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_pt.c +2 -2
index c1bf357..d2c187d 100644
@@ -691,8 +691,8 @@ static int xen_pt_initfn(PCIDevice *d)
     rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
 
     if (rc < 0) {
-        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (rc: %d)\n",
-                   machine_irq, pirq, rc);
+        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
+                   machine_irq, pirq, errno);
 
         /* Disable PCI intx assertion (turn on bit10 of devctl) */
         xen_host_pci_set_word(&s->real_device,
hw/xen/xen_pt_msi.c +2 -2
index 9ed9321..b01921a 100644
@@ -132,8 +132,8 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
                                      msix_entry, table_base);
         if (rc) {
             XEN_PT_ERR(&s->dev,
-                       "Mapping of MSI%s (rc: %i, vec: %#x, entry %#x)\n",
-                       is_msix ? "-X" : "", rc, gvec, msix_entry);
+                       "Mapping of MSI%s (err: %i, vec: %#x, entry %#x)\n",
+                       is_msix ? "-X" : "", errno, gvec, msix_entry);
             return rc;
         }
     }
Signature · 1 line
2.1.0
#4 lore raw

Re: [Qemu-devel] [PATCH RFC v1 1/2] xen/hw/passthrough: Use errno instead of ret for xc_physdev_map_* calls

In reply to Stefano Stabellini
Quoted 9 lines · Stefano Stabellini
Quoted 4 lines · Konrad Rzeszutek Wilk

As the libxc library follows (mostly) the return negative for failure and stashes the error value in errno.

I'll add it to my queue

Thank you.

Quoted 39 lines
Quoted 39 lines

 hw/xen/xen_pt.c     | 4 ++--
 hw/xen/xen_pt_msi.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_pt.c +2 -2
index c1bf357..d2c187d 100644
@@ -691,8 +691,8 @@ static int xen_pt_initfn(PCIDevice *d)
     rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
 
     if (rc < 0) {
-        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (rc: %d)\n",
-                   machine_irq, pirq, rc);
+        XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
+                   machine_irq, pirq, errno);
 
         /* Disable PCI intx assertion (turn on bit10 of devctl) */
         xen_host_pci_set_word(&s->real_device,
hw/xen/xen_pt_msi.c +2 -2
index 9ed9321..b01921a 100644
@@ -132,8 +132,8 @@ static int msi_msix_setup(XenPCIPassthroughState *s,
                                      msix_entry, table_base);
         if (rc) {
             XEN_PT_ERR(&s->dev,
-                       "Mapping of MSI%s (rc: %i, vec: %#x, entry %#x)\n",
-                       is_msix ? "-X" : "", rc, gvec, msix_entry);
+                       "Mapping of MSI%s (err: %i, vec: %#x, entry %#x)\n",
+                       is_msix ? "-X" : "", errno, gvec, msix_entry);
             return rc;
         }
     }
Signature · 1 line
2.1.0
#5 lore raw

RFC PATCH 2/2 xen-hvm: When using xc_domain_add_to_physmap also include errno when reporting

In reply to Konrad Rzeszutek Wilk

.errors - as it will most likely have the proper error value.

---
 xen-hvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen-hvm.c +2 -2
index 7548794..3d6fed3 100644
@@ -348,7 +348,7 @@ go_physmap:
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
@@ -425,7 +425,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
Signature · 1 line
2.1.0
#6 lore raw

RFC PATCH 2/2 xen-hvm: When using xc_domain_add_to_physmap also include errno when reporting

In reply to Konrad Rzeszutek Wilk

.errors - as it will most likely have the proper error value.

---
 xen-hvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen-hvm.c +2 -2
index 7548794..3d6fed3 100644
@@ -348,7 +348,7 @@ go_physmap:
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
@@ -425,7 +425,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
Signature · 1 line
2.1.0
Acked-by on v1 2/2
#7 lore raw

Re: [PATCH RFC v1 2/2] xen-hvm: When using xc_domain_add_to_physmap also include errno when reporting

Quoted 3 lines · Konrad Rzeszutek Wilk

.errors - as it will most likely have the proper error value.

Quoted 28 lines
 xen-hvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen-hvm.c +2 -2
index 7548794..3d6fed3 100644
@@ -348,7 +348,7 @@ go_physmap:
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
@@ -425,7 +425,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
Signature · 1 line
2.1.0
Acked-by on v1 2/2
#8 lore raw

Re: [Qemu-devel] [PATCH RFC v1 2/2] xen-hvm: When using xc_domain_add_to_physmap also include errno when reporting

In reply to Konrad Rzeszutek Wilk
Quoted 3 lines · Konrad Rzeszutek Wilk

.errors - as it will most likely have the proper error value.

Quoted 28 lines
 xen-hvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xen-hvm.c +2 -2
index 7548794..3d6fed3 100644
@@ -348,7 +348,7 @@ go_physmap:
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             DPRINTF("add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
@@ -425,7 +425,7 @@ static int xen_remove_from_physmap(XenIOState *state,
         rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);
         if (rc) {
             fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
-                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);
+                    PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);
             return -rc;
         }
     }
Signature · 1 line
2.1.0
#9 lore raw
In reply to Konrad Rzeszutek Wilk

This series passed Patchew automatic testing, but there are some warnings.

Find the log fragments below, or open the following URL to see the full log:

http://qemu.patchew.org/testing/log/<[email protected]>

----------8<---------

docker run --net=none -v /var/tmp/patchew-tester/tmpJLu77j:/var/tmp/patchew-test patchew:fedora-20 timeout 3600 /var/tmp/patchew-test/qemu-devel.sh /var/tmp/patchew-test

*** Testing 'coding style check' ***

Checking 0001-xen-hw-passthrough--Use-errno-instead-of-ret-for-xc_physdev_map_--calls.patch
total: 0 errors, 0 warnings, 20 lines checked

0001-xen-hw-passthrough--Use-errno-instead-of-ret-for-xc_physdev_map_--calls.patch has no obvious style problems and is ready for submission.

Checking 0002-xen-hvm--When-using-xc_domain_add_to_physmap-also-include-errno-when-reporting.patch command failed with exit code 0
$@
WARNING: line over 80 characters
#17: FILE: xen-hvm.c:351:
+ PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);

WARNING: line over 80 characters
#26: FILE: xen-hvm.c:428:
+ PRI_xen_pfn" failed: %d (errno: %d)\n", idx, gpfn, rc, errno);

total: 0 errors, 2 warnings, 16 lines checked

0002-xen-hvm--When-using-xc_domain_add_to_physmap-also-include-errno-when-reporting.patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

*** Testing 'configure' ***

Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
binary directory  /usr/local/bin

library directory /usr/local/lib
module directory /usr/local/lib/qemu
libexec directory /usr/local/libexec