[PATCH] esx: Do not return root objects in a lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/esx/esx_vi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 6f964cc470d1..80ed6199e3ac 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -4973,6 +4973,11 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx,
              candidate = candidate->_next) {
             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,
                                      esxVI_Occurrence_RequiredItem) < 0) {
                 goto cleanup;
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux