On 02/06/2018 01:05 AM, Richard W.M. Jones wrote:
I had a think about this. How about (for the internal backend
interface only) returning an extra ‘int *err’ parameter?
For backend only, or for backend and filters? The biggest reason for
the change is so that filters can inspect/modify the error to push over
the wire to the client. If for the filters, would it be for both the
callbacks and the next_ops functions, or just the next_ops functions?
int (*pread) (struct backend *, struct connection *conn, void *buf, uint32_t count,
uint64_t offset, uint32_t flags, int *err);
This has some advantages:
- It's explicit.
- It means we preserve the convention that -1 = error
used everywhere else in nbdkit.
- Better for APIs that actually return something like get_size.
- Can be both read and written.
Seems like it might be reasonable enough, even though it's a bit more
verbose; I can respin my series along those lines for comparison.
Note that get_size() doesn't send an error over the wire to the client,
so there, accessing errno in the filter doesn't buy much, and the filter
really has no need to modify errno if failing its own .get_size
callback. It's only the transmission functions (.pread, .pwrite,
.flush, .trim, .zero) where getting at the error value matters.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org