mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
esx: Do not return root objects in a lookup
The lookups in esx_vi work a bit differently that we are used to. The filters (travelsalSpec and selectSet) choose how to look up the objects, but given a root object the lookup lists all the objects of a requested type inside it as well as the root object itself. We then go through the results and find the one which has the same name as was requested. However in a case with nested folders of a same name this could break when the first returned object in the list is the parent folder as we'd select it only based on the name. To avoid this also add a check that the candidate we are trying to pick is not exactly the same object (reference) as the root object. https://bugzilla.redhat.com/show_bug.cgi?id=1643868 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
088bb9cebe
commit
2e2c9797c5
@ -4973,6 +4973,11 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
|
|||||||
candidate = candidate->_next) {
|
candidate = candidate->_next) {
|
||||||
name_candidate = NULL;
|
name_candidate = NULL;
|
||||||
|
|
||||||
|
if (candidate->obj->_type == root->_type &&
|
||||||
|
g_strcmp0(candidate->obj->type, root->type) == 0 &&
|
||||||
|
g_strcmp0(candidate->obj->value, root->value) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (esxVI_GetStringValue(candidate, "name", &name_candidate,
|
if (esxVI_GetStringValue(candidate, "name", &name_candidate,
|
||||||
esxVI_Occurrence_RequiredItem) < 0) {
|
esxVI_Occurrence_RequiredItem) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user