[libvirt] [PATCH] esx: Improve blocked task detection and fix race condition

Matthias Bolte matthias.bolte at googlemail.com
Fri Jul 30 13:40:09 UTC 2010

2010/7/29 Daniel Veillard <veillard at redhat.com>:
> On Mon, Jul 26, 2010 at 03:12:25AM +0200, Matthias Bolte wrote:
>> esxVI_WaitForTaskCompletion can take a UUID to lookup the
>> corresponding domain and check if the current task for it
>> is blocked by a question. It calls another function to do
>> this: esxVI_LookupAndHandleVirtualMachineQuestion looks up
>> the VirtualMachine and checks for a question. If there is
>> a question it calls esxVI_HandleVirtualMachineQuestion to
>> handle it.
>> If there was no question or it has been answered the call
>> to esxVI_LookupAndHandleVirtualMachineQuestion returns 0.
>> If any error occurred during the lookup and answering
>> process -1 is returned. The problem with this is, that -1
>> is also returned when there was no error but the question
>> could not be answered. So esxVI_WaitForTaskCompletion cannot
>> distinguish between this two situations and reports that a
>> question is blocking the task even when there was actually
>> another problem.
>> This inherent problem didn't surface until vSphere 4.1 when
>> you try to define a new domain. The driver tries to lookup
>> the domain that is just in the process of being registered.
>> There seems to be some kind of race condition and the driver
>> manages to issue a lookup command before the ESX server was
>> able to register the domain. This used to work before.
>> Due to the return value problem described above the driver
>> reported a false error message in that case.
>> To solve this esxVI_WaitForTaskCompletion now takes an
>> additional occurrence parameter that describes whether or
>> not to expect the domain to be existent. Also add a new
>> parameter to esxVI_LookupAndHandleVirtualMachineQuestion
>> that allows to distinguish if the call returned -1 because
>> of an actual error or because the question could not be
>> answered.
>> ---
>>  src/esx/esx_driver.c |   17 ++++++++++++++-
>>  src/esx/esx_vi.c     |   53 ++++++++++++++++++++++++++++++++++++-------------
>>  src/esx/esx_vi.h     |    7 ++++-
>>  src/esx/esx_vmx.c    |    4 +-
>>  4 files changed, 61 insertions(+), 20 deletions(-)
>  Thanks for the detailed explanations !
>  ACK,
> Daniel

Thanks, pushed.


More information about the libvir-list mailing list