]> git.ipfire.org Git - thirdparty/libvirt.git/commit
maint: avoid nested use of virConnect{Ref,Close}
authorEric Blake <eblake@redhat.com>
Fri, 3 Jan 2014 15:08:52 +0000 (08:08 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 16 Jan 2014 19:25:45 +0000 (12:25 -0700)
commit25221a1b2103dd4be8a056de5c11705bce037f47
tree7e5b7a3aaea108d0d64d0e63d3554cc01b1e1a8b
parentc05aebfd659979a00ba5046cd549c73af1bb0c74
maint: avoid nested use of virConnect{Ref,Close}

The public virConnectRef and virConnectClose API are just thin
wrappers around virObjectRef/virObjectRef, with added object
validation and an error reset.  Within our backend drivers, use
of the object validation is just an inefficiency since we always
pass valid objects.  More important to think about is what
happens with the error reset; our uses of virConnectRef happened
to be safe (since we hadn't encountered any earlier errors), but
in several cases the use of virConnectClose could lose a real
error.

Ideally, we should also avoid calling virConnectOpen() from
within backend drivers - but that is a known situation that
needs much more design work.

* src/qemu/qemu_process.c (qemuProcessReconnectHelper)
(qemuProcessReconnect): Avoid nested public API call.
* src/qemu/qemu_driver.c (qemuAutostartDomains)
(qemuStateInitialize, qemuStateStop): Likewise.
* src/qemu/qemu_migration.c (doPeer2PeerMigrate): Likewise.
* src/storage/storage_driver.c (storageDriverAutostart):
Likewise.
* src/uml/uml_driver.c (umlAutostartConfigs): Likewise.
* src/lxc/lxc_process.c (virLXCProcessAutostartAll): Likewise.
(virLXCProcessReboot): Likewise, and avoid leaking conn on error.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/lxc/lxc_process.c
src/qemu/qemu_driver.c
src/qemu/qemu_migration.c
src/qemu/qemu_process.c
src/storage/storage_driver.c
src/uml/uml_driver.c