]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: fix libvirtd crash when reconnecting domains
authorJim Fehlig <jfehlig@suse.com>
Wed, 21 Aug 2013 17:05:18 +0000 (11:05 -0600)
committerJim Fehlig <jfehlig@suse.com>
Wed, 21 Aug 2013 17:05:18 +0000 (11:05 -0600)
More fallout from commit d72ef888.  When reconnecting to running
domains, the libxl_ctx in libxlDomainObjPrivate was used before
initializing it, causing a segfault in libxl and consequently
crashing libvirtd.

Initialize the libxlDomainObjPrivate libxl_ctx in libxlReconnectDomain,
and while at it use this ctx in libxlReconnectDomain instead of the
driver-wide ctx.

src/libxl/libxl_driver.c

index f09ad6142cf0feb5f77cb642a53cdf36738d7148..9fb4fa513e5969470a9b63d666d79b7bdcac5e08 100644 (file)
@@ -1118,6 +1118,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
                      void *opaque)
 {
     libxlDriverPrivatePtr driver = opaque;
+    libxlDomainObjPrivatePtr priv = vm->privateData;
     int rc;
     libxl_dominfo d_info;
     int len;
@@ -1125,8 +1126,9 @@ libxlReconnectDomain(virDomainObjPtr vm,
 
     virObjectLock(vm);
 
+    libxlDomainObjPrivateInitCtx(vm);
     /* Does domain still exist? */
-    rc = libxl_domain_info(driver->ctx, &d_info, vm->def->id);
+    rc = libxl_domain_info(priv->ctx, &d_info, vm->def->id);
     if (rc == ERROR_INVAL) {
         goto out;
     } else if (rc != 0) {
@@ -1136,7 +1138,7 @@ libxlReconnectDomain(virDomainObjPtr vm,
     }
 
     /* Is this a domain that was under libvirt control? */
-    if (libxl_userdata_retrieve(driver->ctx, vm->def->id,
+    if (libxl_userdata_retrieve(priv->ctx, vm->def->id,
                                 "libvirt-xml", &data, &len)) {
         VIR_DEBUG("libxl_userdata_retrieve failed, ignoring domain %d", vm->def->id);
         goto out;