[libvirt] [PATCH 3/9] qemu: Convert virExec usage to virCommand
Eric Blake
eblake at redhat.com
Fri May 13 20:57:34 UTC 2011
On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
> Have virCommand cleanup intermediate process for us
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> src/qemu/qemu_driver.c | 35 +++++++++++------------------------
> src/qemu/qemu_process.c | 2 +-
> 2 files changed, 12 insertions(+), 25 deletions(-)
>
> @@ -3270,23 +3271,8 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
> ret = qemuProcessStart(conn, driver, vm, "stdio", true, *fd, path,
> VIR_VM_OP_RESTORE);
>
> - if (intermediate_pid != -1) {
> - if (ret < 0) {
> - /* if there was an error setting up qemu, the intermediate
> - * process will wait forever to write to stdout, so we
> - * must manually kill it.
> - */
> - VIR_FORCE_CLOSE(intermediatefd);
> - VIR_FORCE_CLOSE(*fd);
> - kill(intermediate_pid, SIGTERM);
> - }
> -
> - /* Wait for intermediate process to exit */
> - while (waitpid(intermediate_pid, &childstat, 0) == -1 &&
> - errno == EINTR) {
> - /* empty */
> - }
> - }
> + if (cmd && virCommandWait(cmd, NULL) < 0)
> + goto out;
> VIR_FORCE_CLOSE(intermediatefd);
>
> if (VIR_CLOSE(*fd) < 0) {
> @@ -3324,6 +3310,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
> ret = 0;
>
> out:
> + virCommandFree(cmd);
FD leak. Now you can get to the 'out' label without closing
intermdiatefd. But we also have to be careful that we don't close
things twice (since intermediatefd is sometimes set to *fd, but the
caller may close *fd). I think we need a v3 just to make sure we get
the fd semantics correct on this one.
--
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/bb06daa3/attachment-0001.sig>
More information about the libvir-list
mailing list