esx: De-duplicate @virtualMachine check in esxDomainLookupByName

The function call esxVI_LookupVirtualMachineByName(occurrence =
OptionalItem) and then checks if @virtualMachine is NULL. If it
is an error is reported. The same result can be achieved by
setting occurrence to RequiredItem.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2018-07-03 16:55:01 +02:00
parent 5feb9f9420
commit d999b6016b

View File

@ -1577,12 +1577,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
"config.uuid\0") < 0 ||
esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList,
&virtualMachine,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
}
if (!virtualMachine) {
virReportError(VIR_ERR_NO_DOMAIN, _("No domain with name '%s'"), name);
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
}