[libvirt] Bugfix for failing to reconnect to vbox:///session

Hi All, While reconnecting to vbox:///session, since the VBoxCGlueInit() is not intialized, the g_pfnGetFunctions is NULL and thus reconnection fails with SEGV. Fixed this in the patch below. Regards, Pritesh

On Fri, Jul 17, 2009 at 06:57:24PM +0200, Pritesh Kothari wrote:
Hi All,
While reconnecting to vbox:///session, since the VBoxCGlueInit() is not intialized, the g_pfnGetFunctions is NULL and thus reconnection fails with SEGV. Fixed this in the patch below.
I don't think this is quite correct. We call VBoxCGlueInit() in the vboxRegister() function, which is run when libvirt first initializes the whole library. The real bug is the vboxClose() method which calls vboxUninitialize() which is then calling VBoxCGlueTerm(). So if you have many virConectPtr objects open, the first one you call virConnectClose on will shutdown the entire vbox library, breaking all the other virConnectPtr instances you have active. IMHO, we should simply delete VBoxCGlueTerm() completely. Regards, Daniel
commit 9df6333b50a8b512b30ec5bbbfd01a2eec6cbf8b Author: Pritesh Kothari <Pritesh.Kothari@Sun.com> Date: Fri Jul 17 18:45:57 2009 +0200
libvirt: fixed the intialization routine
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 74c432e..2ccfbd8 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -310,6 +310,12 @@ no_memory: }
static int vboxInitialize(virConnectPtr conn, vboxGlobalData *data) { + + /* Intialize the Glue Library else you can't get to the g_pfnGetFunctions + * function which is needed to fetch the right version of driver */ + if ((VBoxCGlueInit() < 0) || (g_pfnGetFunctions == NULL)) + goto cleanup; + /* Get the API table for out version, g_pVBoxFuncs is for the oldest version of the API that we support so we cannot use that. */ data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION);
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

I don't think this is quite correct. We call VBoxCGlueInit() in the vboxRegister() function, which is run when libvirt first initializes the whole library.
The real bug is the vboxClose() method which calls vboxUninitialize() which is then calling VBoxCGlueTerm(). So if you have many virConectPtr objects open, the first one you call virConnectClose on will shutdown the entire vbox library, breaking all the other virConnectPtr instances you have active.
IMHO, we should simply delete VBoxCGlueTerm() completely.
Right the VBoxCGlueTerm() is causing the whole problem. Resending the patch with changes as suggested above. Regards, Pritesh

On Mon, Jul 20, 2009 at 10:04:31AM +0200, Pritesh Kothari wrote:
I don't think this is quite correct. We call VBoxCGlueInit() in the vboxRegister() function, which is run when libvirt first initializes the whole library.
The real bug is the vboxClose() method which calls vboxUninitialize() which is then calling VBoxCGlueTerm(). So if you have many virConectPtr objects open, the first one you call virConnectClose on will shutdown the entire vbox library, breaking all the other virConnectPtr instances you have active.
IMHO, we should simply delete VBoxCGlueTerm() completely.
Right the VBoxCGlueTerm() is causing the whole problem. Resending the patch with changes as suggested above.
Okay, pushed, thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Mon, Jul 20, 2009 at 10:04:31AM +0200, Pritesh Kothari wrote:
I don't think this is quite correct. We call VBoxCGlueInit() in the vboxRegister() function, which is run when libvirt first initializes the whole library.
The real bug is the vboxClose() method which calls vboxUninitialize() which is then calling VBoxCGlueTerm(). So if you have many virConectPtr objects open, the first one you call virConnectClose on will shutdown the entire vbox library, breaking all the other virConnectPtr instances you have active.
IMHO, we should simply delete VBoxCGlueTerm() completely.
Right the VBoxCGlueTerm() is causing the whole problem. Resending the patch with changes as suggested above.
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 74c432e..42c5477 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -310,6 +310,7 @@ no_memory: }
static int vboxInitialize(virConnectPtr conn, vboxGlobalData *data) { + /* Get the API table for out version, g_pVBoxFuncs is for the oldest version of the API that we support so we cannot use that. */ data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION); @@ -398,7 +399,6 @@ static void vboxUninitialize(vboxGlobalData *data) {
if (data->pFuncs) data->pFuncs->pfnComUninitialize(); - VBoxCGlueTerm();
virDomainObjListFree(&data->domains); virCapabilitiesFree(data->caps);
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Pritesh Kothari