mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
esxConnectListAllDomains: Don't propagate failure to lookup a single domain
In esxConnectListAllDomains if the lookup of the VM name and UUID fails for a single VM (possible e.g. with broken storage) the whole API would return failure even when there are working VMs. Rework the lookup so that if a subset fails we ignore the failure on those. We report an error only if lookup of all of the objects failed. Failure is reported from the last one. Resolves: https://issues.redhat.com/browse/RHEL-80606 Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
1 parent
904b5e9d06
commit
7d4de62cfa
1 file changed
+12
-10
+12
-10
@@ -4792,18 +4792,20 @@ esxConnectListAllDomains(virConnectPtr conn,
|
||||
virtualMachine = virtualMachine->_next) {
|
||||
g_autofree char *name = NULL;
|
||||
|
||||
if (needIdentity) {
|
||||
if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id,
|
||||
&name, uuid) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
/* If the lookup of the required properties fails for some of the machines
|
||||
* in the list it's preferrable to return the valid objects instead of
|
||||
* failing outright */
|
||||
if ((needIdentity && esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, uuid) < 0) ||
|
||||
(needPowerState && esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0)) {
|
||||
|
||||
if (needPowerState) {
|
||||
if (esxVI_GetVirtualMachinePowerState(virtualMachine,
|
||||
&powerState) < 0) {
|
||||
/* Raise error only if we didn't successfuly fill any domain */
|
||||
if (count == 0 && !virtualMachine->_next)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* failure to fetch information of a single VM must not interrupt
|
||||
* the lookup of the rest */
|
||||
virResetLastError();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* filter by active state */
|
||||
|
||||
Reference in new issue
Block a user