[libvirt] [PATCH] [3/6] Add hook utilities

Eric Blake eblake at redhat.com
Fri Mar 26 17:10:36 UTC 2010

On 03/26/2010 11:09 AM, Daniel P. Berrange wrote:
>> Duplicating the definition of all these helpers is a bit of a long
>> distraction in the middle of this function; is it worth a helper file,
>> where we could #include "command_line_builder.h" to get all these
>> helpers defined, and to reduce the duplication from
>> qemudBuildCommandLine by having the macros in one place?
> I'd like to kill off all these macros completely, and instead
> introduce a formal API. In a similar style to virBuffer, have
> a statically initialized struct, APIs to add args & env variables,
> and  a final API to check whether any OOM errors occurred. Then
> a thin wrapper for virExec/virRun to actually execute it
>    typedef struct {
>       int hasError;
>       char **argv;
>       char **env;
>    } virCommandInfo;
>    virCommandInfo cmd = VIR_COMMAND_INFO_INITIALIZER;
>    virCommandInfoAddArg(info, "/usr/bin/kvm");
>    virCommandInfoCopyEnv(info, "PATH");
>    virCommandInfoSetEnv(info, "LANG", "C");
>    virCommandInfoAddArg(info, "--foo");
>    virCommandInfoAddArg(info, "--bar");
>    if (virCommandInfoHasError(info))
>      virReportOOMError();
>    virRunCommand(info);

Even nicer.

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100326/db16d138/attachment-0001.sig>

More information about the libvir-list mailing list