Message ID | 20190815094400.126289-1-wipawel@amazon.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
On Thu, Aug 15, 2019 at 09:44:00AM +0000, Pawel Wieczorkiewicz wrote: > Extend the list of xc() object methods with additional one to display > Xen's buildid. The implementation follows the libxl implementation > (e.g. max buildid size assumption being XC_PAGE_SIZE). > > Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> > Reviewed-by: Martin Mazein <amazein@amazon.de> > Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com> > Reviewed-by: Norbert Manthey <nmanthey@amazon.de> I'm a bit confused by the tag in the subject line. Which series does this patch belong to? Wei.
On 16. Aug 2019, at 14:47, Wei Liu <wl@xen.org<mailto:wl@xen.org>> wrote: On Thu, Aug 15, 2019 at 09:44:00AM +0000, Pawel Wieczorkiewicz wrote: Extend the list of xc() object methods with additional one to display Xen's buildid. The implementation follows the libxl implementation (e.g. max buildid size assumption being XC_PAGE_SIZE). Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de<mailto:wipawel@amazon.de>> Reviewed-by: Martin Mazein <amazein@amazon.de<mailto:amazein@amazon.de>> Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com<mailto:andraprs@amazon.com>> Reviewed-by: Norbert Manthey <nmanthey@amazon.de<mailto:nmanthey@amazon.de>> I'm a bit confused by the tag in the subject line. Which series does this patch belong to? Wei. Thanks for taking a look. This is the series: https://marc.info/?t=155541982300002&r=1&w=4 Best Regards, Pawel Wieczorkiewicz Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
On Thu, Aug 15, 2019 at 09:44:00AM +0000, Pawel Wieczorkiewicz wrote: > Extend the list of xc() object methods with additional one to display > Xen's buildid. The implementation follows the libxl implementation > (e.g. max buildid size assumption being XC_PAGE_SIZE). > > Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> > Reviewed-by: Martin Mazein <amazein@amazon.de> > Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com> > Reviewed-by: Norbert Manthey <nmanthey@amazon.de> > --- > v2: > * No code change > * Adding maintainers > --- > tools/python/xen/lowlevel/xc/xc.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c > index 522cbe3b9c..5459d6834d 100644 > --- a/tools/python/xen/lowlevel/xc/xc.c > +++ b/tools/python/xen/lowlevel/xc/xc.c > @@ -1211,6 +1211,26 @@ out: > return ret_obj ? ret_obj : pyxc_error_to_exception(self->xc_handle); > } > > +static PyObject *pyxc_xenbuildid(XcObject *self) > +{ > + xen_build_id_t *buildid; > + int i, r; > + char *str; > + > + buildid = alloca(sizeof(buildid->len) + XC_PAGE_SIZE); > + buildid->len = XC_PAGE_SIZE - sizeof(*buildid); Those doesn't match. You allocated XC_PAGE_SIZE in addition to sizeof(buildid->len). I'd change to alloca(XC_PAGE_SIZE) - it is unlikely that izeof(buildid->len) would be larger than XC_PAGE_SIZE and we do assume it in other places anyway. > + > + r = xc_version(self->xc_handle, XENVER_build_id, buildid); > + if ( r <= 0 ) > + return pyxc_error_to_exception(self->xc_handle); > + > + str = alloca((r * 2) + 1); > + for ( i = 0; i < r; i++ ) > + snprintf(&str[i * 2], 3, "%02hhx", buildid->buf[i]); > + > + return Py_BuildValue("s", str); > +} > + > static PyObject *pyxc_xeninfo(XcObject *self) > { > xen_extraversion_t xen_extra; > @@ -2294,6 +2314,13 @@ static PyMethodDef pyxc_methods[] = { > "Returns [dict]: information about Xen" > " [None]: on failure.\n" }, > > + { "buildid", > + (PyCFunction)pyxc_xenbuildid, > + METH_NOARGS, "\n" > + "Get Xen buildid\n" > + "Returns [str]: Xen buildid" > + " [None]: on failure.\n" }, > + > { "shadow_control", > (PyCFunction)pyxc_shadow_control, > METH_VARARGS | METH_KEYWORDS, "\n"
> On 19. Aug 2019, at 22:40, Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> wrote: > > On Thu, Aug 15, 2019 at 09:44:00AM +0000, Pawel Wieczorkiewicz wrote: >> Extend the list of xc() object methods with additional one to display >> Xen's buildid. The implementation follows the libxl implementation >> (e.g. max buildid size assumption being XC_PAGE_SIZE). >> >> Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> >> Reviewed-by: Martin Mazein <amazein@amazon.de> >> Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com> >> Reviewed-by: Norbert Manthey <nmanthey@amazon.de> >> --- >> v2: >> …snip... >> >> +static PyObject *pyxc_xenbuildid(XcObject *self) >> +{ >> + xen_build_id_t *buildid; >> + int i, r; >> + char *str; >> + >> + buildid = alloca(sizeof(buildid->len) + XC_PAGE_SIZE); >> + buildid->len = XC_PAGE_SIZE - sizeof(*buildid); > > Those doesn't match. You allocated XC_PAGE_SIZE in addition to > sizeof(buildid->len). I'd change to alloca(XC_PAGE_SIZE) - it is > unlikely that izeof(buildid->len) would be larger than XC_PAGE_SIZE and > we do assume it in other places anyway. ACK. Will fix. > >> + >> + r = xc_version(self->xc_handle, XENVER_build_id, buildid); >> + if ( r <= 0 ) >> + return pyxc_error_to_exception(self->xc_handle); >> + >> …snip... > > -- > 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? Best Regards, Pawel Wieczorkiewicz Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 522cbe3b9c..5459d6834d 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -1211,6 +1211,26 @@ out: return ret_obj ? ret_obj : pyxc_error_to_exception(self->xc_handle); } +static PyObject *pyxc_xenbuildid(XcObject *self) +{ + xen_build_id_t *buildid; + int i, r; + char *str; + + buildid = alloca(sizeof(buildid->len) + XC_PAGE_SIZE); + buildid->len = XC_PAGE_SIZE - sizeof(*buildid); + + r = xc_version(self->xc_handle, XENVER_build_id, buildid); + if ( r <= 0 ) + return pyxc_error_to_exception(self->xc_handle); + + str = alloca((r * 2) + 1); + for ( i = 0; i < r; i++ ) + snprintf(&str[i * 2], 3, "%02hhx", buildid->buf[i]); + + return Py_BuildValue("s", str); +} + static PyObject *pyxc_xeninfo(XcObject *self) { xen_extraversion_t xen_extra; @@ -2294,6 +2314,13 @@ static PyMethodDef pyxc_methods[] = { "Returns [dict]: information about Xen" " [None]: on failure.\n" }, + { "buildid", + (PyCFunction)pyxc_xenbuildid, + METH_NOARGS, "\n" + "Get Xen buildid\n" + "Returns [str]: Xen buildid" + " [None]: on failure.\n" }, + { "shadow_control", (PyCFunction)pyxc_shadow_control, METH_VARARGS | METH_KEYWORDS, "\n"