[libvirt] [PATCH 09/16] qemu: Convert virExec usage to virCommand

Eric Blake eblake at redhat.com
Wed May 11 21:40:53 UTC 2011


On 05/10/2011 02:07 PM, Cole Robinson wrote:
> -            if (virExec(intermediate_argv, NULL, NULL,
> -                        &intermediate_pid, intermediatefd, fd, NULL, 0) < 0) {
> +
> +            virCommandSetInputFD(cmd, intermediatefd);
> +            virCommandSetOutputFD(cmd, fd);
> +
> +            if (virCommandRunAsync(cmd, &intermediate_pid) < 0) {

Either pass NULL for the intermediate_pid (which means that
virCommandFree will auto-cleanup the child process), or add a call to
virCommandWait() or waitpid() along all control flow paths; otherwise
you risk leaking a child process.  See how I did it in qemu_migration.c.

Also, you may want to simplify patches 7 and 8 to take advantage of the
virCommandFree auto-cleanup when you use a NULL pid argument.

-- 
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/20110511/4f5a0da9/attachment-0001.sig>


More information about the libvir-list mailing list