From nobody Sun Feb 8 19:56:46 2026 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=1617980673; cv=none; d=zohomail.com; s=zohoarc; b=HVTOSZYVYFvKkY1NjRkaz+NOb4n4gA4HXjNVRnitocw46ZyoA29oWGT2G8lIdemE3tWupzd+F21r1D6bHmXxCojLuH792Qr21oyIP19WunbVtcMDTiCNvz4oxxPJXwA0oAdshGQv8k6osjajslnxbOGKhAHrtB+AVnnHuL+GOX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617980673; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D/zwCeMOWyjrn56W6QHMn5TsWCJVYFyNyfsmApfJ4rI=; b=KZmqrgos/QWWA6nA60QtqTc7QWuNVq70QNDK17qDyo6bTqPzpGNtpIc0w1Ha0HJ3be1tWHXBU7OJoM/VUM1twEVC6XODzIf4PlltNrSMs7oxtmUbgWN8ye/YlK0FMS+1g7GkRH0Gr0fcm/zqaI+v1CDcG0G9jqVdUdenzYNGG3E= 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) header.from= 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 1617980673291662.1789590619352; Fri, 9 Apr 2021 08:04:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-vYkV8CvNNUiJ4yxy8xwdog-1; Fri, 09 Apr 2021 11:01:11 -0400 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 DA3A618765B5; Fri, 9 Apr 2021 15:00:25 +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 A9DAC5D9C0; Fri, 9 Apr 2021 15:00:25 +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 63D8255345; Fri, 9 Apr 2021 15:00:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139Evkdq023824 for ; Fri, 9 Apr 2021 10:57:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 451BE14106; Fri, 9 Apr 2021 14:57:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8208460D79 for ; Fri, 9 Apr 2021 14:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617980672; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=D/zwCeMOWyjrn56W6QHMn5TsWCJVYFyNyfsmApfJ4rI=; b=IuG3NDYjf1IPub4ypLIZw3wM69kSU83Xj/hEIrc0JIrEyNdHMipMgQVqMhbGPF5cYUz4PK gRY4wIOopm6iiwbPwXxDfhWtFR/2sl+etxblTJ7lFMb6OaaptjVa52wzdHtxkY4F4mRNEi O2fptBiPuwGXWompzFQRsXHUhCw0j+E= X-MC-Unique: vYkV8CvNNUiJ4yxy8xwdog-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [RFC PATCH 17/43] qemuxml2argvtest: Rewrite parsing of XMLs to provide earlier parsing Date: Fri, 9 Apr 2021 16:56:53 +0200 Message-Id: <49428f3dcef43ec467cc387ff3937b3f67e2d1ea.1617979432.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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) Content-Type: text/plain; charset="utf-8" In upcoming patches we'll need to parse a certain bit of XML before calling the full XML parser. This effectively open-codes what virDomainDefParseFile to reach virDomainDefParseNode. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- tests/qemuxml2argvtest.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5e062eefcb..aa6ae9bb4b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -645,6 +645,9 @@ testCompareXMLToArgv(const void *data) char *log =3D NULL; g_autoptr(virCommand) cmd =3D NULL; qemuDomainObjPrivatePtr priv =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + xmlNodePtr root; if (info->arch !=3D VIR_ARCH_NONE && info->arch !=3D VIR_ARCH_X86_64) qemuTestSetHostArch(&driver, info->arch); @@ -668,6 +671,21 @@ testCompareXMLToArgv(const void *data) if (testCheckExclusiveFlags(info->flags) < 0) goto cleanup; + if (!(xml =3D virXMLParse(info->infile, NULL, "(domain_definition)"))) + goto cleanup; + + root =3D xmlDocGetRootElement(xml); + if (!virXMLNodeNameEqual(root, "domain")) { + VIR_TEST_VERBOSE("unexpected root element <%s>, expecting = ", + root->name); + goto cleanup; + } + + if (!(ctxt =3D virXMLXPathContextNew(xml))) + goto cleanup; + + ctxt->node =3D root; + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0) goto cleanup; @@ -686,9 +704,9 @@ testCompareXMLToArgv(const void *data) } parseFlags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; - if (!(vm->def =3D virDomainDefParseFile(info->infile, - driver.xmlopt, - NULL, parseFlags))) { + + if (!(vm->def =3D virDomainDefParseNode(xml, root, driver.xmlopt, NULL, + parseFlags))) { err =3D virGetLastError(); if (!err) { VIR_TEST_DEBUG("no error was reported for expected parse error= "); --=20 2.30.2