mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
admin: fix virt-admin startup crash by calling virAdmInitialize
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>
This commit is contained in:
parent
a3f565b339
commit
c924965b24
@ -85,6 +85,7 @@ typedef virAdmServer *virAdmServerPtr;
|
|||||||
*/
|
*/
|
||||||
typedef virAdmClient *virAdmClientPtr;
|
typedef virAdmClient *virAdmClientPtr;
|
||||||
|
|
||||||
|
int virAdmInitialize(void);
|
||||||
virAdmConnectPtr virAdmConnectOpen(const char *name, unsigned int flags);
|
virAdmConnectPtr virAdmConnectOpen(const char *name, unsigned int flags);
|
||||||
int virAdmConnectClose(virAdmConnectPtr conn);
|
int virAdmConnectClose(virAdmConnectPtr conn);
|
||||||
int virAdmConnectRef(virAdmConnectPtr conn);
|
int virAdmConnectRef(virAdmConnectPtr conn);
|
||||||
|
@ -81,9 +81,16 @@ virAdmGlobalInit(void)
|
|||||||
*
|
*
|
||||||
* Initialize the library.
|
* 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
|
* Returns 0 in case of success, -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
virAdmInitialize(void)
|
virAdmInitialize(void)
|
||||||
{
|
{
|
||||||
if (virOnce(&virAdmGlobalOnce, virAdmGlobalInit) < 0)
|
if (virOnce(&virAdmGlobalOnce, virAdmGlobalInit) < 0)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#
|
#
|
||||||
LIBVIRT_ADMIN_2.0.0 {
|
LIBVIRT_ADMIN_2.0.0 {
|
||||||
global:
|
global:
|
||||||
|
virAdmInitialize;
|
||||||
virAdmClientFree;
|
virAdmClientFree;
|
||||||
virAdmClientGetID;
|
virAdmClientGetID;
|
||||||
virAdmClientGetTimestamp;
|
virAdmClientGetTimestamp;
|
||||||
|
@ -1371,6 +1371,11 @@ main(int argc, char **argv)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virAdmInitialize() < 0) {
|
||||||
|
vshError(ctl, "%s", _("Failed to initialize libvirt"));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
virFileActivateDirOverride(argv[0]);
|
virFileActivateDirOverride(argv[0]);
|
||||||
|
|
||||||
if (!vshInit(ctl, cmdGroups, NULL))
|
if (!vshInit(ctl, cmdGroups, NULL))
|
||||||
|
Loading…
Reference in New Issue
Block a user