From nobody Sun Feb 8 18:31:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642772437; cv=none; d=zohomail.com; s=zohoarc; b=hv91aTSBkKn+7VARPm40Ul6mjCBEp18IQpyh09kqfF4GazHGzRPP3wJdfLdCSdEGA50jJ4IH+ayk5m9HzlzMpz5PC5YJ4dtLxEHJv3v+iJPgxR3PeEZfWj1mj7b5K5bDqtunz7JDp3jF3nVc95kAtOCAIKSFBMngZRW8NdiJuvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642772437; 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=PXN65+5Y46uWnUYsmhEwYoDvle48xHEhKNY+Chm76Bk=; b=Pd2PVSJpxotnrMrZv+YhP/9QD95/lB8wAtZ18cHx1p2c8B0dPbL3dVLnK7R0DtjGGMEz2mDHfv2DMBVSIJVtJNtznYR1lacTJqbwIJLeoi/lyx7XcZDK82NPGE6fG1xSdub/p2GATt682l/fEYL0IWrsDHZSMi4P3f7Dbhz4xxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 164277243710246.727841864747575; Fri, 21 Jan 2022 05:40:37 -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-347-4PCEUBMZMrOL7caqQQ83cg-1; Fri, 21 Jan 2022 08:40:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22D991091DAC; Fri, 21 Jan 2022 13:40:28 +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 CE43710A394F; Fri, 21 Jan 2022 13:40:27 +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 912091832DBD; Fri, 21 Jan 2022 13:40:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20LDSUE6011988 for ; Fri, 21 Jan 2022 08:28:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id A8E1C108F850; Fri, 21 Jan 2022 13:28:30 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33B251090033 for ; Fri, 21 Jan 2022 13:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642772436; 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=PXN65+5Y46uWnUYsmhEwYoDvle48xHEhKNY+Chm76Bk=; b=MR76PgEyCZcLPSeOU28zyA9vm4GTGIWPinKxyCoV7Nm44MQhprkrTS0UDUP8yyr2utLN6w mg5dcRW0PC6Tuv1lle0Q2dBmKvehydNW/JThq1H0eIwwRRmdqk/lqB52fo7q3OKDf2aFpL I443cL1b2JqDTCXBOUpY/MArkv7xuFU= X-MC-Unique: 4PCEUBMZMrOL7caqQQ83cg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/12] conf: Convert virCPUDefParseXML() to virXMLProp*() Date: Fri, 21 Jan 2022 14:28:14 +0100 Message-Id: <233e9f2ae894b930addf62df289ab72bc6422f40.1642771642.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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: 1642772437910100003 Content-Type: text/plain; charset="utf-8" After previous cleanups, the virCPUDefParseXML() function uses a mixture of virXMLProp*() and the old virXMLPropString() + virXXXTypeFromString() patterns. Rework it so that virXMLProp*() is used. Signed-off-by: Michal Privoznik --- src/conf/cpu_conf.c | 24 ++++++++---------------- src/conf/cpu_conf.h | 2 +- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 8e61a16919..da83e99371 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -407,17 +407,11 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, } =20 if (def->type =3D=3D VIR_CPU_TYPE_GUEST) { - g_autofree char *match =3D virXMLPropString(ctxt->node, "match"); - - if (match) { - def->match =3D virCPUMatchTypeFromString(match); - if (def->match < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Invalid match attribute for CPU " - "specification")); - return -1; - } - } + if (virXMLPropEnum(ctxt->node, "match", + virCPUMatchTypeFromString, + VIR_XML_PROP_NONE, + &def->match) < 0) + return -1; =20 if (virXMLPropEnum(ctxt->node, "check", virCPUCheckTypeFromString, VIR_XML_PROP_NONE, &def->check) < 0) @@ -450,12 +444,10 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, if ((counter_node =3D virXPathNode("./counter[@name=3D'tsc'])", ct= xt))) { tsc =3D g_new0(virHostCPUTscInfo, 1); =20 - if (virXPathULongLong("string(./counter[@name=3D'tsc']/@freque= ncy)", - ctxt, &tsc->frequency) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Invalid TSC frequency")); + if (virXMLPropULongLong(counter_node, "frequency", 10, + VIR_XML_PROP_REQUIRED, + &tsc->frequency) < 0) return -1; - } =20 if (virXMLPropTristateBool(counter_node, "scaling", VIR_XML_PROP_NONE, diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index b0a81895be..2cda4ee1f4 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -122,7 +122,7 @@ struct _virCPUDef { int refs; int type; /* enum virCPUType */ int mode; /* enum virCPUMode */ - int match; /* enum virCPUMatch */ + virCPUMatch match; virCPUCheck check; virArch arch; char *model; --=20 2.34.1