On 05/13/2011 02:10 PM, Cole Robinson wrote: > v2: > Have virCommand cleanup intermediate process for us > > Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> > --- > 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@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