On Sun, Dec 13, 2009 at 12:20:49AM +0100, Matthias Bolte wrote: > If a virtual machine is destroyed on a ESX server then immediately > undefining this virtual machine on a vCenter may fail, because the > vCenter has not been informed about the status change yet. Therefore, > destroy a virtual machine on a vCenter if available, so the vCenter > is up-to-date when the virtual machine should be undefined. > --- > src/esx/esx_driver.c | 20 +++++++++++++------- > 1 files changed, 13 insertions(+), 7 deletions(-) > > diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c > index 98b8e91..7792291 100644 > --- a/src/esx/esx_driver.c > +++ b/src/esx/esx_driver.c > @@ -1499,21 +1499,28 @@ esxDomainDestroy(virDomainPtr domain) > { > int result = 0; > esxPrivate *priv = (esxPrivate *)domain->conn->privateData; > + esxVI_Context *ctx = NULL; > esxVI_ObjectContent *virtualMachine = NULL; > esxVI_String *propertyNameList = NULL; > esxVI_VirtualMachinePowerState powerState; > esxVI_ManagedObjectReference *task = NULL; > esxVI_TaskInfoState taskInfoState; > > - if (esxVI_EnsureSession(domain->conn, priv->host) < 0) { > + if (priv->vCenter != NULL) { > + ctx = priv->vCenter; > + } else { > + ctx = priv->host; > + } > + > + if (esxVI_EnsureSession(domain->conn, ctx) < 0) { > goto failure; > } > > if (esxVI_String_AppendValueToList(domain->conn, &propertyNameList, > "runtime.powerState") < 0 || > esxVI_LookupVirtualMachineByUuidAndPrepareForTask > - (domain->conn, priv->host, domain->uuid, propertyNameList, > - &virtualMachine, priv->autoAnswer) < 0 || > + (domain->conn, ctx, domain->uuid, propertyNameList, &virtualMachine, > + priv->autoAnswer) < 0 || > esxVI_GetVirtualMachinePowerState(domain->conn, virtualMachine, > &powerState) < 0) { > goto failure; > @@ -1525,11 +1532,10 @@ esxDomainDestroy(virDomainPtr domain) > goto failure; > } > > - if (esxVI_PowerOffVM_Task(domain->conn, priv->host, virtualMachine->obj, > + if (esxVI_PowerOffVM_Task(domain->conn, ctx, virtualMachine->obj, > &task) < 0 || > - esxVI_WaitForTaskCompletion(domain->conn, priv->host, task, > - domain->uuid, priv->autoAnswer, > - &taskInfoState) < 0) { > + esxVI_WaitForTaskCompletion(domain->conn, ctx, task, domain->uuid, > + priv->autoAnswer, &taskInfoState) < 0) { > goto failure; > } > Okay, similar, c.f. my question on previous patch :-) ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list