[libvirt] [PATCH v2 2/3] virCommand: Introduce virCommandSetDryRun

Daniel P. Berrange berrange at redhat.com
Tue Jan 28 16:51:11 UTC 2014

On Tue, Jan 28, 2014 at 05:08:14PM +0100, Michal Privoznik wrote:
> There are some units within libvirt that utilize virCommand API to run
> some commands and deserve own unit testing. These units are, however,
> not desired to be rewritten to dig virCommand API usage out. As a great
> example virNetDevBandwidth could be used. The problem with the bandwidth
> unit is: it uses virComamnd API heavily. Therefore we need a mechanism
> to not really run a command, but rather see its string representation
> after which we can decide if the unit construct the correct sequence of
> commands or not.

> diff --git a/src/util/vircommand.h b/src/util/vircommand.h
> index e977f93..d942c5b 100644
> --- a/src/util/vircommand.h
> +++ b/src/util/vircommand.h
> @@ -184,4 +184,6 @@ void virCommandAbort(virCommandPtr cmd);
>  void virCommandFree(virCommandPtr cmd);
>  void virCommandDoAsyncIO(virCommandPtr cmd);
> +
> +void virCommandSetDryRun(const char *file);

Do we really need to write it out to a file, or would it be simpler to
just pass in a virBufferPtr instead, so we just write to RAM. This
avoids any tmpfile naming complexity in code using this.

|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

More information about the libvir-list mailing list