From nobody Sun Feb 8 18:57:41 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=1636043554; cv=none; d=zohomail.com; s=zohoarc; b=RrJQlmzopyBKM/fb7P2b4HevdqMCRCFEMFVF3Ifjqi7UKPPle+Gp7FkOJ46BXM8EKQqA162Qn7iq4FLTWeRG+LEXM5WMcdLYyoirmTBljcXwmbL8tc7d/fX5GAJjiJWzWdDh/Jz4udiVj0z0oj0hDJXDGrER2IwY7FPOmCGOjqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636043554; 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=ym+0kegCrsjnmOgpe1UiqlBuldZIsNZqhTEe1crhnYs=; b=lWkzrj50qFSSqJQSm1xJssHGLPwi9rldZ2D8OQRhxxwWh2i3Q6aEED0XXdu8NCsgLQD6fB5HP3HL7E7pIdjlVeV1zsQyTLflOYEf+TByZgyEwXSy8+A47QymtCkoEQOPYcIKl7Vs+OlvrndMKYCRTHKdDi7jf6WhpOEjOwz9NwU= 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) 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 1636043554539358.51801951212656; Thu, 4 Nov 2021 09:32:34 -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-479-3IqzNn99PmCOYldmNwQeAw-1; Thu, 04 Nov 2021 12:32:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E3A8CC621; Thu, 4 Nov 2021 16:32: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 F342760C17; Thu, 4 Nov 2021 16:32:24 +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 BEBFC4EA2A; Thu, 4 Nov 2021 16:32:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4GRQDc026367 for ; Thu, 4 Nov 2021 12:27:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id D80F619C79; Thu, 4 Nov 2021 16:27:26 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FE8A19D9F; Thu, 4 Nov 2021 16:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636043553; 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=ym+0kegCrsjnmOgpe1UiqlBuldZIsNZqhTEe1crhnYs=; b=GLP3MzrCMP3MzBePUk65geyDU/DYY7zE+VcJDhaV88HB0Q2F0HbpI3ZQFWNS2/3YMISjHz 9YZsIxm9vuXw50RCze4RpQ9J0HBiyMgwuXvunmzEAsA9ppPA5CgkgTQADmI7ZwtGoeytEX NZbLJ1WT6yEpkihX0DXdgGdBbcMe/i0= X-MC-Unique: 3IqzNn99PmCOYldmNwQeAw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 05/20] cpu: Split up virCPUDataParse Date: Thu, 4 Nov 2021 17:27:05 +0100 Message-Id: <20211104162720.108973-6-twiederh@redhat.com> In-Reply-To: <20211104162720.108973-1-twiederh@redhat.com> References: <20211104162720.108973-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.12 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: 1636043555823100001 Content-Type: text/plain; charset="utf-8" This makes it possible to call virCPUDataParse with a xmlNodePtr, which will be required by a later patch. Signed-off-by: Tim Wiederhake --- src/cpu/cpu.c | 29 +++++++++++++++++++++-------- src/cpu/cpu.h | 2 ++ src/libvirt_private.syms | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 7823c7cd3d..b97d06c7d8 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -803,11 +803,8 @@ virCPUDataFormat(const virCPUData *data) virCPUData * virCPUDataParse(const char *xmlStr) { - struct cpuArchDriver *driver; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - virCPUData *data =3D NULL; - g_autofree char *arch =3D NULL; =20 VIR_DEBUG("xmlStr=3D%s", xmlStr); =20 @@ -817,7 +814,25 @@ virCPUDataParse(const char *xmlStr) return NULL; } =20 - if (!(arch =3D virXPathString("string(/cpudata/@arch)", ctxt))) { + return virCPUDataParseNode(ctxt->node); +} + + +/** + * virCPUDataParseNode: + * + * @node: XML node as produced by virCPUDataFormat + * + * Parses XML representation of virCPUData structure. + * + * Returns internal CPU data structure parsed from the XML or NULL on erro= r. + */ +virCPUData *virCPUDataParseNode(xmlNodePtr node) +{ + g_autofree char *arch =3D NULL; + struct cpuArchDriver *driver; + + if (!(arch =3D virXMLPropString(node, "arch"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing CPU data architecture")); return NULL; @@ -827,13 +842,11 @@ virCPUDataParse(const char *xmlStr) return NULL; =20 if (!driver->dataParse) { - virReportError(VIR_ERR_NO_SUPPORT, - _("cannot parse %s CPU data"), arch); + virReportError(VIR_ERR_NO_SUPPORT, _("cannot parse %s CPU data"), = arch); return NULL; } =20 - data =3D driver->dataParse(ctxt->node); - return data; + return driver->dataParse(node); } =20 =20 diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index c4897a33f5..a67af61757 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -285,3 +285,5 @@ char *virCPUDataFormat(const virCPUData *data) ATTRIBUTE_NONNULL(1); virCPUData *virCPUDataParse(const char *xmlStr) ATTRIBUTE_NONNULL(1); +virCPUData *virCPUDataParseNode(xmlNodePtr node) + ATTRIBUTE_NONNULL(1); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 55ae7d5b6f..21a723035d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1462,6 +1462,7 @@ virCPUDataFormat; virCPUDataFree; virCPUDataNew; virCPUDataParse; +virCPUDataParseNode; virCPUExpandFeatures; virCPUGetHost; virCPUGetHostIsSupported; --=20 2.31.1