From 4d1cf65a8ce6350ba4b2c6600da1d8b1b291e2b8 Mon Sep 17 00:00:00 2001 From: Jim Fehlig Date: Wed, 21 Aug 2013 11:05:18 -0600 Subject: [PATCH] libxl: fix libvirtd crash when reconnecting domains 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index f09ad6142c..9fb4fa513e 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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; -- 2.47.2