Re: [PATCH 1/9] storage: iscsi: Convert virExec to virCommand

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

 



On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
>     Use virCommand auto-cleanup
> 
> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
> ---
>  src/storage/storage_backend_iscsi.c |   23 +++++++++++------------
>  1 files changed, 11 insertions(+), 12 deletions(-)
> 

>      memset(line, 0, LINE_SIZE);
>  
> -    if (virExec(prog, NULL, NULL, &child, -1, &fd, NULL, VIR_EXEC_NONE) < 0) {
> -        virStorageReportError(VIR_ERR_INTERNAL_ERROR,
> -                              _("Failed to run '%s' when looking for existing interface with IQN '%s'"),
> -                              prog[0], initiatoriqn);
> -
> +    virCommandSetOutputFD(cmd, &fd);
> +    if (virCommandRunAsync(cmd, NULL) < 0) {
>          ret = IQN_ERROR;
...

>  
> +    if (virCommandWait(cmd, NULL) < 0)
> +        ret = IQN_ERROR;
> +
>  out:
>      if (ret == IQN_MISSING) {
>          VIR_DEBUG("Could not find interface with IQN '%s'", iqn);
> @@ -259,6 +257,7 @@ out:
>      VIR_FREE(line);
>      VIR_FORCE_FCLOSE(fp);
>      VIR_FORCE_CLOSE(fd);
> +    virCommandFree(cmd);

Yep, that does the trick for auto-cleanup (I'm liking virCommand more
and more as we convert things to use it).

ACK.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
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]