[libvirt] [PATCH 1/9] storage: iscsi: Convert virExec to virCommand
Eric Blake
eblake at redhat.com
Fri May 13 20:33:57 UTC 2011
On 05/13/2011 02:10 PM, Cole Robinson wrote:
> v2:
> Use virCommand auto-cleanup
>
> Signed-off-by: Cole Robinson <crobinso at 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 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/54e7b9d6/attachment-0001.sig>
More information about the libvir-list
mailing list