Skip to contentSkip to conversation

python: Adjust xc_physinfo wrapper for updated virt_caps bits

PATCH In review Marek Marczykowski-Górecki 3 participants 5 messages Apr 29, 2019 – Aug 5, 2019 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 python: Adjust xc_physinfo wrapper for updated virt_caps bits

Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio".

---
This should be backported to 4.12
Cc: Ian Jackson <[email protected]>

Changes in v2:
- Check XEN_SYSCTL_PHYSCAP_* instead of hardcoding bits values
- Do not duplicate virtcap_names entries, instead append _directio in sprintf()

---
 tools/python/xen/lowlevel/xc/xc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
tools/python/xen/lowlevel/xc/xc.c +13 -3
index cc8175a11e..9c03c8272e 100644
@@ -973,11 +973,17 @@ static PyObject *pyxc_physinfo(XcObject *self)
     xc_physinfo_t pinfo;
     char cpu_cap[128], virt_caps[128], *p;
     int i;
-    const char *virtcap_names[] = { "hvm", "hvm_directio" };
+    const char *virtcap_names[] = { "hvm", "pv" };
+    const unsigned virtcaps_bits[] = { XEN_SYSCTL_PHYSCAP_hvm,
+                                       XEN_SYSCTL_PHYSCAP_pv };
 
     if ( xc_physinfo(self->xc_handle, &pinfo) != 0 )
         return pyxc_error_to_exception(self->xc_handle);
 
+    /*
+     * Keep in sync with tools/xl/xl_info.c:output_xeninfo
+     * and struct xen_sysctl_physinfo (especially bit fields).
+     */
     p = cpu_cap;
     *p = '\0';
     for ( i = 0; i < sizeof(pinfo.hw_cap)/4; i++ )
@@ -986,9 +992,13 @@ static PyObject *pyxc_physinfo(XcObject *self)
 
     p = virt_caps;
     *p = '\0';
-    for ( i = 0; i < 2; i++ )
-        if ( (pinfo.capabilities >> i) & 1 )
+    for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ )
+        if ( pinfo.capabilities & virtcaps_bits[i] )
           p += sprintf(p, "%s ", virtcap_names[i]);
+    if ( pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio )
+        for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ )
+            if ( pinfo.capabilities & virtcaps_bits[i] )
+              p += sprintf(p, "%s_directio ", virtcap_names[i]);
     if ( p != virt_caps )
       *(p-1) = '\0';
 
Signature · 7 lines
2.17.2


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Marek Marczykowski-Górecki

Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio".

---

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v2 1/1
#2 lore raw
In reply to Marek Marczykowski-Górecki

Marek Marczykowski-Górecki writes ("[PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits"):

Quoted 7 lines

Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio".

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

Ian Jackson writes ("Re: [PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits"):

Quoted 10 lines

Marek Marczykowski-Górecki writes ("[PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits"):

Quoted 7 lines

Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio".

I think this is a backport candidate for 4.12, since f089fddd94 was in 4.12. Am I right ?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 8 lines · Ian Jackson

Ian Jackson writes ("Re: [PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits"):

Quoted 7 lines

Marek Marczykowski-Górecki writes ("[PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits"):

Quoted 6 lines

Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio".

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think this is a backport candidate for 4.12, since f089fddd94 was in 4.12. Am I right ?

Yes, definitely.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel