Displaying 18 results from an estimated 18 matches for "pybytearray_fromstringandsize".
2019 Nov 23
3
[PATCH nbdkit] python: Pass memoryview to pwrite()
...python.c b/plugins/python/python.c
index 214fffb..2b4361a 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -496,8 +496,8 @@ py_pwrite (void *handle, const void *buf,
PyErr_Clear ();
r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ PyMemoryView_FromMemory ((char *)buf, count, PyBUF_READ),
+ offset, NULL);
Py_DECREF (fn);
if (check_python_failure ("pwrite") == -1)
return -1;
--
2.21.0
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...;
>>> @@ -515,9 +546,19 @@ py_pwrite (void *handle, const void *buf,
>>> if (callback_defined ("pwrite", &fn)) {
>>> PyErr_Clear ();
>>> - r = PyObject_CallFunction (fn, "ONL", obj,
>>> - PyByteArray_FromStringAndSize (buf, count),
>>> - offset, NULL);
>>> + switch (py_api_version) {
>>> + case 1:
>>> + r = PyObject_CallFunction (fn, "ONL", obj,
>>> + PyByteArray_FromStringAndSize (buf,...
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python,
these are independent enough to push now (and I'll have to rebase
my 'optional may_trim' patch on top of this).
Eric Blake (2):
python: Use Py_XDEFREF()
python: Simplify calling into plugin
plugins/python/python.c | 106 ++++++++----------------------------------------
1 file changed, 18 insertions(+), 88
2019 Nov 22
0
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...> PyObject *fn;
> >@@ -515,9 +546,19 @@ py_pwrite (void *handle, const void *buf,
> > if (callback_defined ("pwrite", &fn)) {
> > PyErr_Clear ();
> >- r = PyObject_CallFunction (fn, "ONL", obj,
> >- PyByteArray_FromStringAndSize (buf, count),
> >- offset, NULL);
> >+ switch (py_api_version) {
> >+ case 1:
> >+ r = PyObject_CallFunction (fn, "ONL", obj,
> >+ PyByteArray_FromStringAndSize (buf, count),
> >+...
2019 Nov 22
8
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...= handle;
> PyObject *fn;
> @@ -515,9 +546,19 @@ py_pwrite (void *handle, const void *buf,
> if (callback_defined ("pwrite", &fn)) {
> PyErr_Clear ();
>
> - r = PyObject_CallFunction (fn, "ONL", obj,
> - PyByteArray_FromStringAndSize (buf, count),
> - offset, NULL);
> + switch (py_api_version) {
> + case 1:
> + r = PyObject_CallFunction (fn, "ONL", obj,
> + PyByteArray_FromStringAndSize (buf, count),
> +...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -515,9 +546,19 @@ py_pwrite (void *handle, const void *buf,
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
- r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ switch (py_api_version) {
+ case 1:
+ r = PyObject_CallFunction (fn, "ONL", obj,
+ PyByteArray_FromStringAndSize (buf, count),
+ offset, NULL);
+...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -525,9 +570,19 @@ py_pwrite (void *handle, const void *buf,
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
- r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ switch (py_api_version) {
+ case 1:
+ r = PyObject_CallFunction (fn, "ONL", obj,
+ PyByteArray_FromStringAndSize (buf, count),
+ offset, NULL);
+...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...= handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
- args = PyTuple_New (3);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, obj);
- PyTuple_SetItem (args, 1, PyByteArray_FromStringAndSize (buf, count));
- PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset));
- r = PyObject_CallObject (fn, args);
+ r = PyObject_CallFunction (fn, "OOL", obj,
+ PyByteArray_FromStringAndSize (buf, count),
+ offset,...
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...G_FUA) != 0;
+ int need_flush = fua && !pwrite_has_fua;
- assert (!flags);
+ assert (!(flags & ~NBDKIT_FLAG_FUA));
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
- r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ args = Py_BuildValue ("ONL", obj,
+ PyByteArray_FromStringAndSize (buf, count),
+ offset);
+ if (!args) {
+ check_python_failure ("pwrite");
+ Py_DECR...
2019 Nov 21
10
[PATCH nbdkit 0/8] Implement nbdkit API v2 for Python plugins.
And fill out most of the missing bits of the API.
Rich.
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...*args;
PyObject *kwargs;
@@ -516,7 +531,7 @@ py_pwrite (void *handle, const void *buf,
if (callback_defined ("pwrite", &fn)) {
PyErr_Clear ();
- args = Py_BuildValue ("ONL", obj,
+ args = Py_BuildValue ("ONL", h->obj,
PyByteArray_FromStringAndSize (buf, count),
offset);
if (!args) {
@@ -559,7 +574,7 @@ py_pwrite (void *handle, const void *buf,
static int
py_flush (void *handle, uint32_t flags)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *r;
@@ -567,7 +582,7 @@ py_fl...
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for
reference, I added 'zero' support for python, perl, and ruby
back in 1.1.13, then Rich had to add it for ocaml in 1.1.20).
I tested this heavily under python 2, but for now only compile
tested under python 3; I plan to do further testing there and
make any tweaks if necessary.
I wrote patch 5 early on, but then realized I
2019 Nov 22
18
[PATCH nbdkit v2 00/10] Implement nbdkit API v2 for Python plugins.
v1:
https://www.redhat.com/archives/libguestfs/2019-November/msg00153.html
v2:
- Fix implementation of can_cache.
- Add implementation of can_fua.
- Add a very thorough test suite which tests every command + flag
combination.
2019 Aug 10
0
[PATCH libnbd 1/5] python: Change aio_buffer into nbd.Buffer class.
...free (buf);
return NULL;
}
- buf->data = calloc (1, buf->len);
+ buf->data = malloc (buf->len);
if (buf->data == NULL) {
PyErr_NoMemory ();
free (buf);
@@ -193,3 +191,21 @@ nbd_internal_py_aio_buffer_to_bytearray (PyObject *self, PyObject *args)
return PyByteArray_FromStringAndSize (buf->data, buf->len);
}
+
+PyObject *
+nbd_internal_py_aio_buffer_size (PyObject *self, PyObject *args)
+{
+ PyObject *obj;
+ struct py_aio_buffer *buf;
+
+ if (!PyArg_ParseTuple (args,
+ (char *) "O:nbd_internal_py_aio_buffer_size",
+...
2019 Nov 23
8
[PATCH nbdkit v3 0/7] Implement nbdkit API v2 for Python plugins.
v2 was here:
https://www.redhat.com/archives/libguestfs/2019-November/msg00163.html
I pushed patch 1 (with spelling fix), patch 4 and patch 5 since those
were previously ACKed on the list.
Differences in v3:
- Add error checking to PyModule_AddIntConstant.
- Use API_VERSION constant instead of function.
- Add max API version supported to --dump-plugin output.
- Print API_VERSION selected by
2019 Aug 10
7
[PATCH libnbd 0/5] WIP: python: Add test for doing asynch copy.
This doesn't yet work. However it does make me more convinced than
ever that we really need to sort out persistent buffer lifetimes in
the library (similar to what we did for closures).
Rich.
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...-516,7 +531,7 @@ py_pwrite (void *handle, const void *buf,
> if (callback_defined ("pwrite", &fn)) {
> PyErr_Clear ();
>
> - args = Py_BuildValue ("ONL", obj,
> + args = Py_BuildValue ("ONL", h->obj,
> PyByteArray_FromStringAndSize (buf, count),
> offset);
> if (!args) {
> @@ -559,7 +574,7 @@ py_pwrite (void *handle, const void *buf,
> static int
> py_flush (void *handle, uint32_t flags)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *f...
2010 Sep 09
2
[PATCH]: add libxl python binding
...PyErr_SetString(PyExc_TypeError,
+ (sz < len) ? "Byffer underflow" : "Buffer overflow");
+ return -1;
+ }
+
+ memcpy(ptr, tmp, sz);
+ return 0;
+}
+
+static PyObject *fixed_bytearray_get(const uint8_t *ptr, size_t len)
+{
+ return PyByteArray_FromStringAndSize((const char *)ptr, len);
+}
+
+#include "_pyxl_types.h"
+
+int attrib__libxl_cpumap_set(PyObject *v, libxl_cpumap *pptr)
+{
+ return -1;
+}
+
+int attrib__libxl_domain_build_state_ptr_set(PyObject *v, libxl_domain_build_state **pptr)
+{
+ return -1;
+}
+
+int attrib__libxl_file_refe...