Similarly to what virsh virt-login-shell do, call virAdmInitialize prior to
initializing an event loop and initializing the error handler. Commit
97973ebb7
described and fixed an identical issue for libvirt_lxc.
Since virAdmInitialize becomes a public API after applying this patch,
the symbol is also added to public syms and the doc string of the method is
slightly enhanced analogically to virInitialize.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
*/
typedef virAdmClient *virAdmClientPtr;
+int virAdmInitialize(void);
virAdmConnectPtr virAdmConnectOpen(const char *name, unsigned int flags);
int virAdmConnectClose(virAdmConnectPtr conn);
int virAdmConnectRef(virAdmConnectPtr conn);
*
* Initialize the library.
*
+ * This method is automatically invoked by virAdmConnectOpen() API. Therefore,
+ * in most cases it is unnecessary to call this method manually, unless an
+ * event loop should be set up by calling virEventRegisterImpl() or the error
+ * reporting of the first connection attempt with virSetErrorFunc() should be
+ * altered prior to setting up connections. If the latter is the case, it is
+ * necessary for the application to call virAdmInitialize.
+ *
* Returns 0 in case of success, -1 in case of error
*/
-static int
+int
virAdmInitialize(void)
{
if (virOnce(&virAdmGlobalOnce, virAdmGlobalInit) < 0)
#
LIBVIRT_ADMIN_2.0.0 {
global:
+ virAdmInitialize;
virAdmClientFree;
virAdmClientGetID;
virAdmClientGetTimestamp;
return EXIT_FAILURE;
}
+ if (virAdmInitialize() < 0) {
+ vshError(ctl, "%s", _("Failed to initialize libvirt"));
+ return EXIT_FAILURE;
+ }
+
virFileActivateDirOverride(argv[0]);
if (!vshInit(ctl, cmdGroups, NULL))