Re: [PATCH v2] openvzDomainSetNetwork: use virCommand

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

 



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);

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]