[libvirt] [PATCH 2/9] openvz: Convert virExec usage to virCommand

Eric Blake eblake at redhat.com
Fri May 13 20:47:14 UTC 2011


On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
>     Use virCommand's autocleanup
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  src/openvz/openvz_conf.c   |   37 +++++++++--------------------
>  src/openvz/openvz_driver.c |   55 +++++++++++++++++++++++--------------------
>  2 files changed, 41 insertions(+), 51 deletions(-)

> @@ -1446,18 +1445,22 @@ static int openvzListDefinedDomains(virConnectPtr conn ATTRIBUTE_UNUSED,
>          }
>          got ++;
>      }
> -    waitpid(pid, NULL, 0);
> +
> +    if (virCommandWait(cmd, NULL) < 0)
> +        goto out;
> +
>      if (VIR_CLOSE(outfd) < 0) {
>          virReportSystemError(errno, "%s", _("failed to close file"));
>          goto out;
>      }
> -    return got;
>  
> +    rc = got;
>  out:
>      VIR_FORCE_CLOSE(outfd);
> +    virCommandFree(cmd);
>      for ( ; got >= 0 ; got--)
>          VIR_FREE(names[got]);

Oops, this now frees names[] on success.  You need to gate this for loop
on whether rc >= 0, now that the success path falls through to the out
label.

ACK with that nit fixed.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110513/9b113a6b/attachment-0001.sig>


More information about the libvir-list mailing list