[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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

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 redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]