From nobody Wed May 8 22:49:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642888547; cv=none; d=zohomail.com; s=zohoarc; b=a8PlK3r6/5fiz9Lt6Iddn+4lFCC8C5V8DdO4YGtTl7qpHvs7+NjBpY9OkyyqUcTeSjpY9/9Y6j1ZGEbqy9bv0QAH3FOXRLDt54wh6SxfTzuivrPmRXTyxB1KXJNm7XCHmop9bIIhClLFBLf+V12FM8BJPzbA/DNOagw5jHfmWhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642888547; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=CAZanyY5KDmeq8CNMODZ9tmTS56s1NZev2S6Uc9azgE=; b=GnbSUj0+sIo973R43QuA1uRIWoIRNtAY0qriIyCAI/nugBPO1vTF8J7eK77H2D8tN4amNPugmFjSVoe5tkVCdVz2P1hYUN4DdGsPPpssOkEnJkO55296ZKoTg3GXsIctX3PaF87ft0TH2nZXiEst+NI+2PfSBGgVQAX5eFfr7Hc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1642888547348472.4589307286119; Sat, 22 Jan 2022 13:55:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-316-1mcfHEj3NPaiedQ0POPYbA-1; Sat, 22 Jan 2022 16:55:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2BE09814243; Sat, 22 Jan 2022 21:55:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FC2D5DF3A; Sat, 22 Jan 2022 21:55:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B74304BB7C; Sat, 22 Jan 2022 21:55:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20MLshra011658 for ; Sat, 22 Jan 2022 16:54:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5FA3840CFD17; Sat, 22 Jan 2022 21:54:43 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B27240CFD01 for ; Sat, 22 Jan 2022 21:54:43 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4059328F0408 for ; Sat, 22 Jan 2022 21:54:43 +0000 (UTC) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-417-H3QwRLk6Myi8WoNtUzXAmw-1; Sat, 22 Jan 2022 16:54:42 -0500 Received: by mail-ej1-f71.google.com with SMTP id m21-20020a1709061ed500b006b3003ec50dso1431077ejj.17 for ; Sat, 22 Jan 2022 13:54:41 -0800 (PST) Received: from carol.localdomain (k8r.cz. [95.82.177.71]) by smtp.gmail.com with ESMTPSA id w8sm3218384ejq.220.2022.01.22.13.54.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 13:54:40 -0800 (PST) Received: from carol.redhat.com (carol.k8r.cz [IPv6:::1]) by carol.localdomain (Postfix) with ESMTP id 9363DC20024 for ; Sat, 22 Jan 2022 22:54:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642888546; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CAZanyY5KDmeq8CNMODZ9tmTS56s1NZev2S6Uc9azgE=; b=CoeaFMuD7PqQYN0BoG7Zl954/362eEMbOOd7iF2GnQIFhzP8Pd/YM36iUCLc+gsxSDHvEO IISlFGLor51I3HywdVORoTyinjdL2JHbRUtX04GUaooNZdWAu9v4fPqAFROMRe2ARPu/5X vRN7jDJS+eSY1JnVkGXbKveBmh++z3Y= X-MC-Unique: 1mcfHEj3NPaiedQ0POPYbA-1 X-MC-Unique: H3QwRLk6Myi8WoNtUzXAmw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=CAZanyY5KDmeq8CNMODZ9tmTS56s1NZev2S6Uc9azgE=; b=pzbq11qQGs3j4VbiZwGGAXXTZQrnmBrkgIhIhV6+MAGP05QOi6avm16Rpzf+qxHeh8 KU9mqSYUnqD/AL6mU1NAeawzZEFq3xa84Bcgg6q4rydNNb9bGaLtNSdYzqqn8WMY94W/ /S36XPB7L+RAH5p/yNvk7qjUNMaDEroDOxnATWz1icRi5l5nVJO7LZVDiNgA+hlVBvx6 j8aKgEctR/MZTqd2BEKgpFDkGiydf66xfvvNxcNP+wp60oH1I8XVSuxdM4+OIIGnl4IO XALDD4hh5qM80wMhFUNFu/FZ6FYoKIOeH0nJxRxL9mRXw1uSv5zJ4jEV0XsHrN/aC/ZH tQug== X-Gm-Message-State: AOAM531cUcOF5kdOsQygQT29hxWlKhGqu8aUobStvX2LyWUjWSrd67Ua o8HbrtANTpPlBEPN6mofkyBCiRnjreYfbwLB00wc9YC1LkvZ5WStuZiT7S19lUKuAQMjua8HKWP DmN5M7k9G4QZNAtD3Ed24mFnKLDTywBCb6FVROr1TzE2q1GUcgI3tilvNgscDP3Pf2EdHVCs= X-Received: by 2002:a17:906:2814:: with SMTP id r20mr7730740ejc.434.1642888480943; Sat, 22 Jan 2022 13:54:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT84IT3mb8fjwByQEdwznWGOyAEzZSjmBE9N6EIj9OSmQ+6nC8klngnxVrf+rVq7XL5bQXeQ== X-Received: by 2002:a17:906:2814:: with SMTP id r20mr7730732ejc.434.1642888480672; Sat, 22 Jan 2022 13:54:40 -0800 (PST) From: Martin Kletzander To: libvir-list@redhat.com Subject: [PATCH] esx: Do not return root objects in a lookup Date: Sat, 22 Jan 2022 22:54:28 +0100 Message-Id: <09d7532e53083fc2021d32c00231fec84a83c3ee.1642888468.git.mkletzan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642888549501100001 Content-Type: text/plain; charset="utf-8" The lookups in esx_vi work a bit differently that we are used to. The filt= ers (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 th= e one which has the same name as was requested. However in a case with nested fo= lders 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=3D1643868 Signed-off-by: Martin Kletzander Reviewed-by: Tim Wiederhake --- 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 =3D candidate->_next) { name_candidate =3D NULL; =20 + if (candidate->obj->_type =3D=3D root->_type && + g_strcmp0(candidate->obj->type, root->type) =3D=3D 0 && + g_strcmp0(candidate->obj->value, root->value) =3D=3D 0) + continue; + if (esxVI_GetStringValue(candidate, "name", &name_candidate, esxVI_Occurrence_RequiredItem) < 0) { goto cleanup; --=20 2.34.1