if (esxVI_SuspendVM_Task(priv->primary, virtualMachine->obj, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
}
if (esxVI_PowerOffVM_Task(ctx, virtualMachine->obj, &task) < 0 ||
- esxVI_WaitForTaskCompletion(ctx, task, domain->uuid, priv->autoAnswer,
- &taskInfoState) < 0) {
+ esxVI_WaitForTaskCompletion(ctx, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
+ priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
datastoreRelatedPath, NULL, esxVI_Boolean_False,
resourcePool, hostSystem->obj, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->host, task, def->uuid,
+ esxVI_Occurrence_OptionalItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_VirtualMachinePowerState_Undefined,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->vCenter, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_Boolean_True,
esxVI_Boolean_False, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL,
&task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
if (esxVI_RemoveSnapshot_Task(priv->primary, snapshotTree->snapshot,
removeChildren, &task) < 0 ||
esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
+ esxVI_Occurrence_RequiredItem,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
esxVI_String *completePropertyNameList = NULL;
esxVI_VirtualMachineQuestionInfo *questionInfo = NULL;
esxVI_TaskInfo *pendingTaskInfoList = NULL;
+ esxVI_Boolean blocked = esxVI_Boolean_Undefined;
if (esxVI_String_DeepCopyList(&completePropertyNameList,
propertyNameList) < 0 ||
if (questionInfo != NULL &&
esxVI_HandleVirtualMachineQuestion(ctx, (*virtualMachine)->obj,
- questionInfo, autoAnswer) < 0) {
+ questionInfo, autoAnswer,
+ &blocked) < 0) {
goto cleanup;
}
int
esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
const unsigned char *uuid,
- esxVI_Boolean autoAnswer)
+ esxVI_Occurrence occurrence,
+ esxVI_Boolean autoAnswer,
+ esxVI_Boolean *blocked)
{
int result = -1;
esxVI_ObjectContent *virtualMachine = NULL;
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.question") < 0 ||
esxVI_LookupVirtualMachineByUuid(ctx, uuid, propertyNameList,
- &virtualMachine,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetVirtualMachineQuestionInfo(virtualMachine,
- &questionInfo) < 0) {
+ &virtualMachine, occurrence) < 0) {
goto cleanup;
}
- if (questionInfo != NULL &&
- esxVI_HandleVirtualMachineQuestion(ctx, virtualMachine->obj,
- questionInfo, autoAnswer) < 0) {
- goto cleanup;
+ if (virtualMachine != NULL) {
+ if (esxVI_GetVirtualMachineQuestionInfo(virtualMachine,
+ &questionInfo) < 0) {
+ goto cleanup;
+ }
+
+ if (questionInfo != NULL &&
+ esxVI_HandleVirtualMachineQuestion(ctx, virtualMachine->obj,
+ questionInfo, autoAnswer,
+ blocked) < 0) {
+ goto cleanup;
+ }
}
result = 0;
esxVI_HandleVirtualMachineQuestion
(esxVI_Context *ctx, esxVI_ManagedObjectReference *virtualMachine,
esxVI_VirtualMachineQuestionInfo *questionInfo,
- esxVI_Boolean autoAnswer)
+ esxVI_Boolean autoAnswer, esxVI_Boolean *blocked)
{
int result = -1;
esxVI_ElementDescription *elementDescription = NULL;
int answerIndex = 0;
char *possibleAnswers = NULL;
+ if (blocked == NULL || *blocked != esxVI_Boolean_Undefined) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ *blocked = esxVI_Boolean_False;
+
if (questionInfo->choice->choiceInfo != NULL) {
for (elementDescription = questionInfo->choice->choiceInfo;
elementDescription != NULL;
_("Pending question blocks virtual machine execution, "
"question is '%s', no possible answers"),
questionInfo->text);
+
+ *blocked = esxVI_Boolean_True;
goto cleanup;
} else if (answerChoice == NULL) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"question is '%s', possible answers are %s, but no "
"default answer is specified"), questionInfo->text,
possibleAnswers);
+
+ *blocked = esxVI_Boolean_True;
goto cleanup;
}
questionInfo->text);
}
+ *blocked = esxVI_Boolean_True;
goto cleanup;
}
esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
esxVI_ManagedObjectReference *task,
const unsigned char *virtualMachineUuid,
+ esxVI_Occurrence virtualMachineOccurrence,
esxVI_Boolean autoAnswer,
esxVI_TaskInfoState *finalState)
{
esxVI_PropertyChange *propertyChange = NULL;
esxVI_AnyType *propertyValue = NULL;
esxVI_TaskInfoState state = esxVI_TaskInfoState_Undefined;
+ esxVI_Boolean blocked = esxVI_Boolean_Undefined;
esxVI_TaskInfo *taskInfo = NULL;
version = strdup("");
if (virtualMachineUuid != NULL) {
if (esxVI_LookupAndHandleVirtualMachineQuestion
- (ctx, virtualMachineUuid, autoAnswer) < 0) {
+ (ctx, virtualMachineUuid, virtualMachineOccurrence,
+ autoAnswer, &blocked) < 0) {
/*
* FIXME: Disable error reporting here, so possible errors from
* esxVI_LookupTaskInfoByTask() and esxVI_CancelTask()
}
if (taskInfo->cancelable == esxVI_Boolean_True) {
- if (esxVI_CancelTask(ctx, task) < 0) {
+ if (esxVI_CancelTask(ctx, task) < 0 &&
+ blocked == esxVI_Boolean_True) {
VIR_ERROR0(_("Cancelable task is blocked by an "
"unanswered question but cancelation "
"failed"));
}
- } else {
+ } else if (blocked == esxVI_Boolean_True) {
VIR_ERROR0(_("Non-cancelable task is blocked by an "
"unanswered question"));
}
int esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx,
const unsigned char *uuid,
- esxVI_Boolean autoAnswer);
+ esxVI_Occurrence occurrence,
+ esxVI_Boolean autoAnswer,
+ esxVI_Boolean *blocked);
int esxVI_LookupRootSnapshotTreeList
(esxVI_Context *ctx, const unsigned char *virtualMachineUuid,
(esxVI_Context *ctx,
esxVI_ManagedObjectReference *virtualMachine,
esxVI_VirtualMachineQuestionInfo *questionInfo,
- esxVI_Boolean autoAnswer);
+ esxVI_Boolean autoAnswer, esxVI_Boolean *blocked);
int esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
esxVI_ManagedObjectReference *task,
const unsigned char *virtualMachineUuid,
+ esxVI_Occurrence virtualMachineOccurrence,
esxVI_Boolean autoAnswer,
esxVI_TaskInfoState *finalState);
/* Search datastore for file */
if (esxVI_SearchDatastore_Task(ctx, hostDatastoreBrowser, datastorePath,
searchSpec, &task) < 0 ||
- esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Boolean_False,
- &taskInfoState) < 0) {
+ esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None,
+ esxVI_Boolean_False, &taskInfoState) < 0) {
goto cleanup;
}