Re: [PATCH v3 1/6] virCommand: Introduce virCommandDoAsyncIO

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

 



On 04.02.2013 16:47, Peter Krempa wrote:
> On 02/04/13 15:56, Michal Privoznik wrote:
>> Currently, if we want to feed stdin, or catch stdout or stderr of a
>> virCommand we have to use virCommandRun(). When using
>> virCommandRunAsync()
>> we have to register FD handles by hand. This may lead to code
>> duplication.
>> Hence, introduce an internal API, which does this automatically within
>> virCommandRunAsync(). The intended usage looks like this:
>>
>>      virCommandPtr cmd = virCommandNew*(...);
>>      char *buf = NULL;
>>
>>      ...
>>
>>      virCommandSetOutputBuffer(cmd, &buf);
>>      virCommandDoAsyncIO(cmd);
>>
>>      if (virCommandRunAsync(cmd, NULL) < 0)
>>          goto cleanup;
>>
>>      ...
>>
>>      if (virCommandWait(cmd, NULL) < 0)
>>          goto cleanup;
>>
>>      /* @buf now contains @cmd's stdout */
>>      VIR_DEBUG("STDOUT: %s", NULLSTR(buf));
>>
>>      ...
>>
>> cleanup:
>>      VIR_FREE(buf);
>>      virCommandFree(cmd);
>>
>> Note, that both stdout and stderr buffers may change until
>> virCommandWait()
>> returns.
>> ---
>>   src/libvirt_private.syms |   1 +
>>   src/util/vircommand.c    | 308 ++++++++++++++++++++++++++++++++++++++++++++---
>>   src/util/vircommand.h    |   1 +
>>   3 files changed, 293 insertions(+), 17 deletions(-)
>>

> 
> ACK with the two nits fixed. ACKs on the unchanged patches from the last
> time still stand.
> 
> Peter

Thanks, fixed and pushed.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]