[libvirt] [PATCH] virt-admin: Call virInitialize to fix startup crash

Martin Kletzander mkletzan at redhat.com
Tue Jun 28 08:12:01 UTC 2016


On Mon, Jun 27, 2016 at 02:28:39PM -0400, Cole Robinson wrote:
>Similar to what virsh and virt-login-shell do
>
>https://bugzilla.redhat.com/show_bug.cgi?id=1350315
>---
>I can't actually reproduce the bug, the backtrace is similar to
>97973ebb7 which added the same fix for virt-login-shell, and
>that commit also mentions the randomness of reproducing...
>

I think we should try finding out what the cause for that is.  It might
be as simple as adding similar fix to yours and asking the user what
error does he see with that fix in.  The idea behind that is that
scripts shouldn't need to call that initialization as that should be
part of any first call they make to the library.

> tools/virt-admin.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
>diff --git a/tools/virt-admin.c b/tools/virt-admin.c
>index 4acac65..7bff5c3 100644
>--- a/tools/virt-admin.c
>+++ b/tools/virt-admin.c
>@@ -1371,6 +1371,11 @@ main(int argc, char **argv)
>         return EXIT_FAILURE;
>     }
>
>+    if (virInitialize() < 0) {

If this is the right thing to do, it should be virAdmInitialize().  By
using virInitialize() we're giving bad example to others as it only
works in virt-admin thanks to internal.h being included, I guess.

>+        vshError(ctl, "%s", _("Failed to initialize libvirt"));
>+        return EXIT_FAILURE;
>+    }
>+
>     virFileActivateDirOverride(argv[0]);
>
>     if (!vshInit(ctl, cmdGroups, NULL))
>--
>2.7.4
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160628/9e62ba1e/attachment-0001.sig>


More information about the libvir-list mailing list