From nobody Mon Feb 9 05:41:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1618476072; cv=none; d=zohomail.com; s=zohoarc; b=DIESwfKtqTF/dSjmyxcevVVhVCfxCZjU4aPapFfvuC/S8nqvWEDtE004x1mipPTyK6B5en999TgPHx9s+O1XSfj1ob2R+Ck9dc4Jcw28tz6Sf5kpSRjkKjy8wa/LxV6fk6toHGF/8++k3G7i5Df2RvsuR77sr5X5CyS37gYV7c4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618476072; h=Content-Type:Content-Transfer-Encoding:Cc: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=/EHZ1e9dDiSqAqK9N5YJxe4iSNVMR7YpvyI2iX0nCo8=; b=lW95oD7BRJIbfIu+cwmxtfHBwP6ZZZH8nGFB+u+ma7VJrGkpl+p8vnQxWVqT4z8PvwASrku9mw+j7IVJyOLNQJ5AwNlMYkvpwxuXM4iu6JQ54yTVtoSKX+pcXlI8XBsg7lM0t+83hpX/ZJINhPuFxLM7IKxCheosMOueVldpXUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1618476072088264.84507095675326; Thu, 15 Apr 2021 01:41:12 -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-579-A1oHW-0PPtOFFKZDOMjZ3w-1; Thu, 15 Apr 2021 04:41:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCE8B802B4F; Thu, 15 Apr 2021 08:41:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8F406267E; Thu, 15 Apr 2021 08:41:02 +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 7812A1806D17; Thu, 15 Apr 2021 08:41:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13F8exuf021233 for ; Thu, 15 Apr 2021 04:40:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5E615D76F; Thu, 15 Apr 2021 08:40:59 +0000 (UTC) Received: from work.redhat.com (ovpn-114-212.ams2.redhat.com [10.36.114.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D85D62462; Thu, 15 Apr 2021 08:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618476071; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=/EHZ1e9dDiSqAqK9N5YJxe4iSNVMR7YpvyI2iX0nCo8=; b=FVMF7Pp6x5EaU3+OmkN+OL4hWgtXE7FSUQr5CVciZ/bxxiOPHnoeF/JZ7X7mt+DbRDvSAn CSVv5OiPU/GX/gSBHMinFtRYY2/VJMcY9YHAmc0Uq8yYFodEfOPOPQ3GXYKPASFOgTONuR ilPaTpjsMvUkwNL1IiWXJR9Oqv77Efg= X-MC-Unique: A1oHW-0PPtOFFKZDOMjZ3w-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] virxml: Fix schema validation of individual nodes Date: Thu, 15 Apr 2021 10:40:53 +0200 Message-Id: <20210415084054.9971-2-twiederh@redhat.com> In-Reply-To: <20210415084054.9971-1-twiederh@redhat.com> References: <20210415084054.9971-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.15 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" xmlDocSetRootElement removes the node from its previous document tree, effectively removing the "" node from "" in virCPUDefParseXML. Signed-off-by: Tim Wiederhake --- src/util/virxml.c | 13 ++++++------- src/util/virxml.h | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 117f50f2bf..d816a8e08d 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1285,16 +1285,15 @@ virXMLValidateAgainstSchema(const char *schemafile, =20 =20 int -virXMLValidateNodeAgainstSchema(const char *schemafile, - xmlDocPtr doc, - xmlNodePtr node) +virXMLValidateNodeAgainstSchema(const char *schemafile, xmlNodePtr node) { - xmlNodePtr root; int ret; + xmlDocPtr copy =3D xmlNewDoc(NULL); =20 - root =3D xmlDocSetRootElement(doc, node); - ret =3D virXMLValidateAgainstSchema(schemafile, doc); - xmlDocSetRootElement(doc, root); + xmlDocSetRootElement(copy, xmlCopyNode(node, true)); + ret =3D virXMLValidateAgainstSchema(schemafile, copy); + + xmlFreeDoc(copy); return ret; } =20 diff --git a/src/util/virxml.h b/src/util/virxml.h index de171dce12..8a8ec2a6df 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -213,7 +213,6 @@ virXMLValidateAgainstSchema(const char *schemafile, =20 int virXMLValidateNodeAgainstSchema(const char *schemafile, - xmlDocPtr doc, xmlNodePtr node); =20 void --=20 2.26.2