[Libguestfs] [nbdkit PATCH 3/5] filters: Allow nbdkit_next_context_open outside client connection

Richard W.M. Jones rjones at redhat.com
Tue May 11 14:17:39 UTC 2021


On Thu, May 06, 2021 at 08:59:38PM -0500, Eric Blake wrote:
> diff --git a/server/backend.c b/server/backend.c
> index 2244df7a..73994f56 100644
> --- a/server/backend.c
> +++ b/server/backend.c
> @@ -234,24 +234,37 @@ static struct nbdkit_next_ops next_ops = {
>  };
> 
>  struct context *
> -backend_open (struct backend *b, int readonly, const char *exportname)
> +backend_open (struct backend *b, int readonly, const char *exportname,
> +              int shared)
>  {
> -  GET_CONN;
> -  struct context *c = malloc (sizeof *c);
> -  PUSH_CONTEXT_FOR_SCOPE (c);
> +  struct connection *conn = threadlocal_get_conn ();
> +  bool using_tls;
> +  struct context *c;
> 
> +  if (!shared && !conn) {
> +    nbdkit_error ("attempt to open non-shared context outside a connection");
> +    return NULL;

Not abort ()?  Wouldn't this indicate a bug in a filter?

Complicated, but looks good.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list