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

Re: [libvirt] [PATCH v2] openvzDomainSetNetwork: use virCommand



On 20.05.2013 17:54, Eric Blake wrote:
> On 05/20/2013 07:47 AM, Michal Privoznik wrote:
>> Currently, the openvzDomainSetNetwork function constructs an
>> array of strings representing a command line for VZCTL binary.
>> This is a overkill since our virCommand APIs can cover all the
>> functionality. Moreover, the function is not following our
>> structure where return value is set to -1 initially, and after
>> all operations succeeded then it is set to zero.
>> ---
>>  src/openvz/openvz_driver.c | 80 +++++++++++-----------------------------------
>>  1 file changed, 19 insertions(+), 61 deletions(-)
>> @@ -919,40 +889,28 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
>>              }
>>          }
>>  
>> -        if (!(opt = virBufferContentAndReset(&buf)))
>> -            goto no_memory;
>> +        if (!(opt = virBufferContentAndReset(&buf))) {
>> +            virReportOOMError();
>> +            goto cleanup;
>> +        }
> 
> You can skip the call to virBufferContentAndReset, if you instead do:
> 
>>  
>> -        ADD_ARG_LIT(opt) ;
>> +        /* --netif_add ifname[,mac,host_ifname,host_mac] */
>> +        virCommandAddArgList(cmd, "--netif_add", opt, NULL);
> 
> virCommandAddArg(cmd, "--netif_add");
> virCommandAddArgBuffer(cmd, opt);
> 

Even nicer! I went with this version and pushed. Thank you both guys.

Michal


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