Skip to contentSkip to conversation

python: Adjust xc_physinfo wrapper for updated virt_caps bits

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

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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, and add reporting of both "pv_directio" and "hvm_directio".

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

---
 tools/python/xen/lowlevel/xc/xc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/python/xen/lowlevel/xc/xc.c +6 -1
index cc8175a11e..0a8d8f407e 100644
@@ -973,7 +973,8 @@ 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",
+                                    "hvm_directio", "pv_directio" };
 
     if ( xc_physinfo(self->xc_handle, &pinfo) != 0 )
         return pyxc_error_to_exception(self->xc_handle);
@@ -989,6 +990,10 @@ static PyObject *pyxc_physinfo(XcObject *self)
     for ( i = 0; i < 2; i++ )
         if ( (pinfo.capabilities >> i) & 1 )
           p += sprintf(p, "%s ", virtcap_names[i]);
+    if (pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio)
+        for ( i = 0; i < 2; i++ )
+            if ( (pinfo.capabilities >> i) & 1 )
+              p += sprintf(p, "%s ", virtcap_names[i+2]);
     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 v1 1/1
#1 lore raw
Quoted 7 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, and add reporting of both "pv_directio" and "hvm_directio".

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

#2 lore raw
In reply to Marek Marczykowski-Górecki

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

Quoted 5 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, and add reporting of both "pv_directio" and "hvm_directio".

Thanks for your attention to this...

But:

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 977

Quoted 10 lines

index cc8175a11e..0a8d8f407e 100644

tools/python/xen/lowlevel/xc/xc.c +2 -1
@@ -973,7 +973,8 @@ 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",
+                                    "hvm_directio", "pv_directio" };

It seems quite wrong that we have no way to keep this in sync - and not even comments in both places! (This is not your fault...)

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 998

Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +4 -0
@@ -989,6 +990,10 @@ static PyObject *pyxc_physinfo(XcObject *self)
     for ( i = 0; i < 2; i++ )
         if ( (pinfo.capabilities >> i) & 1 )
           p += sprintf(p, "%s ", virtcap_names[i]);
+    if (pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio)
+        for ( i = 0; i < 2; i++ )
+            if ( (pinfo.capabilities >> i) & 1 )
+              p += sprintf(p, "%s ", virtcap_names[i+2]);
     if ( p != virt_caps )
       *(p-1) = '\0';

I'm not sure I like this. AFAICT the +2 is magic, and you in fact treat the two halves of this array together as a single array. So this should either be two arrays, or, more likely, something like this maybe:

+ p += sprintf(p, "%s_directio ", virtcap_names[i]);

What do you think ?

Ian.

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

#3 lore raw
Quoted 11 lines · Ian Jackson

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

Quoted 5 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, and add reporting of both "pv_directio" and "hvm_directio".

Thanks for your attention to this...

But:

Quoted 13 lines

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 977

Quoted 10 lines

index cc8175a11e..0a8d8f407e 100644

tools/python/xen/lowlevel/xc/xc.c +2 -1
@@ -973,7 +973,8 @@ 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",
+                                    "hvm_directio", "pv_directio" };

It seems quite wrong that we have no way to keep this in sync - and not even comments in both places! (This is not your fault...)

I'll add a comment...

Quoted 16 lines

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 998

Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +4 -0
@@ -989,6 +990,10 @@ static PyObject *pyxc_physinfo(XcObject *self)
     for ( i = 0; i < 2; i++ )
         if ( (pinfo.capabilities >> i) & 1 )
           p += sprintf(p, "%s ", virtcap_names[i]);
+    if (pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio)
+        for ( i = 0; i < 2; i++ )
+            if ( (pinfo.capabilities >> i) & 1 )
+              p += sprintf(p, "%s ", virtcap_names[i+2]);
     if ( p != virt_caps )
       *(p-1) = '\0';

I'm not sure I like this. AFAICT the +2 is magic, and you in fact treat the two halves of this array together as a single array. So this should either be two arrays, or, more likely, something like this maybe:

Quoted 3 lines

+ p += sprintf(p, "%s_directio ", virtcap_names[i]);

What do you think ?

Makes sense.

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

#4 lore raw
Quoted 26 lines · Marek Marczykowski-Górecki
Quoted 11 lines · Ian Jackson

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

Quoted 5 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, and add reporting of both "pv_directio" and "hvm_directio".

Thanks for your attention to this...

But:

Quoted 13 lines

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 977

Quoted 10 lines

index cc8175a11e..0a8d8f407e 100644

tools/python/xen/lowlevel/xc/xc.c +2 -1
@@ -973,7 +973,8 @@ 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",
+                                    "hvm_directio", "pv_directio" };

It seems quite wrong that we have no way to keep this in sync - and not even comments in both places! (This is not your fault...)

Quoted 1 line

I'll add a comment...

Actually, this would work much better if the loop below would use #defines from sysctl.h, instead of hardcoded values. I'll update it this way.

Quoted 22 lines
Quoted 16 lines

tools/python/xen/lowlevel/xc/xc.c static PyObject *pyxc_physinfo(XcObject *self) · line 998

Quoted 10 lines
tools/python/xen/lowlevel/xc/xc.c +4 -0
@@ -989,6 +990,10 @@ static PyObject *pyxc_physinfo(XcObject *self)
     for ( i = 0; i < 2; i++ )
         if ( (pinfo.capabilities >> i) & 1 )
           p += sprintf(p, "%s ", virtcap_names[i]);
+    if (pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio)
+        for ( i = 0; i < 2; i++ )
+            if ( (pinfo.capabilities >> i) & 1 )
+              p += sprintf(p, "%s ", virtcap_names[i+2]);
     if ( p != virt_caps )
       *(p-1) = '\0';

I'm not sure I like this. AFAICT the +2 is magic, and you in fact treat the two halves of this array together as a single array. So this should either be two arrays, or, more likely, something like this maybe:

Quoted 3 lines

+ p += sprintf(p, "%s_directio ", virtcap_names[i]);

What do you think ?

Makes sense.

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