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

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



On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
>     Use virCommand auto-cleanup
> 
> Signed-off-by: Cole Robinson <crobinso redhat com>
> ---
>  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 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]