[Libguestfs] [PATCH nbdkit 2/2] tmpdisk: Pass any parameters as shell variables to the command.

Richard W.M. Jones rjones at redhat.com
Sat Apr 4 20:01:56 UTC 2020


On Sat, Apr 04, 2020 at 05:06:32PM +0100, Richard W.M. Jones wrote:
> This allows us to be much more flexible about what commands can be
> used.  It also means we do not need to encode any special behaviour
> for type or label parameters.
> 
> XXX
> However one problem which is not addressed here: The $disk passed to
> the shell script fragment must be updated, not replaced.  This is
> because currently the plugin has a file descriptor opened on this
> file.  If it is deleted by the script then the fd becomes invalid and
> the plugin will no longer work.  It's unclear if it is safe (from a
> security point of view) for the plugin to reopen the disk by name
> after the script has run.

I realise I didn't say why this is a problem for the consumer of the
plugin (which is different from why it may or may not be a security
problem).

Common commands you might want to use include:

  nbdkit tmpdisk 16G command='virt-builder -o $disk $os --size $size'

  nbdkit tmpdisk 16G command='qemu-img create -f $fmt $disk $size'

The problem is that these commands will delete and recreate the output
file, so will not work with the plugin as written.  (Note that for
qemu-img create, the -n parameter is not sufficient - left as an
interesting puzzle for the reader to work out why.)

If the plugin is allowed to close and reopen $disk, and recalcuate the
size, then these commands would be fine.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list