On Sat, Nov 23, 2019 at 01:58:02AM +0200, Nir Soffer wrote:
On Fri, Nov 22, 2019 at 11:07 PM Richard W.M. Jones
<rjones(a)redhat.com> wrote:
>
> On Fri, Nov 22, 2019 at 02:55:31PM -0600, Eric Blake wrote:
> > Unrelated side topic: in your recent addition of eval.sh, you
> > wondered if we should promote it to a full-blown plugin rather than
> > just an example script. But reading 'man nbdkit-sh-plugin', there
> > is no mention of turning an executable script into a full-blown
> > plugin via a shebang, the way that python documents it. [I guess
> > 'man nbdkit' sort of mentions it under Shebang scripts]
>
> I believe it's not possible to do it for sh plugins.
>
> For (eg) python plugins it works like this:
>
> #!/usr/sbin/nbdkit python
> -> runs nbdkit python <script name>
> -> <script name> is interpreted as magic script= parameter
> -> the python plugin works by loading the script using
> PyRun_SimpleFileEx which interprets the contents of the
> script as python code
>
> However for shell it doesn't work:
>
> #!/usr/sbin/nbdkit sh
> -> runs nbdkit sh <script name>
> -> <script name> is interpreted as magic script= parameter
> -> the sh plugin works by actually executing the script
> -> executing the script repeats the steps over from the top,
> causing an infinite loop
>
> If you can think of a way to make this work it would be a useful
> feature IMO.
Even if we can find a way, it sounds too complicated, and I don't see
the use case.
I think an aim of nbdkit is to make it as widely usable as possible.
That's for example why we have apparent esoterica like plugins written
in shell script.
We want to in the future ship the (or "an") imageio plugin separately
from virt-v2v. A possibility is it might be shipped as a single
Python file which starts with ‘#!/usr/bin/env nbdkit python’ which
would allow anyone to run it directly. They wouldn't need to
understand anything about nbdkit or its command line.
So that's the use case (which to be fair is not actually used much
today at all). The context above is I can't think of a way to extend
this feature to nbdkit-sh-plugin.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/