On 01/16/2018 10:32 AM, Richard W.M. Jones wrote: > Introduce the concept of a backend. Currently the only type of > backend is a plugin, and there can only be one of them. Instead of > calling functions like ‘plugin_pwrite’ you call the backend method > ‘backend->pwrite (backend, ...)’. > > The change is largely mechanical. I was able to remove ‘assert (dl)’ > statements throughout since we can now prove they will never be > called. > > Note this does not lift the restriction of one plugin per server, and > it can *never* do that because plugins can use global variables. > ---
> +struct backend {
> + void (*free) (struct backend *);
> + int (*thread_model) (struct backend *);
> + const char *(*name) (struct backend *);
> + void (*usage) (struct backend *);
> + const char *(*version) (struct backend *);
> + void (*dump_fields) (struct backend *);
> + void (*config) (struct backend *, const char *key, const char *value);
> + void (*config_complete) (struct backend *);
> + int (*errno_is_preserved) (struct backend *);
> + int (*open) (struct backend *, struct connection *conn, int readonly);
Is it worth using 'bool' instead of 'int' where we are really using a
truth value? We can't change the nbdkit-plugin.h API (well, at least
not without plugins opting in), but the new stuff (including filters)
could be sane from the get-go instead of overloading int.
> + void (*close) (struct backend *, struct connection *conn);
> + int64_t (*get_size) (struct backend *, struct connection *conn);
> + int (*can_write) (struct backend *, struct connection *conn);
However, functions like this still need to return int because they are
tri-state (true, false, or -1 for error).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
