From nobody Fri May 17 22:40:28 2024 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=1666620922; cv=none; d=zohomail.com; s=zohoarc; b=Z3FHosoMr6gBP9kjyF38D2kUZQvjeMTYaxKX5vyQ2dVZZ6ux7Ly/VhdPaA9jAqolbivmKJ1Jtpnlr/otsjHzDBsw+eukr98Wr3x1uggYm+atuvRFHZ8qzYBqrv60Z/eqWcD3KOC1kLY/aEGdW0slQHBfmooLvvy0MBXmENewke0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620922; 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=J1K/DaFCFqs5EHLiat0XgElJPSRZgZEUEoMcCs6uEwY=; b=MvlF0CiMnrRnIg2iSErJogxNj6DmAYmqMJvLI5YxQVVlzlbBIKzfH49wmnW0Mj5mdF06HbggPpZaFZctPG5Q1KoIn6KAcoBiJd+tnFXFXVU7k5OJfd5QcW2BNDrxV1ZcrhbjH4GhHO83at6882I00XBnK2ZObg8/WSdD3Rp6Zdk= 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 1666620922787748.5302863055982; Mon, 24 Oct 2022 07:15:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-18NDFuyuNY68ILstEVvs1w-1; Mon, 24 Oct 2022 10:15:08 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F2E9811E84; Mon, 24 Oct 2022 14:14:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA6CC15BB2; Mon, 24 Oct 2022 14:14:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A297F19465B5; Mon, 24 Oct 2022 14:14:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1C398194658D for ; Mon, 24 Oct 2022 14:14:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0272E40C2064; Mon, 24 Oct 2022 14:14:52 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 715EF40C2140 for ; Mon, 24 Oct 2022 14:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620920; 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=J1K/DaFCFqs5EHLiat0XgElJPSRZgZEUEoMcCs6uEwY=; b=GWAJjYFNk4z/9ErcZNCOX+et6F1q0iYJ+kHzyDWcZIpoljVRmkZNFgPCY47kwWuuRbLqDu 2eFQchPliKUhjQVJ/Zorh5kQlaerVXUu9zWpE/Wel5Od1AO5D10/7bSWau8UYfLdYwo8ab uMB8T5RTcTLWNpAMnvHNb9TysmFwSEo= X-MC-Unique: 18NDFuyuNY68ILstEVvs1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/43] util: xml: Remove unused virXPathNumber Date: Mon, 24 Oct 2022 16:14:06 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620923808100005 Content-Type: text/plain; charset="utf-8" 'virXPathNumber' is not used currently, remove it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virxml.c | 33 --------------------------------- src/util/virxml.h | 4 ---- 3 files changed, 38 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0b0ccbafe5..61003eff39 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3699,7 +3699,6 @@ virXPathLongHex; virXPathLongLong; virXPathNode; virXPathNodeSet; -virXPathNumber; virXPathString; virXPathUInt; virXPathULong; diff --git a/src/util/virxml.c b/src/util/virxml.c index 0548a29e65..d99b060b63 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -90,39 +90,6 @@ virXPathString(const char *xpath, } -/** - * virXPathNumber: - * @xpath: the XPath string to evaluate - * @ctxt: an XPath context - * @value: the returned double value - * - * Convenience function to evaluate an XPath number - * - * Returns 0 in case of success in which case @value is set, - * or -1 if the evaluation failed. - */ -int -virXPathNumber(const char *xpath, - xmlXPathContextPtr ctxt, - double *value) -{ - g_autoptr(xmlXPathObject) obj =3D NULL; - - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathNumber()")); - return -1; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_NUMBER) || - (isnan(obj->floatval))) { - return -1; - } - - *value =3D obj->floatval; - return 0; -} - static int virXPathLongBase(const char *xpath, xmlXPathContextPtr ctxt, diff --git a/src/util/virxml.h b/src/util/virxml.h index febc7cbdfb..6d61d91497 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -51,10 +51,6 @@ char * virXPathString(const char *xpath, xmlXPathContextPtr ctxt); int -virXPathNumber(const char *xpath, - xmlXPathContextPtr ctxt, - double *value); -int virXPathInt(const char *xpath, xmlXPathContextPtr ctxt, int *value); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620934; cv=none; d=zohomail.com; s=zohoarc; b=Oj/v8/o0BJG1p40iZdEIC75R+irBo/60E4YhFF1pjomJsmMSHdejSyFGXOzXpXV573cG7Mf/C9nLHCxnURRHLlFk39LBzh89StjQgcEDRtxP8Fu4h89ykye/JqhpQyTJCr0sJYe3Ijpjg1F9CZWpa1gQciAO/JpBad3fCe02dGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620934; 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=Kb4VcqjMP3+HcfPsQac/XpIB9EmrG+38GOtSEuqrTRA=; b=aVqVhasF3luCT9TAw7nxwMbKx3X5HY7/5VP4msZl7gdjlD4prHVUDxP3dI10bRrmXfJVIDCAVxGUEd6ECg1We22HrCr5WKcEDg6z72oJiBjz4S6XyR9R8I2dneb4h2d/8BwU3OMCF3xsnVr0FfTewkEWRTrx8rYU8l3o8mGFB20= 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 1666620934469266.16957464206666; Mon, 24 Oct 2022 07:15:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-2ssSwh30ONmiRYgScYR_8g-1; Mon, 24 Oct 2022 10:15:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E508E857D13; Mon, 24 Oct 2022 14:14:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D152E40C6FA0; Mon, 24 Oct 2022 14:14:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A56A2194658F; Mon, 24 Oct 2022 14:14:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 34046194658F for ; Mon, 24 Oct 2022 14:14:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1894840C2143; Mon, 24 Oct 2022 14:14:53 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F85940C2064 for ; Mon, 24 Oct 2022 14:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620933; 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=Kb4VcqjMP3+HcfPsQac/XpIB9EmrG+38GOtSEuqrTRA=; b=VQW9xlILqfCBNBqpfe6gqVFdoxe15262X5oL+6tLw/5QBacjX4ccGoDf7egEJsGmDRccl3 gD68tIy/yGLRSng1+mGAgKQXOnSzqFX9VMsZJjH90z6MNWpkh2XJompadbCTUzmVYMDN+t C2rFlAxJmzPQNMU4wA8owkTAii8qFTE= X-MC-Unique: 2ssSwh30ONmiRYgScYR_8g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/43] util: xml: Unexport virXMLXPathContextNew Date: Mon, 24 Oct 2022 16:14:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1666620935938100001 Content-Type: text/plain; charset="utf-8" The function is now referenced only within util/virxml.c other callers should not use it directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virxml.c | 2 +- src/util/virxml.h | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 61003eff39..7150e87c38 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3690,7 +3690,6 @@ virXMLValidateAgainstSchema; virXMLValidatorFree; virXMLValidatorInit; virXMLValidatorValidate; -virXMLXPathContextNew; virXPathBoolean; virXPathContextNodeRestore; virXPathInt; diff --git a/src/util/virxml.c b/src/util/virxml.c index d99b060b63..de7b7a095d 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -48,7 +48,7 @@ struct virParserData { }; -xmlXPathContextPtr +static xmlXPathContextPtr virXMLXPathContextNew(xmlDocPtr xml) { xmlXPathContextPtr ctxt; diff --git a/src/util/virxml.h b/src/util/virxml.h index 6d61d91497..8a03077695 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -30,10 +30,6 @@ #include "virbuffer.h" #include "virenum.h" -xmlXPathContextPtr virXMLXPathContextNew(xmlDocPtr xml) - G_GNUC_WARN_UNUSED_RESULT; - - typedef enum { VIR_XML_PROP_NONE =3D 0, VIR_XML_PROP_REQUIRED =3D 1 << 0, /* Attribute may not be absent */ --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620931; cv=none; d=zohomail.com; s=zohoarc; b=eZGPl8g+GSAwEzyHx95ojiZO8b/j78Jv1RbR+VZxPgu3mDfOsExgam+FPX7mXzppkRgPvpyIz2JHGFQ3kLcE+5iBSL8gDoFxwwkfINDrVKMQ8ZtEibTlJr8H6a2363idoX/PoiNu0iRd7elX7q3upumRjcC4TP+zX6jQBOXwVmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620931; 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=6ga/3ylBavVz+zeVULhHSMmT+VJJBl77VwW1cnQoQQ4=; b=SL7z/jnHW+Y/WpVeoCPa8s5+4je8iMQDmMM4Ie67Xym5TAPta8kgvYhRURhHPXH79qJ1UXRG9yf+3vCtKd+pBKw+4QdrdmO1ozWzyyx4/OclecnRk3SaJZLmETvdVeTP2S7UpcCc6/Ec9ksanfUwD5hg2noEzSdAfm82QVlzSps= 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 1666620931041628.6966487472624; Mon, 24 Oct 2022 07:15:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-j23WDEC1ORyEhC_Ou9dt8w-1; Mon, 24 Oct 2022 10:15:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55BE586F13B; Mon, 24 Oct 2022 14:14:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03660C2C8C5; Mon, 24 Oct 2022 14:14:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EDAE21946594; Mon, 24 Oct 2022 14:14:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F16A3194658F for ; Mon, 24 Oct 2022 14:14:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E200140C2088; Mon, 24 Oct 2022 14:14:54 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 543C540C83AA for ; Mon, 24 Oct 2022 14:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620929; 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=6ga/3ylBavVz+zeVULhHSMmT+VJJBl77VwW1cnQoQQ4=; b=aGVlSIsAfLQih8o8dDPxa+f8TiQfsXfgkNySF0XZp359D9ldDGGuOULvLI0NI185xcK6M/ jICgybrNaGw6xrZzDxXDRMZ0oQLrukaBO+zoGlQPUN+IIhjSbZIY6SaLR3VTr4Z+9HdT6E b4X1XY7TMQu73+EvDebA1vpMV3rG1XE= X-MC-Unique: j23WDEC1ORyEhC_Ou9dt8w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/43] util: xml: Ensure proper header style in virxml.c Date: Mon, 24 Oct 2022 16:14:08 +0200 Message-Id: <9cd03c45e4c064e6c0b915e335e4a1fe6436a53d.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620931959100002 Content-Type: text/plain; charset="utf-8" Make the file use consistent header formatting and two line spacing between functions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index de7b7a095d..43b1ccfd24 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -121,6 +121,7 @@ virXPathLongBase(const char *xpath, return ret; } + /** * virXPathInt: * @xpath: the XPath string to evaluate @@ -150,6 +151,7 @@ virXPathInt(const char *xpath, return 0; } + /** * virXPathLong: * @xpath: the XPath string to evaluate @@ -170,6 +172,7 @@ virXPathLong(const char *xpath, return virXPathLongBase(xpath, ctxt, 10, value); } + /** * virXPathLongHex: * @xpath: the XPath string to evaluate @@ -191,6 +194,7 @@ virXPathLongHex(const char *xpath, return virXPathLongBase(xpath, ctxt, 16, value); } + static int virXPathULongBase(const char *xpath, xmlXPathContextPtr ctxt, @@ -222,6 +226,7 @@ virXPathULongBase(const char *xpath, return ret; } + /** * virXPathUInt: * @xpath: the XPath string to evaluate @@ -251,6 +256,7 @@ virXPathUInt(const char *xpath, return 0; } + /** * virXPathULong: * @xpath: the XPath string to evaluate @@ -271,6 +277,7 @@ virXPathULong(const char *xpath, return virXPathULongBase(xpath, ctxt, 10, value); } + /** * virXPathUHex: * @xpath: the XPath string to evaluate @@ -292,6 +299,7 @@ virXPathULongHex(const char *xpath, return virXPathULongBase(xpath, ctxt, 16, value); } + /** * virXPathULongLong: * @xpath: the XPath string to evaluate @@ -334,6 +342,7 @@ virXPathULongLong(const char *xpath, return ret; } + /** * virXPathLongLong: * @xpath: the XPath string to evaluate @@ -482,6 +491,7 @@ virXMLNodeContentString(xmlNodePtr node) return ret; } + static int virXMLPropEnumInternal(xmlNodePtr node, const char *name, @@ -967,6 +977,7 @@ virXPathBoolean(const char *xpath, return obj->boolval; } + /** * virXPathNode: * @xpath: the XPath string to evaluate @@ -998,6 +1009,7 @@ virXPathNode(const char *xpath, return obj->nodesetval->nodeTab[0]; } + /** * virXPathNodeSet: * @xpath: the XPath string to evaluate @@ -1133,6 +1145,7 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSE= D, ...) } } + /** * virXMLParseHelper: * @domcode: error domain of the caller, usually VIR_FROM_THIS @@ -1238,7 +1251,10 @@ virXMLParseHelper(int domcode, return g_steal_pointer(&xml); } -const char *virXMLPickShellSafeComment(const char *str1, const char *str2) + +const char * +virXMLPickShellSafeComment(const char *str1, + const char *str2) { if (str1 && !strpbrk(str1, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~") && !strstr(str1, "--")) @@ -1249,9 +1265,11 @@ const char *virXMLPickShellSafeComment(const char *s= tr1, const char *str2) return NULL; } -static int virXMLEmitWarning(int fd, - const char *name, - const char *cmd) + +static int +virXMLEmitWarning(int fd, + const char *name, + const char *cmd) { size_t len; const char *prologue =3D @@ -1300,6 +1318,7 @@ struct virXMLRewriteFileData { const char *xml; }; + static int virXMLRewriteFile(int fd, const char *path, @@ -1325,6 +1344,7 @@ virXMLRewriteFile(int fd, return 0; } + int virXMLSaveFile(const char *path, const char *warnName, @@ -1337,6 +1357,7 @@ virXMLSaveFile(const char *path, virXMLRewriteFile, &data); } + /** * virXMLNodeToString: convert an XML node ptr to an XML string * @@ -1586,9 +1607,10 @@ virXMLNodeSanitizeNamespaces(xmlNodePtr node) } -static void catchRNGError(void *ctx, - const char *msg, - ...) +static void +catchRNGError(void *ctx, + const char *msg, + ...) { virBuffer *buf =3D ctx; va_list args; @@ -1601,9 +1623,10 @@ static void catchRNGError(void *ctx, } -static void ignoreRNGError(void *ctx G_GNUC_UNUSED, - const char *msg G_GNUC_UNUSED, - ...) +static void +ignoreRNGError(void *ctx G_GNUC_UNUSED, + const char *msg G_GNUC_UNUSED, + ...) {} @@ -1772,6 +1795,7 @@ virXMLFormatElementInternal(virBuffer *buf, virBufferFreeAndReset(childBuf); } + /* same as virXMLFormatElement but outputs an empty element if @attrBuf and * @childBuf are both empty */ void --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620968; cv=none; d=zohomail.com; s=zohoarc; b=AkeJracB+qxKvp7Wge9Fzna/SSAS9VEsgi/jn097gQa53r47oAELubUxsDP/l2PB344aC/PUp6olBhrCEZM++2jrePKxxob9d/6KKy/bm47wYu3YkMirx4AFzCp9xMCHKLgyIfyAS6xa8IWCUKtG8aR/1jYz8ARRQYdxoJRUNao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620968; 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=xhHTc6W430LcEproiYHqjMI2UeaXkObxtI8JFVNUbcE=; b=W3DhAGEq2z75yxjn9nT8VKrCC+ubV0B3UA21IhG9EL+cV4RQpyaoMVMczeBmk6XTlxE9Hi4MycGd0jmz9P0RUeSBVNqCJGVwyLO6oD7VIxXfAT027TBRo8Y7lQoI8Hx00MXXi0uOprbTYhjkzRQE1NtRF1RtJog4o2fAFckN6QU= 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 1666620968875345.88889638283433; Mon, 24 Oct 2022 07:16:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-sHNnngcLN5qN8UGnu_f6tA-1; Mon, 24 Oct 2022 10:15:20 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8ED64800186; Mon, 24 Oct 2022 14:14:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4501F1415117; Mon, 24 Oct 2022 14:14:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 361D2194658F; Mon, 24 Oct 2022 14:14:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 370321946595 for ; Mon, 24 Oct 2022 14:14:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1B23C40C2143; Mon, 24 Oct 2022 14:14:56 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F39740C2088 for ; Mon, 24 Oct 2022 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620966; 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=xhHTc6W430LcEproiYHqjMI2UeaXkObxtI8JFVNUbcE=; b=G7Jd18pGd1BCKeMS6vD3G7H6CxK8ByUqWIibYu24xROAB6U57ixgsI6mL0rjCljO24Li1b wVe/zyC9kyODRyQZXq1cdl7quya/4KkFGjBmp8wCbAPTsG78nGwufi1KF2g8FV6ozOmN8T /q4njOKjMJ06BCvdQU1hotfb8AddZGE= X-MC-Unique: sHNnngcLN5qN8UGnu_f6tA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/43] util: xml: Use consistent naming for RNG validation error handling functions Date: Mon, 24 Oct 2022 16:14:09 +0200 Message-Id: <1943d146e5a1855185149626adceb0b79a79e7ca.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1666620970408100001 Content-Type: text/plain; charset="utf-8" Rename 'catchRNGError' to 'virXMLValidatorRNGErrorCatch' and 'ignoreRNGError' to 'virXMLValidatorRNGErrorIgnore'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 43b1ccfd24..16e7ef9808 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1608,9 +1608,9 @@ virXMLNodeSanitizeNamespaces(xmlNodePtr node) static void -catchRNGError(void *ctx, - const char *msg, - ...) +virXMLValidatorRNGErrorCatch(void *ctx, + const char *msg, + ...) { virBuffer *buf =3D ctx; va_list args; @@ -1624,9 +1624,9 @@ catchRNGError(void *ctx, static void -ignoreRNGError(void *ctx G_GNUC_UNUSED, - const char *msg G_GNUC_UNUSED, - ...) +virXMLValidatorRNGErrorIgnore(void *ctx G_GNUC_UNUSED, + const char *msg G_GNUC_UNUSED, + ...) {} @@ -1648,8 +1648,8 @@ virXMLValidatorInit(const char *schemafile) } xmlRelaxNGSetParserErrors(validator->rngParser, - catchRNGError, - ignoreRNGError, + virXMLValidatorRNGErrorCatch, + virXMLValidatorRNGErrorIgnore, &validator->buf); if (!(validator->rng =3D xmlRelaxNGParse(validator->rngParser))) { @@ -1668,8 +1668,8 @@ virXMLValidatorInit(const char *schemafile) } xmlRelaxNGSetValidErrors(validator->rngValid, - catchRNGError, - ignoreRNGError, + virXMLValidatorRNGErrorCatch, + virXMLValidatorRNGErrorIgnore, &validator->buf); return validator; --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620929; cv=none; d=zohomail.com; s=zohoarc; b=jjlBFRjdPPBgADhlDFj210LAjzgykt4CvjXALSJ9NcC1miSszQ8G9L9ZMxU83aqKqD39e+dlqc4rbeYO1WjwxzK3fUV/mPWrk1kOWX4shyFnwruEbMSEd64Mow3aIh3ueefYBEq4AOUnhgcj0DB9Q+6yFHa60XAW4FrEXrjY+vo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620929; 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=1tUM96rnrrmVjhfH9HTXTMtKy/ZdiWxBgUjd+Jeh1cw=; b=nG3FW8nOckbtwLxMuG6vfcFLWKmQ5kw+5eEoCslCfg0m9KCEb5S2LIJhtO2ivTvde20tFOn/iYuymd9eVRNmPiLVoZgbTzLW+dRdiEnYX3LF01275lJI0iyvrBdboZqECjt0XJGO/gWNR8VyM57CdGCdtSd+J4fuFywi0N6PfQM= 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 1666620929917602.0783595903902; Mon, 24 Oct 2022 07:15:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-AhTbK3GiNvKO8Nq5AhsxUw-1; Mon, 24 Oct 2022 10:15:18 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A7FF3C0F80A; Mon, 24 Oct 2022 14:14:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 169B7C158CF; Mon, 24 Oct 2022 14:14:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EA6701946594; Mon, 24 Oct 2022 14:14:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40D86194658D for ; Mon, 24 Oct 2022 14:14:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 181F440C2089; Mon, 24 Oct 2022 14:14:58 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 430F540C2144 for ; Mon, 24 Oct 2022 14:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620928; 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=1tUM96rnrrmVjhfH9HTXTMtKy/ZdiWxBgUjd+Jeh1cw=; b=h6yxldtFJpZUA/AZrje5OHXwZ3UjJFyJqA0lPkBWbTLOO3gU0ac1goX4/vImLUC5TdQCFU NRYDQr1/iMhtlFAQ9jwGJwcAJxmw+xAYJjydNIGc0Fo2/NT6fV57tpRY8HiufaiXtG4Vcz w3cSQnBSKa3fcS7g1E3cqa61aZ/+a8E= X-MC-Unique: AhTbK3GiNvKO8Nq5AhsxUw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/43] util: xml: Remove unused 'virXPathLongHex' Date: Mon, 24 Oct 2022 16:14:10 +0200 Message-Id: <5a1ccdeb15e352d5503d8b6e20c36e68897d5cd2.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620931934100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virxml.c | 22 ---------------------- src/util/virxml.h | 4 ---- 3 files changed, 27 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7150e87c38..c6445dedcb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3694,7 +3694,6 @@ virXPathBoolean; virXPathContextNodeRestore; virXPathInt; virXPathLong; -virXPathLongHex; virXPathLongLong; virXPathNode; virXPathNodeSet; diff --git a/src/util/virxml.c b/src/util/virxml.c index 16e7ef9808..e771471dd7 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -173,28 +173,6 @@ virXPathLong(const char *xpath, } -/** - * virXPathLongHex: - * @xpath: the XPath string to evaluate - * @ctxt: an XPath context - * @value: the returned long value - * - * Convenience function to evaluate an XPath number - * according to a base of 16 - * - * Returns 0 in case of success in which case @value is set, - * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have a long format. - */ -int -virXPathLongHex(const char *xpath, - xmlXPathContextPtr ctxt, - long *value) -{ - return virXPathLongBase(xpath, ctxt, 16, value); -} - - static int virXPathULongBase(const char *xpath, xmlXPathContextPtr ctxt, diff --git a/src/util/virxml.h b/src/util/virxml.h index 8a03077695..fe07e2d223 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -71,10 +71,6 @@ virXPathLongLong(const char *xpath, xmlXPathContextPtr ctxt, long long *value); int -virXPathLongHex(const char *xpath, - xmlXPathContextPtr ctxt, - long *value); -int virXPathULongHex(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620926; cv=none; d=zohomail.com; s=zohoarc; b=bQsuZ46DKcD7dP58ocbUA+fN790jcnSr67eTIZc1mCmgHYtzrxv/O4fZolKh53iak8/ZNDkvHT9fj3CDHQ98iYa49kNqpFZwgxz3/VlOTV2yoI0ctZM/J9KUAIKncTkYKrUTn2A4yvuH5sIkdstM701TGfzkPTZoK79RUJIR0+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620926; 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=WkgYXm0/6XNi/eJcxxDhRHz2Hxahdc1A+R+4+n6WzvI=; b=GNdnugiLPqfcoXhgZ4FXvSF1qZ3rXp+NWrtfvorIgs1G8mzpYOSn4XIEfpTPinzPUtOqtmFw1YAOijsFZV4Rco5+rhhBP2GkaQ2rhc3lcg/3zNQ/eR6pAA6CRLdkUUuBZvEIwTdOOMFgpmavI6psTkdjamLAs7ZS1QzKHYfvAWs= 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 1666620926907874.7217950983562; Mon, 24 Oct 2022 07:15:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-mwmtQtpZM2WfQLBLoSkBBA-1; Mon, 24 Oct 2022 10:15:22 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69416832D60; Mon, 24 Oct 2022 14:15:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55AC71415114; Mon, 24 Oct 2022 14:15:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3DE361946594; Mon, 24 Oct 2022 14:15:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 72FFA1946595 for ; Mon, 24 Oct 2022 14:14:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 68F6340C83AD; Mon, 24 Oct 2022 14:14:59 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB2CD40C2088 for ; Mon, 24 Oct 2022 14:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620925; 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=WkgYXm0/6XNi/eJcxxDhRHz2Hxahdc1A+R+4+n6WzvI=; b=aYywplWVD+alPGJSbpSRr4vffO0uND/mdE0iqUg7i5dYtpvgsQ23m/ml3SZf2i4kfDLlM5 Mx0FFswNO1kTslVk88AvvmFpRZKVoKrvHv1Y2CMlUYpexhiBR0m4GVAdOCinpTu/aVkCIm l989QH2PNkuDuCB0lfEUm+EKAnyx/zE= X-MC-Unique: mwmtQtpZM2WfQLBLoSkBBA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/43] virNodeDevCapsDefParseULong: Use virXPathUInt instead of virXPathULong Date: Mon, 24 Oct 2022 16:14:11 +0200 Message-Id: <5876a3d64391c26a41ac9d16aed0c6aabcd41ca3.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1666620927946100001 Content-Type: text/plain; charset="utf-8" Fix the function argument to properly spell out 'unsigned int' and use virXPathUInt instead of virXPathULong and a temporary value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index bdfbbab434..bb10b9dabe 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -833,15 +833,14 @@ virNodeDevCapsDefParseIntOptional(const char *xpath, static int virNodeDevCapsDefParseULong(const char *xpath, xmlXPathContextPtr ctxt, - unsigned *value, + unsigned int *value, virNodeDeviceDef *def, const char *missing_error_fmt, const char *invalid_error_fmt) { int ret; - unsigned long val; - ret =3D virXPathULong(xpath, ctxt, &val); + ret =3D virXPathUInt(xpath, ctxt, value); if (ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, ret =3D=3D -1 ? missing_error_fmt : invalid_error_f= mt, @@ -849,7 +848,6 @@ virNodeDevCapsDefParseULong(const char *xpath, return -1; } - *value =3D val; return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620940; cv=none; d=zohomail.com; s=zohoarc; b=HtI+8P5Uau+srmAU+3E3X0YnNofvi5JLC0sd5y0XfBSVxe4jhGvyDLIeXY7yoe+hbUcYfC9xegVScMslTH8cCMsNCaJLlBXjDuyjdfc2LQUn2zT1yCvk0QRAdId+a5SYXG8YInl7nlG8oMgEgG5d4Xo7Xy2kHZzbuJWYFYbFw3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620940; 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=wLUB7yCNLjR/JdS+WD47kcS4rB/1YefHxaElFPn3IWo=; b=ZTWe17wmj3copMI4BYT1dA736XrMc2Lm2vctn0RZ0qWUwgyUPveFcDgeC21qx4WKOA/Y4x4BfjTkwLyQfVYbknOlt7ysUWDgZTWE/KvACetQMV1s5hWxyjLpLAtvzszpYFRIcOODi9RQfSKvQyx0OZ4ShC5CVvNozQMTggPj84c= 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 1666620940536755.8669284374589; Mon, 24 Oct 2022 07:15:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-0NrKfd5JNY6QCKu6-5-wqw-1; Mon, 24 Oct 2022 10:15:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADC221C08972; Mon, 24 Oct 2022 14:15:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B971C15BB2; Mon, 24 Oct 2022 14:15:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 898671946595; Mon, 24 Oct 2022 14:15:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 22C5D1946595 for ; Mon, 24 Oct 2022 14:15:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1674A40C2140; Mon, 24 Oct 2022 14:15:01 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 435C040C2088 for ; Mon, 24 Oct 2022 14:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620939; 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=wLUB7yCNLjR/JdS+WD47kcS4rB/1YefHxaElFPn3IWo=; b=Wz0qCSfROfCefeurzF37K4wnpIBmmKYA08JDiEha4gSZBJde2nSabg/M4YKwwA+9O7uhmc R7UCvacUum1GaDU9QSKuuO2M80mZkaHXP5zxa2bhGVYzQ3XMaZMZ7mNuq4/IKJBJMZiQbe 1vuQpzzbkIoIjibHfsDzsIubtx+inU8= X-MC-Unique: 0NrKfd5JNY6QCKu6-5-wqw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/43] conf: node_device: Rename virNodeDevCapsDefParseULong to virNodeDevCapsDefParseUInt Date: Mon, 24 Oct 2022 16:14:12 +0200 Message-Id: <4bc1a79a8a75c3ddfde9666721287b5feec2f75e.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620942056100001 Content-Type: text/plain; charset="utf-8" The function parses an unsigned int so rename it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 132 ++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index bb10b9dabe..9c0a27b9f0 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -831,12 +831,12 @@ virNodeDevCapsDefParseIntOptional(const char *xpath, static int -virNodeDevCapsDefParseULong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value, - virNodeDeviceDef *def, - const char *missing_error_fmt, - const char *invalid_error_fmt) +virNodeDevCapsDefParseUInt(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int *value, + virNodeDeviceDef *def, + const char *missing_error_fmt, + const char *invalid_error_fmt) { int ret; @@ -1502,28 +1502,28 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, - &scsi->host, def, - _("no SCSI host ID supplied for '%s'"), - _("invalid SCSI host ID supplied for '= %s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./host[1])", ctxt, + &scsi->host, def, + _("no SCSI host ID supplied for '%s'"), + _("invalid SCSI host ID supplied for '%= s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &scsi->bus, def, - _("no SCSI bus ID supplied for '%s'"), - _("invalid SCSI bus ID supplied for '%= s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + &scsi->bus, def, + _("no SCSI bus ID supplied for '%s'"), + _("invalid SCSI bus ID supplied for '%s= '")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./target[1])", ctxt, - &scsi->target, def, - _("no SCSI target ID supplied for '%s'= "), - _("invalid SCSI target ID supplied for= '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./target[1])", ctxt, + &scsi->target, def, + _("no SCSI target ID supplied for '%s'"= ), + _("invalid SCSI target ID supplied for = '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./lun[1])", ctxt, - &scsi->lun, def, - _("no SCSI LUN ID supplied for '%s'"), - _("invalid SCSI LUN ID supplied for '%= s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./lun[1])", ctxt, + &scsi->lun, def, + _("no SCSI LUN ID supplied for '%s'"), + _("invalid SCSI LUN ID supplied for '%s= '")) < 0) return -1; scsi->type =3D virXPathString("string(./type[1])", ctxt); @@ -1615,10 +1615,10 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ct= xt, ctxt->node =3D node; if (create =3D=3D EXISTING_DEVICE) { - if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, - &scsi_host->host, def, - _("no SCSI host ID supplied for '%= s'"), - _("invalid SCSI host ID supplied f= or '%s'")) < 0) { + if (virNodeDevCapsDefParseUInt("number(./host[1])", ctxt, + &scsi_host->host, def, + _("no SCSI host ID supplied for '%s= '"), + _("invalid SCSI host ID supplied fo= r '%s'")) < 0) { return -1; } /* Optional unique_id value */ @@ -1775,28 +1775,28 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPt= r ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseULong("number(./number[1])", ctxt, - &usb_if->number, def, - _("no USB interface number supplied fo= r '%s'"), - _("invalid USB interface number suppli= ed for '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./number[1])", ctxt, + &usb_if->number, def, + _("no USB interface number supplied for= '%s'"), + _("invalid USB interface number supplie= d for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./class[1])", ctxt, - &usb_if->klass, def, - _("no USB interface class supplied for= '%s'"), - _("invalid USB interface class supplie= d for '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./class[1])", ctxt, + &usb_if->klass, def, + _("no USB interface class supplied for = '%s'"), + _("invalid USB interface class supplied= for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./subclass[1])", ctxt, - &usb_if->subclass, def, - _("no USB interface subclass supplied = for '%s'"), - _("invalid USB interface subclass supp= lied for '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./subclass[1])", ctxt, + &usb_if->subclass, def, + _("no USB interface subclass supplied f= or '%s'"), + _("invalid USB interface subclass suppl= ied for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./protocol[1])", ctxt, - &usb_if->protocol, def, - _("no USB interface protocol supplied = for '%s'"), - _("invalid USB interface protocol supp= lied for '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./protocol[1])", ctxt, + &usb_if->protocol, def, + _("no USB interface protocol supplied f= or '%s'"), + _("invalid USB interface protocol suppl= ied for '%s'")) < 0) return -1; usb_if->description =3D virXPathString("string(./description[1])", ctx= t); @@ -1839,16 +1839,16 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &usb_dev->bus, def, - _("no USB bus number supplied for '%s'= "), - _("invalid USB bus number supplied for= '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + &usb_dev->bus, def, + _("no USB bus number supplied for '%s'"= ), + _("invalid USB bus number supplied for = '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseULong("number(./device[1])", ctxt, - &usb_dev->device, def, - _("no USB device number supplied for '= %s'"), - _("invalid USB device number supplied = for '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./device[1])", ctxt, + &usb_dev->device, def, + _("no USB device number supplied for '%= s'"), + _("invalid USB device number supplied f= or '%s'")) < 0) return -1; if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, @@ -2084,28 +2084,28 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, pci_dev->klass =3D -1; } - if (virNodeDevCapsDefParseULong("number(./domain[1])", ctxt, - &pci_dev->domain, def, - _("no PCI domain ID supplied for '%s'"= ), - _("invalid PCI domain ID supplied for = '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./domain[1])", ctxt, + &pci_dev->domain, def, + _("no PCI domain ID supplied for '%s'"), + _("invalid PCI domain ID supplied for '= %s'")) < 0) goto out; - if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt, - &pci_dev->bus, def, - _("no PCI bus ID supplied for '%s'"), - _("invalid PCI bus ID supplied for '%s= '")) < 0) + if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + &pci_dev->bus, def, + _("no PCI bus ID supplied for '%s'"), + _("invalid PCI bus ID supplied for '%s'= ")) < 0) goto out; - if (virNodeDevCapsDefParseULong("number(./slot[1])", ctxt, - &pci_dev->slot, def, - _("no PCI slot ID supplied for '%s'"), - _("invalid PCI slot ID supplied for '%= s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./slot[1])", ctxt, + &pci_dev->slot, def, + _("no PCI slot ID supplied for '%s'"), + _("invalid PCI slot ID supplied for '%s= '")) < 0) goto out; - if (virNodeDevCapsDefParseULong("number(./function[1])", ctxt, - &pci_dev->function, def, - _("no PCI function ID supplied for '%s= '"), - _("invalid PCI function ID supplied fo= r '%s'")) < 0) + if (virNodeDevCapsDefParseUInt("number(./function[1])", ctxt, + &pci_dev->function, def, + _("no PCI function ID supplied for '%s'= "), + _("invalid PCI function ID supplied for= '%s'")) < 0) goto out; if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt, --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621000; cv=none; d=zohomail.com; s=zohoarc; b=akzP0nDlY8XSPDNSR3YtmJ+ePS3GO5FF59NKn/66TwMv1yxWEuyAc2gelUURb2pr2vs3QkH1bYy/DGfSs3qvaTVxUxvQY0ptW2sCUyND4AdNYfSbjtnyXJaq8VWBOdU70ay4dZBlxUhK/sEwZxWP/pr4ptxiBv+zj/xqotV1swA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621000; 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=I7axGdy4cUFIROdGxkLM1UcLQQUIoiHaQbZQlmy3fmc=; b=Tysia7bj29jwFCKawW9m6CtwxTZekOsR4glp4MzFeBBpm4XGOInhfs7UjUQoSCDWFZe6SNsa4fZnnkiZ+ToMVBhUpDV0HYCVtFHdQta0Nq/46bj41d7cT4+TKjUQXR97QXLWDo5fguEWFPIShzIfj1QNwc9fp3y3Ch8jL1e4EkY= 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 1666621000118926.6114195394659; Mon, 24 Oct 2022 07:16:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-9ltGK36ZMAmUkSW3qmzbHw-1; Mon, 24 Oct 2022 10:16:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 017592A59558; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF2C342222; Mon, 24 Oct 2022 14:15:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CF99A194658F; Mon, 24 Oct 2022 14:15:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 59D7C194658D for ; Mon, 24 Oct 2022 14:15:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4A24F40C2088; Mon, 24 Oct 2022 14:15:04 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B32B340C2144 for ; Mon, 24 Oct 2022 14:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620999; 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=I7axGdy4cUFIROdGxkLM1UcLQQUIoiHaQbZQlmy3fmc=; b=MHctZf/cukrY4oGh1Qz0T/nVAOpRDlP9Jat6l6zoZNUFg4DYE0NcBmelui+zBnzR5uZJuT JFdOxKohUJO+1AAWmIi/sKEo7K8GmnNxlr2eno7ZLZRJb87sXH1zGzpEKyEzbtFomWJyeV juqSpywrN48bsxMii3LCINdulIeHKis= X-MC-Unique: 9ltGK36ZMAmUkSW3qmzbHw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/43] virNodeDeviceCapPCIDefFormat: Use %u for unsigned values Date: Mon, 24 Oct 2022 16:14:13 +0200 Message-Id: <3866c09a009be349bb213922361bf132d0961f00.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1666621000556100007 Content-Type: text/plain; charset="utf-8" 'bus', 'slot' and 'function' are unsigned int variables parsed as unsigned int, but were formated as signed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 6 +++--- tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9c0a27b9f0..b079c3713d 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -323,10 +323,10 @@ virNodeDeviceCapPCIDefFormat(virBuffer *buf, virBufferAsprintf(buf, "0x%.6x\n", data->pci_dev.kl= ass); virBufferAsprintf(buf, "%d\n", data->pci_dev.domain); - virBufferAsprintf(buf, "%d\n", data->pci_dev.bus); - virBufferAsprintf(buf, "%d\n", + virBufferAsprintf(buf, "%u\n", data->pci_dev.bus); + virBufferAsprintf(buf, "%u\n", data->pci_dev.slot); - virBufferAsprintf(buf, "%d\n", + virBufferAsprintf(buf, "%u\n", data->pci_dev.function); virBufferAsprintf(buf, "pci_dev.product); diff --git a/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml b/tes= ts/nodedevschemadata/pci_0000_00_02_0_header_type.xml index 387fce7051..df620dc64f 100644 --- a/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml +++ b/tests/nodedevschemadata/pci_0000_00_02_0_header_type.xml @@ -4,7 +4,7 @@ 0xffffff 0 - 0 + 4294967295 2 0 4th Gen Core Processor Integrated Graphics Cont= roller --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620990; cv=none; d=zohomail.com; s=zohoarc; b=bWi5J8IQgOMy6ZVq57ZXnd3s+3ozJvbqi/CHUwknL2hmw2FG9fjToxIJO7xvHawkJ+SmeZ0+Xut2HRoTWnWOH2BYFq50hMhbjY0ovuv8QLcERj58kIUCw5ZBDkmJthYBlZiqLvCTruQ4OMYBXNsq7rRfBhJ7A6qxa07YWpjxzAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620990; 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=s0k+RgqLQyQCQ3YAA4h7Ap4DRY5nuROyBGUeyFlD9AM=; b=aGgLAShVuD/FmxUDa+ZiJozV9Bi0B8GetSjTPQJgR29xwZVtRk3w81zGpVJ2UHXVp3lhiS9eS6mBHeTp+DppkeBSL1EQLK67y4fd9A4tft8ofzSQyeWDk1X9hgkklqCklH+GxeQrNHzxOEXsTjdX/me3pSSCuz2S/LPhSvK+zUc= 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 1666620990891537.3390792616646; Mon, 24 Oct 2022 07:16:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-SXhnCrLdOvadjaiuTBjYXg-1; Mon, 24 Oct 2022 10:16:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A84F2A5954B; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 339DC40C6F75; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2685F194658F; Mon, 24 Oct 2022 14:15:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6F505194658F for ; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5527E40C2143; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF3DD40C2089 for ; Mon, 24 Oct 2022 14:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620989; 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=s0k+RgqLQyQCQ3YAA4h7Ap4DRY5nuROyBGUeyFlD9AM=; b=XjV74paIvXvVzE772k5W5oWAkV6iRsa3gKf/JuTDdgDmCIcmHs4d+WoaIdupS4tQwNVM2d ehN76HoAODemySqcf8VhN0d27Y4lMn1vPguMLYV8DayWGa1kqMlN4RZ6nWlRlLj5aI5F/4 +MwrfcV0WF0g0u8dxeaW4Fz3ZoDtNLs= X-MC-Unique: SXhnCrLdOvadjaiuTBjYXg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/43] conf: Always use 'string()' conversion with virXPath(U)LongLong Date: Mon, 24 Oct 2022 16:14:14 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1666620992521100004 Content-Type: text/plain; charset="utf-8" When the 'string()' conversion is used the number is parsed inside libvirt by our internal helpers which work on integers in contrast to when 'number()' is used and libxml2 uses a 'double' variable internally. On the upper extremes of the 64 bit variables the doulbe precision variable doesn't have enough precision to represent each distinct integer and thus could cause problems. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 +++--- src/conf/node_device_conf.c | 4 ++-- src/conf/storage_conf.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7dba65cfeb..7984a15c46 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18103,10 +18103,10 @@ virDomainDefClockParse(virDomainDef *def, break; case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - if (virXPathLongLong("number(./clock/@adjustment)", ctxt, + if (virXPathLongLong("string(./clock/@adjustment)", ctxt, &def->clock.data.variable.adjustment) < 0) def->clock.data.variable.adjustment =3D 0; - if (virXPathLongLong("number(./clock/@adjustment0)", ctxt, + if (virXPathLongLong("string(./clock/@adjustment0)", ctxt, &def->clock.data.variable.adjustment0) < 0) def->clock.data.variable.adjustment0 =3D 0; tmp =3D virXPathString("string(./clock/@basis)", ctxt); @@ -18132,7 +18132,7 @@ virDomainDefClockParse(virDomainDef *def, break; case VIR_DOMAIN_CLOCK_OFFSET_ABSOLUTE: - if (virXPathULongLong("number(./clock/@start)", ctxt, + if (virXPathULongLong("string(./clock/@start)", ctxt, &def->clock.data.starttime) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'start' attribute for clock with off= set=3D'absolute'")); diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index b079c3713d..3bff17dae2 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1463,7 +1463,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, storage->media_label =3D virXPathString("string(./media_label[= 1])", ctxt); val =3D 0; - if (virNodeDevCapsDefParseULongLong("number(./media_size[1])",= ctxt, &val, def, + if (virNodeDevCapsDefParseULongLong("string(./media_size[1])",= ctxt, &val, def, _("no removable media size= supplied for '%s'"), _("invalid removable media= size supplied for '%s'")) < 0) { return -1; @@ -1481,7 +1481,7 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, if (!(storage->flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE)) { val =3D 0; - if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &va= l, def, + if (virNodeDevCapsDefParseULongLong("string(./size[1])", ctxt, &va= l, def, _("no size supplied for '%s'"), _("invalid size supplied for '= %s'")) < 0) return -1; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 0f4fe1451e..b570679de2 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -720,7 +720,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->uid =3D (uid_t) -1; } else { /* We previously could output -1, so continue to parse it */ - if (virXPathLongLong("number(./owner)", ctxt, &val) < 0 || + if (virXPathLongLong("string(./owner)", ctxt, &val) < 0 || ((uid_t)val !=3D val && val !=3D -1)) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -735,7 +735,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt, perms->gid =3D (gid_t) -1; } else { /* We previously could output -1, so continue to parse it */ - if (virXPathLongLong("number(./group)", ctxt, &val) < 0 || + if (virXPathLongLong("string(./group)", ctxt, &val) < 0 || ((gid_t) val !=3D val && val !=3D -1)) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621158; cv=none; d=zohomail.com; s=zohoarc; b=Hi4uyBHNO0+m/+7PmVpJTPhxGBecO8KGT7Zn7FCnl8eQEe1feUJvG1s5g+h+kNQL85ZiZUmJeOyyeeTZGpRqwOzS5P7P2+at6cSjn1FrnEUQNvrQ9iV8EupBHrPy3zF6Ol4DxfyVnVMe9bFBAbr5JH+2wPXPkMzHe9NeKFj4Ihw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621158; 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=xy2k7Bh2F2SCV1+cZFZhflGEEFQgONOMbTf5f09qK0Q=; b=SJ7GHebO6F/SY4i5RMt7YZ32BHuBi0XaH+a5MylVeLQiR+GFFD6P1rVHxpi/yuPrTEz9GA5j0ImMr8rnHkdV/SilvjVEBjOsyiBNraVK1GG83OoH1JDQD0mp9xgQRVW2updaAUK4alslZ1fRvRU0viJwCu4O/cfGG9O6f5GLWqc= 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 1666621158735534.794096715904; Mon, 24 Oct 2022 07:19:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-264-gyxEO4ZsPje3zZNd4IH_KA-1; Mon, 24 Oct 2022 10:15:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6B25857F92; Mon, 24 Oct 2022 14:15:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3BF8C16922; Mon, 24 Oct 2022 14:15:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 98EA41946594; Mon, 24 Oct 2022 14:15:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D517B194658D for ; Mon, 24 Oct 2022 14:15:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C785C40C2140; Mon, 24 Oct 2022 14:15:08 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44BFE40C83AA for ; Mon, 24 Oct 2022 14:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621157; 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=xy2k7Bh2F2SCV1+cZFZhflGEEFQgONOMbTf5f09qK0Q=; b=YL3shmOcXpKc4YcjzdhydlpOd6R4ICp+sRZPNu6nAz/zDiYX6SNio+p80D1HCv/n+E2uO0 mCDvsZAiKos+cNtTShHtF6iVUSYVvlFmn7Tr4kvwv7gPd0lZ2Cmuq9Y6P0uYWpg1YGcaV+ KTFFLId3F9mIAgaNJy1VToHmOVeh4NI= X-MC-Unique: gyxEO4ZsPje3zZNd4IH_KA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/43] util: xml: Extract XPath evaluation for strings Date: Mon, 24 Oct 2022 16:14:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666621159640100001 Content-Type: text/plain; charset="utf-8" Extract the internals of virXPathString which evaluate the XPath and validate that the returned object is a string into a new helper named 'virXPathEvalString'. The function will be later reused in the number XPath evaluation functions. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index e771471dd7..aec475ccfd 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -60,6 +60,34 @@ virXMLXPathContextNew(xmlDocPtr xml) } +static xmlXPathObject * +virXPathEvalString(const char *xpath, + xmlXPathContextPtr ctxt) +{ + g_autoptr(xmlXPathObject) obj =3D NULL; + + if (!xpath) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing XPath expr= ession")); + return NULL; + } + + if (!ctxt) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing XPath cont= ext")); + return NULL; + } + + if (!(obj =3D xmlXPathEval(BAD_CAST xpath, ctxt))) + return NULL; + + if (obj->type !=3D XPATH_STRING || + !obj->stringval || + obj->stringval[0] =3D=3D '\0') + return NULL; + + return g_steal_pointer(&obj); +} + + /** * virXPathString: * @xpath: the XPath string to evaluate @@ -76,16 +104,9 @@ virXPathString(const char *xpath, { g_autoptr(xmlXPathObject) obj =3D NULL; - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathString()")); + if (!(obj =3D virXPathEvalString(xpath, ctxt))) return NULL; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj =3D=3D NULL) || (obj->type !=3D XPATH_STRING) || - (obj->stringval =3D=3D NULL) || (obj->stringval[0] =3D=3D 0)) { - return NULL; - } + return g_strdup((char *)obj->stringval); } --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621088; cv=none; d=zohomail.com; s=zohoarc; b=E8FddczwuwMxG1utVpA/BtJRrsKDV29qBWJJshq2WvyE571WgeBKL9vlCa7/C01qjA2Zvdf4HJG1jaRXeYLf+ZNKdOFbk70SXa7YWYuoDqneeunDkun3SfJoaQyh5sXQQrDvHC2qC0lW+FR1GiWN1u9am2Te+tpvyEF1PDz9wNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621088; 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=q/R0qOEeQz7FAUstTmL2hF9X+fVxtIDPSf1PAKwPiQw=; b=JBIK6puEEmV+itCmWBO8gdeuOeya9DDrwyRFpVpTFBcoyg/B6G31Y9G1lJOMc+DK7JGj3yrhsFWS+aeMA1c58F0DN3my0JYTKI0kzU7gJJ1t3WnRNNVtBoRu9KbmPlSmUcJNtZZrxIqnldsJpm1sP7JvUymeXSghldxjK69b+rU= 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 1666621088653526.5403024728299; Mon, 24 Oct 2022 07:18:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-JYIgCROrNNCsMZnlfv_MAQ-1; Mon, 24 Oct 2022 10:15:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BA911012471; Mon, 24 Oct 2022 14:15:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1880F2166B34; Mon, 24 Oct 2022 14:15:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E29A61946595; Mon, 24 Oct 2022 14:15:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 00DCC19465B2 for ; Mon, 24 Oct 2022 14:15:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DA96640C83C5; Mon, 24 Oct 2022 14:15:09 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30A3740C2064 for ; Mon, 24 Oct 2022 14:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621087; 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=q/R0qOEeQz7FAUstTmL2hF9X+fVxtIDPSf1PAKwPiQw=; b=UqoRQvUOAtvXAYAb+YgvS+CB6pWs89suNqt0vwnJKMSwbVnYTinBSUdECOI9WFXRwjJxIK xdMyCBA/Twd5tDM/EsJvozyRXsfa2OplQr4EORJvNSf8Pfs/ngdHMrqfgo7c+uCTLVSHpf kvfRQqipQRds+tZVT/8JMteyhHnR4g0= X-MC-Unique: JYIgCROrNNCsMZnlfv_MAQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/43] util: xml: Remove double->(u)ll conversion in virXPath(U)LongLong Date: Mon, 24 Oct 2022 16:14:16 +0200 Message-Id: <5828129fae29faccd28bb28de4ebfcefa10dac69.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1666621089369100001 Content-Type: text/plain; charset="utf-8" The conversion from double is not precise enough at the extremes so it must not be used. Spell out that the callers are required to use a string() conversion in the XPath expression and remove the code path handling the direct conversion from numbers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 60 ++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index aec475ccfd..35c0340779 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -303,13 +303,15 @@ virXPathULongHex(const char *xpath, * virXPathULongLong: * @xpath: the XPath string to evaluate * @ctxt: an XPath context - * @value: the returned long long value + * @value: the returned unsigned long long value * - * Convenience function to evaluate an XPath number + * Convenience function to evaluate an XPath number. The @xpath expression + * must ensure that the evaluated value is returned as a string (use the + * 'string()' conversion in the expression). * * Returns 0 in case of success in which case @value is set, * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have a long format. + * value doesn't have a unsigned long long format. */ int virXPathULongLong(const char *xpath, @@ -317,28 +319,14 @@ virXPathULongLong(const char *xpath, unsigned long long *value) { g_autoptr(xmlXPathObject) obj =3D NULL; - int ret =3D 0; - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathULong()")); + if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && - (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { - if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0) - ret =3D -2; - } else if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_NUMBER) && - (!(isnan(obj->floatval)))) { - *value =3D (unsigned long long) obj->floatval; - if (*value !=3D obj->floatval) - ret =3D -2; - } else { - ret =3D -1; - } - return ret; + if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0) + return -2; + + return 0; } @@ -348,7 +336,9 @@ virXPathULongLong(const char *xpath, * @ctxt: an XPath context * @value: the returned long long value * - * Convenience function to evaluate an XPath number + * Convenience function to evaluate an XPath number. The @xpath expression + * must ensure that the evaluated value is returned as a string (use the + * 'string()' conversion in the expression). * * Returns 0 in case of success in which case @value is set, * or -1 if the XPath evaluation failed or -2 if the @@ -360,28 +350,14 @@ virXPathLongLong(const char *xpath, long long *value) { g_autoptr(xmlXPathObject) obj =3D NULL; - int ret =3D 0; - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathLongLong()")); + if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && - (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { - if (virStrToLong_ll((char *) obj->stringval, NULL, 10, value) < 0) - ret =3D -2; - } else if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_NUMBER) && - (!(isnan(obj->floatval)))) { - *value =3D (long long) obj->floatval; - if (*value !=3D obj->floatval) - ret =3D -2; - } else { - ret =3D -1; - } - return ret; + if (virStrToLong_ll((char *) obj->stringval, NULL, 10, value) < 0) + return -2; + + return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621040; cv=none; d=zohomail.com; s=zohoarc; b=hnZk4CPvl6QsBQ9J2mu6Qr51LSaawi94OTQk/da/Ct/40CpBSmL/SfSCuCU6J42+lYnQvXjmX5Wd0/eqJDA1EsqgPBVLGxRCqmUYxQQnqcD2habxDSrHUkg0d5XOpGZemNJhCAgywcPqUDn+334IGdQX9iVF+/gFqCIen6kMP2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621040; 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=tekhR321tRbtelxZACFdszsjB06inHSTdJe9BUfQKPg=; b=V6fBwGhyd9nea5nG6AMKaLLZXsrSFY6rogpDaHHeEnKNI8WBh5VEJVMWja9R0cbVXertOapq1CoRUpD16KOk8kayxKqBizgbeNumZwdqJkgwgksWULIvAk7lVK8HRpTm1uYLhZ94Vq//GB81YpFzFU732SyzgRarzZRLcrRWpAU= 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 1666621040879909.8532840482789; Mon, 24 Oct 2022 07:17:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-539-gATyjFbEOwuj6Tl6tNFqCg-1; Mon, 24 Oct 2022 10:16:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 645B2857D10; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52F2B1121315; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 437BC194658F; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 59380194658D for ; Mon, 24 Oct 2022 14:15:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4007D40C83AA; Mon, 24 Oct 2022 14:15:12 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C4C240C2064 for ; Mon, 24 Oct 2022 14:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621039; 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=tekhR321tRbtelxZACFdszsjB06inHSTdJe9BUfQKPg=; b=hbxUwjKDL+z0A7MHVRenyq6UT0zoGwzS1LVaqyxAUingRnUcMtnoBdW76+H1w1Fu6Fzq5n Tx0xi/wNy+7DTVqClHYs0w4wCU/46zZ285t/TBudeugKeeZV2qTaa+8df71hlDRPnYtOXX XLAdk7YEggQASx+XjOhpYWqFK9UpsAo= X-MC-Unique: gATyjFbEOwuj6Tl6tNFqCg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/43] util: xml: Disallow aliasing of negative numbers in virXPathULongLong Date: Mon, 24 Oct 2022 16:14:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666621043006100001 Content-Type: text/plain; charset="utf-8" Passing negative number as an alias for the max value is an anti-feature we unfortunately allowed in virsh, but luckily never encouraged in the XML. Refuse numbers with negative sign when parsing unsigned long long from XPaths. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 35c0340779..067fef8856 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -323,7 +323,7 @@ virXPathULongLong(const char *xpath, if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0) + if (virStrToLong_ullp((char *) obj->stringval, NULL, 10, value) < 0) return -2; return 0; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620978; cv=none; d=zohomail.com; s=zohoarc; b=CcIMieinyeL4jSC4ok4BGzsWQIC2i/KLC2Z6JQMKSkwtVZ/mWzwoRN10OZ1SBiYucFMZ4nsF8yQHLbj3/UQhqFjU4wkQ1IDnn/pUU084cX7hYr+AbFD08R2r9jpCRUyqkTa2caYUQzV1hHpuOrSgAEK/6iJw4mq/lY4I4wgPcNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620978; 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=Wzld1WmTxr72lBLjX4eYEC3NaXdyig49UESiOMBvG5Q=; b=hVcGAWrqBkTlcHAHwKAssZ49PfCA1uZ46Tigt8FnX36MnG3fkGvjuycrR0Iyg1aA9tNKtjzwOciXzuVTdFUPLsB9jj4AKtM+LDV5oP+o54cS8jro6+7TL0oGP8Nyzql4uXKTG/cA2GPwrUEc09KECSpasV+dXESWCVtISzFu1qs= 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 1666620978962376.59263600211773; Mon, 24 Oct 2022 07:16:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-CYj2LYEFMZWdtuoDQllaZg-1; Mon, 24 Oct 2022 10:16:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F07A1855459; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E3640C6FA3; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 859D619465B5; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A56DF194658D for ; Mon, 24 Oct 2022 14:15:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 89B8E40C2088; Mon, 24 Oct 2022 14:15:13 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB3D940C2064 for ; Mon, 24 Oct 2022 14:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620978; 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=Wzld1WmTxr72lBLjX4eYEC3NaXdyig49UESiOMBvG5Q=; b=M9u271KLHsUbgvT2ULl27JUoSjUA/5n7F1nOmvbKQ/R106LT8uEQHZJG5MBVTouRQrSMXV FNUBnRTAldb6qwzLfyV96YCGN3GrBL4skZYHX2bgvCmeFIbfbzXzz7z8Iu99P8UOkkVBE4 eHpPeeyPIq4jko6EUbtvmjhlPcdDZ+w= X-MC-Unique: CYj2LYEFMZWdtuoDQllaZg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/43] conf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseUInt Date: Mon, 24 Oct 2022 16:14:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1666620980484100001 Content-Type: text/plain; charset="utf-8" Upcoming patches will require that the XML XPath query returns a string for conversion in virXPathUInt. Convert all the XPaths used with virNodeDevCapsDefParseUInt which uses virXPathUInt internally. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 3bff17dae2..883f66f4d5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1502,25 +1502,25 @@ virNodeDevCapSCSIParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseUInt("number(./host[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./host[1])", ctxt, &scsi->host, def, _("no SCSI host ID supplied for '%s'"), _("invalid SCSI host ID supplied for '%= s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./bus[1])", ctxt, &scsi->bus, def, _("no SCSI bus ID supplied for '%s'"), _("invalid SCSI bus ID supplied for '%s= '")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./target[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./target[1])", ctxt, &scsi->target, def, _("no SCSI target ID supplied for '%s'"= ), _("invalid SCSI target ID supplied for = '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./lun[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./lun[1])", ctxt, &scsi->lun, def, _("no SCSI LUN ID supplied for '%s'"), _("invalid SCSI LUN ID supplied for '%s= '")) < 0) @@ -1615,7 +1615,7 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; if (create =3D=3D EXISTING_DEVICE) { - if (virNodeDevCapsDefParseUInt("number(./host[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./host[1])", ctxt, &scsi_host->host, def, _("no SCSI host ID supplied for '%s= '"), _("invalid SCSI host ID supplied fo= r '%s'")) < 0) { @@ -1775,25 +1775,25 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPt= r ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseUInt("number(./number[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./number[1])", ctxt, &usb_if->number, def, _("no USB interface number supplied for= '%s'"), _("invalid USB interface number supplie= d for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./class[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./class[1])", ctxt, &usb_if->klass, def, _("no USB interface class supplied for = '%s'"), _("invalid USB interface class supplied= for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./subclass[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./subclass[1])", ctxt, &usb_if->subclass, def, _("no USB interface subclass supplied f= or '%s'"), _("invalid USB interface subclass suppl= ied for '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./protocol[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./protocol[1])", ctxt, &usb_if->protocol, def, _("no USB interface protocol supplied f= or '%s'"), _("invalid USB interface protocol suppl= ied for '%s'")) < 0) @@ -1839,13 +1839,13 @@ virNodeDevCapUSBDevParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D node; - if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./bus[1])", ctxt, &usb_dev->bus, def, _("no USB bus number supplied for '%s'"= ), _("invalid USB bus number supplied for = '%s'")) < 0) return -1; - if (virNodeDevCapsDefParseUInt("number(./device[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./device[1])", ctxt, &usb_dev->device, def, _("no USB device number supplied for '%= s'"), _("invalid USB device number supplied f= or '%s'")) < 0) @@ -2084,25 +2084,25 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, pci_dev->klass =3D -1; } - if (virNodeDevCapsDefParseUInt("number(./domain[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./domain[1])", ctxt, &pci_dev->domain, def, _("no PCI domain ID supplied for '%s'"), _("invalid PCI domain ID supplied for '= %s'")) < 0) goto out; - if (virNodeDevCapsDefParseUInt("number(./bus[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./bus[1])", ctxt, &pci_dev->bus, def, _("no PCI bus ID supplied for '%s'"), _("invalid PCI bus ID supplied for '%s'= ")) < 0) goto out; - if (virNodeDevCapsDefParseUInt("number(./slot[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./slot[1])", ctxt, &pci_dev->slot, def, _("no PCI slot ID supplied for '%s'"), _("invalid PCI slot ID supplied for '%s= '")) < 0) goto out; - if (virNodeDevCapsDefParseUInt("number(./function[1])", ctxt, + if (virNodeDevCapsDefParseUInt("string(./function[1])", ctxt, &pci_dev->function, def, _("no PCI function ID supplied for '%s'= "), _("invalid PCI function ID supplied for= '%s'")) < 0) --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621001; cv=none; d=zohomail.com; s=zohoarc; b=gmuOsmCKs/GeGgFjvMCnuhROCs6sWey0747T3cW6FngtqceVrc50apIyS4kvNGVrn7QQROYQlgO4eAwVCbtAj4AMsE4OGJfTzzsh2Xu6OF1zOaDw+MQCwcFweUlhXrhYqGTMjtXzY+5y+eh72nT/zUAG2ndOZmBBmzmu05rPE6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621001; 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=2blvqml+eDZTuj4X3nJZFCM9fyLsNLjC/eNd/agRxmY=; b=GfU91aR1hxb9f5j51cAaR3LJ+m796wv/DPH88+K7navpwXho5L/3ARpSO7LQVSTWyuPwsAyhw66C56Jum90qczruTVlUmRp7jlPboZL7BH9XHmmH1XMxUKq1NlWGoTVCjfCeVGLgGRW6JVayl9C8yzzfupFKyT2rVFSyeukjDGk= 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 1666621001144748.6943007213699; Mon, 24 Oct 2022 07:16:41 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-BTyUlwoIOPSDryxYAtZLXg-1; Mon, 24 Oct 2022 10:16:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E49CF10109C1; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D37701121315; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C8B51194658F; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9DFE619465BA for ; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9376740C2088; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED60740C2064 for ; Mon, 24 Oct 2022 14:15:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621000; 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=2blvqml+eDZTuj4X3nJZFCM9fyLsNLjC/eNd/agRxmY=; b=dzGpoK6HA5kcy1UscjuZb8KrqAi7l9NmPFa3gY4zW4/1B09/iGFCLnQcvM23WgYMNIg5AX o4nuc8td2GhAgI27Fc7BefzRdVGPRG3nWFDXuLrfXVih0ITWqhPK8ftW6R+pF4X3L5Qyt1 peQQJQ3pJ0FpD+Pk3rEWuXlBNj/+/rc= X-MC-Unique: BTyUlwoIOPSDryxYAtZLXg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/43] conf: node_device: Convert rest of virXPathUInt XPath expressions to number Date: Mon, 24 Oct 2022 16:14:19 +0200 Message-Id: <6c732f2703b67b48777991c2bc68e61d81212fde.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666621002577100009 Content-Type: text/plain; charset="utf-8" Convert the rest of the XPath expressions used with virXPathUInt directly to convert via string(). This will become mandatory in upcoming patches. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 883f66f4d5..1e798651c5 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -942,7 +942,7 @@ virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt, goto cleanup; } - if (virXPathUInt("number(./availableInstances)", ctxt, + if (virXPathUInt("string(./availableInstances)", ctxt, &type->available_instances) < 0) { virReportError(VIR_ERR_XML_ERROR, _("missing number of available instances for " @@ -2257,7 +2257,7 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, /* 'iommuGroup' is optional, only report an error if the supplied valu= e is * invalid (-2), not if it's missing (-1) */ - if (virXPathUInt("number(./iommuGroup[1]/@number)", + if (virXPathUInt("string(./iommuGroup[1]/@number)", ctxt, &mdev->iommuGroupNumber) < -1) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid iommuGroup number attribute for '%s'"), --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620963; cv=none; d=zohomail.com; s=zohoarc; b=aLMKlIkakcm6jo0NFFY4BfX4nDvuPy7aurix4va/Ysl7gGV6Y/jYAm3FtFOELOPhywEJkwJ6E7vlO5Vwfp+TvQ8ZaOvy0v7/IcITFmWLBNLyfVRkoi2DMmVlkqwLOenTAeGFEc2nim7myiAHZdBzo5oDdTMnK3Ov6hiA0l2wtLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620963; 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=NUjpVUw6hvQamTB5kHP58n4aDXhDXJz/1QCwxZwykRg=; b=QR47AaK5qWqQZFiJKdvZ3i1ac5N/KrmjblMRrcdfkOPfvSveAbp1p9TwtEJ9o5ac/XIMQEAumGZaF/30XoO0ygTdnAYMFzE3kHLutTZGkIATpaEFHqRurYBzucMRubks5CDFyGKF+EG9rE9SealFiqHDPvWsBpxcdpPino3noj4= 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 1666620963218507.6573898533243; Mon, 24 Oct 2022 07:16:03 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-H7_XIhcUNmep9MR7CTwMdg-1; Mon, 24 Oct 2022 10:15:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F09385CE0F; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF9141401C26; Mon, 24 Oct 2022 14:15:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D63C6194658F; Mon, 24 Oct 2022 14:15:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0CE06194658D for ; Mon, 24 Oct 2022 14:15:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E783F40C2140; Mon, 24 Oct 2022 14:15:15 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57A8440C2064 for ; Mon, 24 Oct 2022 14:15:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620961; 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=NUjpVUw6hvQamTB5kHP58n4aDXhDXJz/1QCwxZwykRg=; b=M2XDMIXEmc8A9TyAL4qnhp/JelXLHZQDSC+nNZNUssdaSvFGhzLZm3Is+32X6+rJdMvl70 zd2TbIm/rIG5QrMHfgKlUiRbdij/tQcWWplcYXxBj5oLQ6ePUAA8z2iqKpkvK9g5w0mUeV /c+/Rwv7H0mBJowoCk3XK67Owr+aigg= X-MC-Unique: H7_XIhcUNmep9MR7CTwMdg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/43] conf: node_device: Use 'string()' in XPath expressions for virNodeDevCapsDefParseIntOptional Date: Mon, 24 Oct 2022 16:14:20 +0200 Message-Id: <415b28b877aa6edc8e4182445905f28106e8c09f.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1666620964373100001 Content-Type: text/plain; charset="utf-8" Upcoming patches will require that the XML XPath query returns a string for conversion in virXPathInt. Convert all the XPaths used with virNodeDevCapsDefParseIntOptional which uses virXPathInt internally. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 1e798651c5..9d04c5fdf4 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1623,7 +1623,7 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, } /* Optional unique_id value */ scsi_host->unique_id =3D -1; - if (virNodeDevCapsDefParseIntOptional("number(./unique_id[1])", ct= xt, + if (virNodeDevCapsDefParseIntOptional("string(./unique_id[1])", ct= xt, &scsi_host->unique_id, def, _("invalid unique_id supplie= d for '%s'")) < 0) { return -1; @@ -2140,7 +2140,7 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, /* The default value is -1 since zero is valid NUMA node number */ pci_dev->numa_node =3D -1; - if (virNodeDevCapsDefParseIntOptional("number(./numa[1]/@node)", ctxt, + if (virNodeDevCapsDefParseIntOptional("string(./numa[1]/@node)", ctxt, &pci_dev->numa_node, def, _("invalid NUMA node ID supplied= for '%s'")) < 0) goto out; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620996; cv=none; d=zohomail.com; s=zohoarc; b=AjkKYUUY7xc5HmzqJHOZ/T9ibPPD3GMoaMhpww/b+cCluhvx+sZZVeusGJmXGjxP3Ma7s8d+a41B6cvVuIomA84Ml4YvxctP58aaWupjUDCh1UM5X8D7KK5wyUARRTyWAucl6k2jNX7ZCkNsdmlp3yV0lxBTbsuTkjg6BLWnl/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620996; 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=hriHvgAvWGzDgMZAF4L5ueaoesM3qKTjBY+w9yjXMNg=; b=lLQWM7O2mwloNdIkRPRr3FF4NcHyM2j4A15T+mVBkC9cgyLZRC21Fh/i+Sf1WRYpwgSMCQSzAMunKpXyO78BjRCQgz9ULUkRj37FNzDQuYF321GTJ+LOkzSzFDlLezmiAhNG3BefgVAJoBmaOUPCnbg6nnmgZAZ0/WnVXNQivi8= 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 1666620996898311.5413428369085; Mon, 24 Oct 2022 07:16:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-ZRWd7QgWOEu5D9CAZiEF_w-1; Mon, 24 Oct 2022 10:16:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F7C1804186; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BDD514152E1; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 219A4194658F; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E4BDF194658F for ; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C777040C2064; Mon, 24 Oct 2022 14:15:17 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44BF940C2143 for ; Mon, 24 Oct 2022 14:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620995; 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=hriHvgAvWGzDgMZAF4L5ueaoesM3qKTjBY+w9yjXMNg=; b=D0lJzdtcRFL80xRtiHneexdgkMNv4B5H9sj2Fe0Y1Uqo8RwN1RZ7i4hR2oAgg+Dtui8Ynb dmPkwknuSXm3l17taTePjDf7UwrSegwwbFnErLlyEP+Ea+Q/im2etLIHqUEVx2ZQybCOq4 9EaNt6hDS7sw9gryzZ/aK69F1q2MJ6M= X-MC-Unique: ZRWd7QgWOEu5D9CAZiEF_w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/43] conf: numa: Don't fetch XML node count in virDomainNumatuneParseXML Date: Mon, 24 Oct 2022 16:14:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1666620998526100005 Content-Type: text/plain; charset="utf-8" The code only wants to refuse cases where more than one 'numatune' element is present which can be achieved by using 'virXPathBoolean'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/numa_conf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 390ef49b84..688aa7b409 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -226,18 +226,13 @@ virDomainNumatuneParseXML(virDomainNuma *numa, { g_autofree char *modestr =3D NULL; int mode =3D -1; - int n =3D 0; g_autofree char *placementstr =3D NULL; int placement =3D -1; g_autofree char *nodesetstr =3D NULL; g_autoptr(virBitmap) nodeset =3D NULL; xmlNodePtr node =3D NULL; - if (virXPathInt("count(./numatune)", ctxt, &n) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot extract numatune nodes")); - return -1; - } else if (n > 1) { + if (virXPathBoolean("count(./numatune) > 1", ctxt) =3D=3D 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("only one numatune is supported")); return -1; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620982; cv=none; d=zohomail.com; s=zohoarc; b=Qj35DHxX2McO5GiUbPznagpzIaOQknJYCSmSpPgxE2IPDwVUSo52DB4Pa4WhLZhNJcpjCU4PGNkrTzmeYPqr+UXxzQw+cYsLtf/v79QHsb9autPU46/uEZJHdyMqSxVSwaNRKs7uNJtr7eNGpaIYvTxUQ0pNg42gaubtGHYLiZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620982; 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=T3BWaNQRHnMGlL7kyXTxu7hGtPJGf7GglJ0DgmAl2CQ=; b=htsWUnaO5r+wkOjC5g3tUL2cbsbCMBLOjo7S3kE3nInY/FS/3OFH95dSRDuquh61qJNiuOOq4VSVFtxI2D137bzDBdRt+X9lBsK34BMq2c6nj7uPSDuLiY7T2RnUe43ImnHpUXxpFyYTVQ5NO8U8GILfkWMj/flV+mrVm9aXrZI= 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 1666620982916544.5705341183387; Mon, 24 Oct 2022 07:16:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-__KctGW7NtKiV98h6gEs2g-1; Mon, 24 Oct 2022 10:16:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 864451C07557; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73944112132C; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6446D194658F; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 69A3919465A4 for ; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5EE7740C2064; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA7740C2089 for ; Mon, 24 Oct 2022 14:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620981; 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=T3BWaNQRHnMGlL7kyXTxu7hGtPJGf7GglJ0DgmAl2CQ=; b=dv+87P2nESQaPey/zW/JgRb9ir7q9S4yra4NTL9psWJgafJoUoJ3BcunvzF14Ge8ryg7Ft sgcXfxS/+/PnlcMJ7Uugw0wmkiKSeRM01zxcv5Dxj++Cj2B0iTdLwWVx7u5U7HLNtQLYBF qWdiCbLSDrjbRUX5sjnwwQRZbBvwlng= X-MC-Unique: __KctGW7NtKiV98h6gEs2g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/43] conf: cpu: Extract and refactor parsing of cache from virCPUDefParseXML Date: Mon, 24 Oct 2022 16:14:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666620984504100001 Content-Type: text/plain; charset="utf-8" Move the parser into a helper function named 'virCPUDefParseXMLCache' and use the virXMLProp* helpers instead of multiple XPath lookups. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/cpu_conf.c | 58 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index fdbb564cc8..a33f39ef31 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -312,6 +312,34 @@ virCPUDefParseXMLString(const char *xml, } +static int +virCPUDefParseXMLCache(virCPUDef *def, + xmlNodePtr node) +{ + int rc; + + def->cache =3D g_new0(virCPUCacheDef, 1); + + if ((rc =3D virXMLPropInt(node, "level", 10, VIR_XML_PROP_NONNEGATIVE, + &def->cache->level, -1)) < 0) + return -1; + + if (rc =3D=3D 1) { + if (def->cache->level < 1 || def->cache->level > 3) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid CPU cache level, must be in range [1= ,3]")); + return -1; + } + } + + if (virXMLPropEnum(node, "mode", virCPUCacheModeTypeFromString, + VIR_XML_PROP_REQUIRED, &def->cache->mode) < 0) + return -1; + + return 0; +} + + /* * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is * NULL, the current node of @ctxt is used (i.e., it is a shortcut to "."). @@ -335,6 +363,8 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, g_autofree xmlNodePtr *nodes =3D NULL; xmlNodePtr topology =3D NULL; xmlNodePtr maxphysaddrNode =3D NULL; + g_autofree xmlNodePtr *cacheNodes =3D NULL; + ssize_t ncacheNodes =3D 0; VIR_XPATH_NODE_AUTORESTORE(ctxt) int n; int rv; @@ -626,35 +656,15 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, def->features[i].policy =3D policy; } - if (virXPathInt("count(./cache)", ctxt, &n) < 0) { - return -1; - } else if (n > 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("at most one CPU cache element may be specified")= ); - return -1; - } else if (n =3D=3D 1) { - int level =3D -1; - g_autofree char *strmode =3D NULL; - int mode; - - if (virXPathBoolean("boolean(./cache[1]/@level)", ctxt) =3D=3D 1 && - (virXPathInt("string(./cache[1]/@level)", ctxt, &level) < 0 || - level < 1 || level > 3)) { + if ((ncacheNodes =3D virXPathNodeSet("./cache", ctxt, &cacheNodes)) > = 0) { + if (ncacheNodes > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("invalid CPU cache level, must be in range [1= ,3]")); + _("at most one CPU cache element may be specifi= ed")); return -1; } - if (!(strmode =3D virXPathString("string(./cache[1]/@mode)", ctxt)= ) || - (mode =3D virCPUCacheModeTypeFromString(strmode)) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing or invalid CPU cache mode")); + if (virCPUDefParseXMLCache(def, cacheNodes[0]) < 0) return -1; - } - - def->cache =3D g_new0(virCPUCacheDef, 1); - def->cache->level =3D level; - def->cache->mode =3D mode; } if ((maxphysaddrNode =3D virXPathNode("./maxphysaddr[1]", ctxt))) { --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620949; cv=none; d=zohomail.com; s=zohoarc; b=iKTgykfUfs7nRhK/wHgbzi/nDKPJf0dU5IFdQG8p8qj72t3AgQQd9sRDt8YbDPfNdhbadsNxm0rzPzyI0G6fWSGilQXnjip6eJL4PH1kmX3MzeKafLH1B43UmSQC+k+EdaiFJCJnuU7mHU5GL/ur/jStna+cvIkmwqFJE+ACeOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620949; 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=24ip7FlkwSJISyPqE5Kr9Xe/EipOz86R20wiAZiFe3c=; b=NPjyq2GlrztYPBv/CyNEdPbsTLauv07mp9LiLS+EI/iJeR2EHD8ocgcDaCz5bpBMYVvvlBseXHomTmfJ1Ax7+wosopsgzubN9ljugFLGs9Pw+XyxJHPhATFnWLyrdHGbZ21DQBISyP1ZQ77ftI5dNppxqPuC/LqcENcd9x7Ds+M= 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 1666620949954669.7068030910048; Mon, 24 Oct 2022 07:15:49 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-npc_cgOAM5WXqKUdYFmiKg-1; Mon, 24 Oct 2022 10:15:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA6CA3C11060; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C28CE1121315; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B455719465A0; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 79779194658F for ; Mon, 24 Oct 2022 14:15:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 69F3A40C2089; Mon, 24 Oct 2022 14:15:20 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB52140C2064 for ; Mon, 24 Oct 2022 14:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620948; 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=24ip7FlkwSJISyPqE5Kr9Xe/EipOz86R20wiAZiFe3c=; b=KeC6XFHQofvgas1N49Cf15m3J1h4c5BZ5dT+07bDhO9yK5d6B5WUjeWp7pQLM1Cb8VP9Cw HcZ/5eWWcWtgxPZV7Vj9rIe1kON0JNhb+/KH88oh3N13gH3bP34KvWtcLQRePsJJxjdMGB cX4UQeBxzgKmazv9yt/DoY7TlzUzr3Y= X-MC-Unique: npc_cgOAM5WXqKUdYFmiKg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/43] util: xml: Reimplement virXPath(U)Int via virXPathEvalString Date: Mon, 24 Oct 2022 16:14:23 +0200 Message-Id: <36db07cd9eb839b07a7fdae7a3390d6500290519.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666620950229100001 Content-Type: text/plain; charset="utf-8" Similarly to the refactor of virXPath(U)LongLong drop the ability to convert from the internal double value forcing the use of the 'string()' conversion. In case of 32 bit integers there's no problem with overflows, but we can implement the code identically to what we have in the other helpers. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 067fef8856..d885fc1680 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -149,7 +149,9 @@ virXPathLongBase(const char *xpath, * @ctxt: an XPath context * @value: the returned int value * - * Convenience function to evaluate an XPath number + * Convenience function to evaluate an XPath number. The @xpath expression + * must ensure that the evaluated value is returned as a string (use the + * 'string()' conversion in the expression). * * Returns 0 in case of success in which case @value is set, * or -1 if the XPath evaluation failed or -2 if the @@ -160,15 +162,14 @@ virXPathInt(const char *xpath, xmlXPathContextPtr ctxt, int *value) { - long tmp; - int ret; + g_autoptr(xmlXPathObject) obj =3D NULL; - ret =3D virXPathLongBase(xpath, ctxt, 10, &tmp); - if (ret < 0) - return ret; - if ((int) tmp !=3D tmp) + if (!(obj =3D virXPathEvalString(xpath, ctxt))) + return -1; + + if (virStrToLong_i((char *) obj->stringval, NULL, 10, value) < 0) return -2; - *value =3D tmp; + return 0; } @@ -230,28 +231,29 @@ virXPathULongBase(const char *xpath, * virXPathUInt: * @xpath: the XPath string to evaluate * @ctxt: an XPath context - * @value: the returned int value + * @value: the returned unsigned int value * - * Convenience function to evaluate an XPath number + * Convenience function to evaluate an XPath number. The @xpath expression + * must ensure that the evaluated value is returned as a string (use the + * 'string()' conversion in the expression). * * Returns 0 in case of success in which case @value is set, * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have an int format. + * value doesn't have an unsigned int format. */ int virXPathUInt(const char *xpath, xmlXPathContextPtr ctxt, unsigned int *value) { - unsigned long tmp; - int ret; + g_autoptr(xmlXPathObject) obj =3D NULL; - ret =3D virXPathULongBase(xpath, ctxt, 10, &tmp); - if (ret < 0) - return ret; - if ((unsigned int) tmp !=3D tmp) + if (!(obj =3D virXPathEvalString(xpath, ctxt))) + return -1; + + if (virStrToLong_ui((char *) obj->stringval, NULL, 10, value) < 0) return -2; - *value =3D tmp; + return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620989; cv=none; d=zohomail.com; s=zohoarc; b=itlDAbyWNvD7MDGd2/NUoOgbs/GBynmrCCU5GsVEJ5ZVh4ASYXHZL4yksr+MYzSIKmM/crVjZkm1MhKixngUU4HrAUlUtPHFHbncxu6kjeTRbllqm1vS6ckgL8Ja8nLpWWD9GvBoC4p0/YruViITbGvmI8S6+sdH4AF59CfwdIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620989; 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=/XRaDW1jdAqNQPiZBNbH1gYEG5I3ImJ9iTi4NEcMkeY=; b=fxmjlFKTObBNd1aEI35fhoEj9e3SLerJsK/3MzC3ZiI2lqKKUMbC6wRdwQOH18Hr6DV17F9mhsH2rBIknjVsCL7wdTJ9lerL04tCMZwLm/BUrsZU2pqLVCjkYAQxAwhNiWh8e4lbeYbio8AhazWsU3nCVua8/sUmJ9Mf3wK2gOs= 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 1666620989974505.5416859254683; Mon, 24 Oct 2022 07:16:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-150-uh4u4-lbNqWjD07TKcCPAQ-1; Mon, 24 Oct 2022 10:16:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D2A5857ABF; Mon, 24 Oct 2022 14:15:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A38B112132C; Mon, 24 Oct 2022 14:15:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EF861946594; Mon, 24 Oct 2022 14:15:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 972DE19465B1 for ; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8954B40C2140; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E63A240C2064 for ; Mon, 24 Oct 2022 14:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620988; 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=/XRaDW1jdAqNQPiZBNbH1gYEG5I3ImJ9iTi4NEcMkeY=; b=AnI0DBwxAaGkmTVCyqzGmCaWKHrUrKBMM6hmrI0Bu/oZ3041VOg02gRkyYzxLwIAA4KyqP 2r81vciElDJRrRILwJdJA7e1Wmielc2lJVzMNkm/6KHSpCwn7ZZwXWJoLI249ff/lCqNoA +C5VT0j51b1ji3dsL5UKLKeVPWej5sI= X-MC-Unique: uh4u4-lbNqWjD07TKcCPAQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/43] util: xml: Introduce virXPathU(Int|LongLong)Base Date: Mon, 24 Oct 2022 16:14:24 +0200 Message-Id: <122236d6ac1d220150386edf568a1c39e52e41a0.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666620990629100001 Content-Type: text/plain; charset="utf-8" In an effort to remove the 'Long' variants of XPath number fetching functions we need a way to replace the hex number parsing capability. The new helpers are created from the originals by adding a 'base' argument and keeping the original function as a wrapper to pass 10. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 2 ++ src/util/virxml.c | 42 ++++++++++++++++++++++++++++++---------- src/util/virxml.h | 10 ++++++++++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c6445dedcb..dab3b389c8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3699,9 +3699,11 @@ virXPathNode; virXPathNodeSet; virXPathString; virXPathUInt; +virXPathUIntBase; virXPathULong; virXPathULongHex; virXPathULongLong; +virXPathULongLongBase; # Let emacs know we want case-insensitive sorting diff --git a/src/util/virxml.c b/src/util/virxml.c index d885fc1680..a47a5d49fc 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -228,9 +228,10 @@ virXPathULongBase(const char *xpath, /** - * virXPathUInt: + * virXPathUIntBase: * @xpath: the XPath string to evaluate * @ctxt: an XPath context + * @base: base of the number to fetch @value as * @value: the returned unsigned int value * * Convenience function to evaluate an XPath number. The @xpath expression @@ -242,22 +243,32 @@ virXPathULongBase(const char *xpath, * value doesn't have an unsigned int format. */ int -virXPathUInt(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned int *value) +virXPathUIntBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned int *value) { g_autoptr(xmlXPathObject) obj =3D NULL; if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ui((char *) obj->stringval, NULL, 10, value) < 0) + if (virStrToLong_ui((char *) obj->stringval, NULL, base, value) < 0) return -2; return 0; } +int +virXPathUInt(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int *value) +{ + return virXPathUIntBase(xpath, ctxt, 10, value); +} + + /** * virXPathULong: * @xpath: the XPath string to evaluate @@ -302,9 +313,10 @@ virXPathULongHex(const char *xpath, /** - * virXPathULongLong: + * virXPathULongLongBase: * @xpath: the XPath string to evaluate * @ctxt: an XPath context + * @base: base of the number to fetch @value as * @value: the returned unsigned long long value * * Convenience function to evaluate an XPath number. The @xpath expression @@ -316,22 +328,32 @@ virXPathULongHex(const char *xpath, * value doesn't have a unsigned long long format. */ int -virXPathULongLong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long long *value) +virXPathULongLongBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned long long *value) { g_autoptr(xmlXPathObject) obj =3D NULL; if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ullp((char *) obj->stringval, NULL, 10, value) < 0) + if (virStrToLong_ullp((char *) obj->stringval, NULL, base, value) < 0) return -2; return 0; } +int +virXPathULongLong(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned long long *value) +{ + return virXPathULongLongBase(xpath, ctxt, 10, value); +} + + /** * virXPathLongLong: * @xpath: the XPath string to evaluate diff --git a/src/util/virxml.h b/src/util/virxml.h index fe07e2d223..bdd2e9145d 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -51,6 +51,11 @@ virXPathInt(const char *xpath, xmlXPathContextPtr ctxt, int *value); int +virXPathUIntBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned int *value); +int virXPathUInt(const char *xpath, xmlXPathContextPtr ctxt, unsigned int *value); @@ -63,6 +68,11 @@ virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); int +virXPathULongLongBase(const char *xpath, + xmlXPathContextPtr ctxt, + unsigned int base, + unsigned long long *value); +int virXPathULongLong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long long *value); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621095; cv=none; d=zohomail.com; s=zohoarc; b=BMPPzebjR0xNGgWvEnTpDqtNCNWetARDdh+HjNmNmUMXn7x4lLJp/lwl4DN6+nz4nwVF7mNSMRgsuBxL0QWaIXh9aqUyt8hma2PsHyzA0mKgJP4HlZ5SDwg/mfQQ4BGENMpvDelQvUKOa3H5GuJVitZWRy75WQhofCRps8rwXfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621095; 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=8UXLPMdvZEivFdet5giVUi5YZebBqla72hb5/ecwt6M=; b=RdJ3mDSaoLRGW0pjqGAq4a5xnFelZxtJJB3mGnD756a52rNq6I5FxdS9pgTvBLxrdbqscw9yKJd/ekhKQ8pPf/pqMRIGNJDandIBbD5Kxv9zWalizNDlem2hAe0nUEs6jSD54iuyDzPaPjc2pBM4LaqyhhuvWVi2gvZkdQXyF4s= 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 1666621095639971.4416433864989; Mon, 24 Oct 2022 07:18:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-wf2QgSZ3MYqtjmg5Xxq0jw-1; Mon, 24 Oct 2022 10:16:22 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81BAE185A794; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EA93492CA2; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6235B1946595; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A885194658F for ; Mon, 24 Oct 2022 14:15:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 819B940C2064; Mon, 24 Oct 2022 14:15:22 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id F000440C2140 for ; Mon, 24 Oct 2022 14:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621094; 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=8UXLPMdvZEivFdet5giVUi5YZebBqla72hb5/ecwt6M=; b=B8e177WIig4geHh78Yeee6y54tMxMWFatT3VQZ1gzFf2pB4ZSSjC7+7U2DwqVLG9xaztHn S7EKe1p/oLAoLKCWWZGN2RuUynUS0owS+dYqdxoxgRKCol6U878NZ2IfC3JBotgJJghpUH 0gXU83rjYQ/3NTsrvZOgPhwAEQ5tL3o= X-MC-Unique: wf2QgSZ3MYqtjmg5Xxq0jw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/43] virNodeDevCapsDefParseHexId: Use 'virXPathUIntBase' Date: Mon, 24 Oct 2022 16:14:25 +0200 Message-Id: <51c6436527a78bdd95a0f5ba60f7b4a6a4627386.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1666621097308100005 Content-Type: text/plain; charset="utf-8" Switch to the proper function for parsing integer variant of a hex number via XPath and spell out properly that the argument is 'unsigned int'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9d04c5fdf4..ccedf77443 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1808,15 +1808,14 @@ virNodeDevCapUSBInterfaceParseXML(xmlXPathContextPt= r ctxt, static int virNodeDevCapsDefParseHexId(const char *xpath, xmlXPathContextPtr ctxt, - unsigned *value, + unsigned int *value, virNodeDeviceDef *def, const char *missing_error_fmt, const char *invalid_error_fmt) { int ret; - unsigned long val; - ret =3D virXPathULongHex(xpath, ctxt, &val); + ret =3D virXPathUIntBase(xpath, ctxt, 16, value); if (ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, ret =3D=3D -1 ? missing_error_fmt : invalid_error_f= mt, @@ -1824,7 +1823,6 @@ virNodeDevCapsDefParseHexId(const char *xpath, return -1; } - *value =3D val; return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621035; cv=none; d=zohomail.com; s=zohoarc; b=MPuov9IIfG7jq7ysyPX+wlpgDvasU5aJ5jttPy6NcQr9et8DB9I/aPDpntNoxZBaFyuUkrzcVM1J0xo1P8ehiUPaopeJ7HhDAu3qBrgsnQcuD0YC2PObVeVE3tFIB+DEn8frPhoqsoEKpwiM22ynr5OJBEcG8IGD/CbJf+hveqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621035; 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=nOx1tibVApG6Yt8lSpaMGMhEfUvQj210j0q3aTLeVD0=; b=MfMmCUeiPlmffX7pJ37BDq0OdBj70R7ztQ64kPZdeX77+fLEbL4YeD4emIw5imGz31r3hhAg2rG/cL8xUhBHPcvT7VmOdIoqXYN4RwzZZH27+ssFVU2zrcVnqHmVcZ0fWOreRrEJti5qSvb79F2My1lg2r6L9TBi8wzvc0AQ+Vk= 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 1666621035242408.86221086335684; Mon, 24 Oct 2022 07:17:15 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-Za9aRvDzM3yQMQJr17PyXQ-1; Mon, 24 Oct 2022 10:16:06 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFC3E83FC85; Mon, 24 Oct 2022 14:15:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A30A0C15BB2; Mon, 24 Oct 2022 14:15:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9311719465B2; Mon, 24 Oct 2022 14:15:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A46F519465B2 for ; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 95E8240C2140; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1E9F40C2064 for ; Mon, 24 Oct 2022 14:15:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621033; 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=nOx1tibVApG6Yt8lSpaMGMhEfUvQj210j0q3aTLeVD0=; b=HVoGsAI18BL8Y1qxPzU2PZSfF6+nJ2aDUbttdWzd8rv3Fy8OTp1zxoIvHTNTsnkiCqUM6F CMHFYp2UvtktkmYWinD+bSCajwRcbGGubKgAXBkhp0DMTDJeY1Syko8ThffMboKu+oRGJG EM9Ty5nexEcXZxvoUZEY9nYJ4CkcECs= X-MC-Unique: Za9aRvDzM3yQMQJr17PyXQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/43] util: xml: Disallow aliasing of negative numbers in virXPathUInt Date: Mon, 24 Oct 2022 16:14:26 +0200 Message-Id: <80443f9d91cad1b4cfdad0dbc4a8b9b5609de6f0.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666621037008100007 Content-Type: text/plain; charset="utf-8" Passing negative number as an alias for the max value is an anti-feature we unfortunately allowed in virsh, but luckily never encouraged in the XML. Refuse numbers with negative sign when parsing unsigned int from XPaths. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index a47a5d49fc..d80a69f163 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -253,7 +253,7 @@ virXPathUIntBase(const char *xpath, if (!(obj =3D virXPathEvalString(xpath, ctxt))) return -1; - if (virStrToLong_ui((char *) obj->stringval, NULL, base, value) < 0) + if (virStrToLong_uip((char *) obj->stringval, NULL, base, value) < 0) return -2; return 0; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666620996; cv=none; d=zohomail.com; s=zohoarc; b=gzVAMt4/SNpEF4h5Al0Ei3+bTafN2G+uUV/fOEchlHPqoJggMBUhIAD+YK4pWu0p6buT0AfQ4qM/vX5VuMI9tvdpLBGE4AiAZpKusftxPQTNjpaLWvZByyQ7ttO7zBfugUH2n8XGDxBikeXTmzFqHNy7tHRgAA2/y7bytJ9G138= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620996; 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=roE4X0BB486r+S2hLsIiPmap8HvgVyTI/Stei411OfY=; b=nxT4KmEU/+ieH6LJ4HOybK1WW9c2HX6bXfY/7TKr+JC40jrmMeTcBXsDRqjQtu2/g1Jbn7aRWM565yS0VlMFaDCfvBXPyqKK12s6bziINzBDsnhMJDLJjVx4xQS+5mVzkf/Q6xO07AcWRGynr9AABO/VGoSE9pZ8kjSCs2L3uFM= 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 1666620996050286.6136316275042; Mon, 24 Oct 2022 07:16:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-WAWGEfuDO2SLw8CXDkhDYw-1; Mon, 24 Oct 2022 10:16:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3543486C175; Mon, 24 Oct 2022 14:15:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 211D4200C0CD; Mon, 24 Oct 2022 14:15:27 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1365F19465A0; Mon, 24 Oct 2022 14:15:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8955A1946594 for ; Mon, 24 Oct 2022 14:15:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7AB5F40C2064; Mon, 24 Oct 2022 14:15:26 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5769240C2088 for ; Mon, 24 Oct 2022 14:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620995; 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=roE4X0BB486r+S2hLsIiPmap8HvgVyTI/Stei411OfY=; b=U4owWaJEpPDTp244cLHIeB4d4To+dqaCue27WcIaoiJH3mMVapTAC3GRdMME2NSI7EKUgx RCZ+l/iumKGANTEitLANcQj7nARxzR++GwVerNyt3ptVFR58geEJK1bFLXe+SnihXfCVA+ UikvJysuIgGCkbsceZbQC9r3tUJt2O8= X-MC-Unique: WAWGEfuDO2SLw8CXDkhDYw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/43] testParseNodeInfo: Rewrite to virXPathU(Int|LongLong) Date: Mon, 24 Oct 2022 16:14:27 +0200 Message-Id: <05bd4691e5d0d7e6f86cbef003396e83a3de5fc5.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1666620996526100001 Content-Type: text/plain; charset="utf-8" Use the function for appropriate types and simplify the error logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/test/test_driver.c | 51 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 67c70de11d..5a988fbcbd 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -874,41 +874,30 @@ testParseXMLDocFromFile(xmlNodePtr node, static int testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt) { - long l; - int ret; g_autofree char *str =3D NULL; + unsigned int activeCpus; + unsigned long long memory =3D 0; + int rc; - ret =3D virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->nodes =3D l; - } else if (ret =3D=3D -2) { + if (virXPathUInt("string(/node/cpu/nodes[1])", ctxt, &nodeInfo->nodes)= =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu nodes value")); return -1; } - ret =3D virXPathLong("string(/node/cpu/sockets[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->sockets =3D l; - } else if (ret =3D=3D -2) { + if (virXPathUInt("string(/node/cpu/sockets[1])", ctxt, &nodeInfo->sock= ets) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu sockets value")); return -1; } - ret =3D virXPathLong("string(/node/cpu/cores[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->cores =3D l; - } else if (ret =3D=3D -2) { + if (virXPathUInt("string(/node/cpu/cores[1])", ctxt, &nodeInfo->cores)= =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu cores value")); return -1; } - ret =3D virXPathLong("string(/node/cpu/threads[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->threads =3D l; - } else if (ret =3D=3D -2) { + if (virXPathUInt("string(/node/cpu/threads[1])", ctxt, &nodeInfo->thre= ads) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu threads value")); return -1; @@ -916,19 +905,19 @@ testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathCo= ntextPtr ctxt) nodeInfo->cpus =3D (nodeInfo->cores * nodeInfo->threads * nodeInfo->sockets * nodeInfo->nodes); - ret =3D virXPathLong("string(/node/cpu/active[1])", ctxt, &l); - if (ret =3D=3D 0) { - if (l < nodeInfo->cpus) - nodeInfo->cpus =3D l; - } else if (ret =3D=3D -2) { + + if ((rc =3D virXPathUInt("string(/node/cpu/active[1])", ctxt, &activeC= pus)) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu active value")); return -1; } - ret =3D virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->mhz =3D l; - } else if (ret =3D=3D -2) { + + if (rc =3D=3D 0) { + if (activeCpus < nodeInfo->cpus) + nodeInfo->cpus =3D activeCpus; + } + + if (virXPathUInt("string(/node/cpu/mhz[1])", ctxt, &nodeInfo->mhz) =3D= =3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu mhz value")); return -1; @@ -943,15 +932,15 @@ testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathCo= ntextPtr ctxt) } } - ret =3D virXPathLong("string(/node/memory[1])", ctxt, &l); - if (ret =3D=3D 0) { - nodeInfo->memory =3D l; - } else if (ret =3D=3D -2) { + if ((rc =3D virXPathULongLong("string(/node/memory[1])", ctxt, &memory= )) =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node memory value")); return -1; } + if (rc =3D=3D 0) + nodeInfo->memory =3D memory; + return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621145; cv=none; d=zohomail.com; s=zohoarc; b=hP8c2ibFPmNMRiEBdiGLqIlEeqOmcenUQ1BqhuKpA/PHxOVpHvdO2rlf/X/68wgMa4JIj1HB/gjmMMjc8M5CINn2pq1AWhBvovL/9DP+kmf40NRhTJPrK3dOCMCSwZeTCxV5fXV4L7sO8G+VfKxcQHPKOuB2XArovQFi5HzBEBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621145; 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=CTkehtwVIPWtArpRtUNZe9uJegHTmevvSyVjmrzAJi0=; b=B0ItTqg7bu0fKa626Qe0UYJlSjDHM/Qkw/3FTqgO42Y+p+87L9or8ome8dFacW276n14+8E9H0S1zYxA31gDtGch8GBnQQ5fRgsGeLPxBWlb6IFqiTKO+Jw0ge0+7oZK4BHrFtPwV2Y6GgdjK/LawpPm6C6zJQWfhQXBZFJnzXc= 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 1666621145476808.7014885601651; Mon, 24 Oct 2022 07:19:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-604-vA06irI1PgSm1Z2RVR2-ZQ-1; Mon, 24 Oct 2022 10:16:17 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EF847104D52F; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD08C492CA2; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C1CDA1946595; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F1FD91946595 for ; Mon, 24 Oct 2022 14:15:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D785740C2064; Mon, 24 Oct 2022 14:15:29 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3950340C2140 for ; Mon, 24 Oct 2022 14:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621144; 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=CTkehtwVIPWtArpRtUNZe9uJegHTmevvSyVjmrzAJi0=; b=X6Z0egN2x4XItYWoDqFQqjrVByDOORS+stpQ+JEQEvUgNvWkF/8YL8FgxqbtdWBLLhED0S 6+KZ96RKhnze0rYCwhd1Sv5BUdciRZ6JrZ6LzknPAmpxT8tGSFyeCaco8Qm7ka1s+72Lbu EsUSyVLnhqAahEwm5yHLqOsyaX+KItI= X-MC-Unique: vA06irI1PgSm1Z2RVR2-ZQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/43] conf: domain: Convert from virXPathLong Date: Mon, 24 Oct 2022 16:14:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1666621147575100001 Content-Type: text/plain; charset="utf-8" Convert the two uses of virXPathLong to proper virXMLPropInt/virXMLPropLongLong so that virXPathLong can be removed in an upcoming patch. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7984a15c46..8be37a4040 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17420,13 +17420,15 @@ virDomainDefParseIDs(virDomainDef *def, { g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *tmp =3D NULL; - long id =3D -1; int n; - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - if (virXPathLong("string(./@id)", ctxt, &id) < 0) - id =3D -1; - def->id =3D (int)id; + def->id =3D -1; + + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + if (virXMLPropInt(ctxt->node, "id", 10, VIR_XML_PROP_NONNEGATIVE, + &def->id, -1) < 0) + return -1; + } /* Extract domain name */ if (!(def->name =3D virXPathString("string(./name[1])", ctxt))) { @@ -18983,7 +18985,7 @@ virDomainObjParseXML(xmlXPathContextPtr ctxt, virDomainXMLOption *xmlopt, unsigned int flags) { - long val; + long long vmpid; xmlNodePtr config; xmlNodePtr oldnode; g_autoptr(virDomainObj) obj =3D NULL; @@ -19026,12 +19028,11 @@ virDomainObjParseXML(xmlXPathContextPtr ctxt, virDomainObjSetState(obj, state, reason); - if (virXPathLong("string(./@pid)", ctxt, &val) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid pid")); + if (virXMLPropLongLong(ctxt->node, "pid", 10, VIR_XML_PROP_REQUIRED, + &vmpid, 0) < 0) return NULL; - } - obj->pid =3D (pid_t)val; + + obj->pid =3D (pid_t) vmpid; if ((n =3D virXPathNodeSet("./taint", ctxt, &taintNodes)) < 0) return NULL; --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621008; cv=none; d=zohomail.com; s=zohoarc; b=b20fsiOFZXNr8IycTYDRUOxCm9hyeucCuvah1jMfPvcDYCPf/zn6m7e3Ow2vOWivsGwXOhDHVHtTWUmm8Imvwgbtyrn1Amv3nDcE9JwLwMwmIclZopoP4/CpiwvXCZ9T4cf762nYdml6u7Akkqb7P6+V6tWn9ZYHpa2gjN4n2qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621008; 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=HgnmcQNWOcCVMlNn5AT2x1LRsUkHpW0fr4zKvYUwiC0=; b=X9SgMh8tH216ioJNfsTVjTZVgL1YJ55a+7IKJ0Olvyw/UzKCZH2JfCzClmDDu6bVSyI6WagQW1tMsrOARjXYCVt7rCBaUYB6RON+iY2CzXwtID68da8WayYBMIc0TMfWCe1ZB65BJKDH4eNPlTlTF7GEIxFqwPRtSc+egyjUSqY= 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 1666621008832803.4442803426223; Mon, 24 Oct 2022 07:16:48 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-NVPo_ffjNl-BwYUrjFweOQ-1; Mon, 24 Oct 2022 10:16:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E43F3814959; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49459C06218; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B5A219465A0; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EA2A91946594 for ; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DBBFF40C83AD; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54E0340C2064 for ; Mon, 24 Oct 2022 14:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621007; 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=HgnmcQNWOcCVMlNn5AT2x1LRsUkHpW0fr4zKvYUwiC0=; b=AJsQy9oPzSeBkFN1PeZ9gBFBIfUsU1CpnTjCFUBZH5yVTenEOgOIvq2B6AO9fPXyWnZeEt ESrQzs0uQNtKHA7NAH/G2P/2NjHyJIE4Nj95gZjf58KKkHEHE+m5kZSnTyQT1iSh7quTbk 57b/mVxaUjVyvDlMe4GxXQEd9tx0Vs0= X-MC-Unique: NVPo_ffjNl-BwYUrjFweOQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/43] util: xml: Remove virXPathLong Date: Mon, 24 Oct 2022 16:14:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666621010652100007 Content-Type: text/plain; charset="utf-8" The function is now unused and we no longer want to promote use of the 'long' type. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virxml.c | 53 ---------------------------------------- src/util/virxml.h | 4 --- 3 files changed, 58 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dab3b389c8..0fc5481a26 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3693,7 +3693,6 @@ virXMLValidatorValidate; virXPathBoolean; virXPathContextNodeRestore; virXPathInt; -virXPathLong; virXPathLongLong; virXPathNode; virXPathNodeSet; diff --git a/src/util/virxml.c b/src/util/virxml.c index d80a69f163..f5ee9284a6 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -111,38 +111,6 @@ virXPathString(const char *xpath, } -static int -virXPathLongBase(const char *xpath, - xmlXPathContextPtr ctxt, - int base, - long *value) -{ - g_autoptr(xmlXPathObject) obj =3D NULL; - int ret =3D 0; - - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathLong()")); - return -1; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && - (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { - if (virStrToLong_l((char *) obj->stringval, NULL, base, value) < 0) - ret =3D -2; - } else if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_NUMBER) && - (!(isnan(obj->floatval)))) { - *value =3D (long) obj->floatval; - if (*value !=3D obj->floatval) - ret =3D -2; - } else { - ret =3D -1; - } - - return ret; -} - - /** * virXPathInt: * @xpath: the XPath string to evaluate @@ -174,27 +142,6 @@ virXPathInt(const char *xpath, } -/** - * virXPathLong: - * @xpath: the XPath string to evaluate - * @ctxt: an XPath context - * @value: the returned long value - * - * Convenience function to evaluate an XPath number - * - * Returns 0 in case of success in which case @value is set, - * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have a long format. - */ -int -virXPathLong(const char *xpath, - xmlXPathContextPtr ctxt, - long *value) -{ - return virXPathLongBase(xpath, ctxt, 10, value); -} - - static int virXPathULongBase(const char *xpath, xmlXPathContextPtr ctxt, diff --git a/src/util/virxml.h b/src/util/virxml.h index bdd2e9145d..439a2a9991 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -60,10 +60,6 @@ virXPathUInt(const char *xpath, xmlXPathContextPtr ctxt, unsigned int *value); int -virXPathLong(const char *xpath, - xmlXPathContextPtr ctxt, - long *value); -int virXPathULong(const char *xpath, xmlXPathContextPtr ctxt, unsigned long *value); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620986; cv=none; d=zohomail.com; s=zohoarc; b=m5q1ec+seZ11iRfRjbwPsxceYWapCNA9En5q7MxhUdXGbPEdkxJFvqofhQVVInF5CNm0hggKN1kPy4pve/PVKAG6X/XZo+kPZG0phKl3vNJtQo+Ep7xY/4JRGSUJUi+xUNUSqqi8Lb4Xh/7b6m9FqArsySluzo8CZDVU1pxuuIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620986; 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=uGBWCbSgRAHtiVEN4qjfwpEmpqT6EraGLHcUO5PRx+s=; b=luCca0e6dTTf4f9/EHIA4IkcLf5URtELhh005EH+7M850qSV3soEndpEDN/XNBMt/1LtLr1FyMCqPkckjXn/YLrV/xKR/M+oXIShd2MXajSAgGsPgg4oYEQwWe6l0HGgl5cLn/y1GrtmnNEyou+Z2hZGnZwrHt/gl2S2U+5Q7pY= 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 1666620986819740.139823781482; Mon, 24 Oct 2022 07:16:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-hnLGAgeZMVuRiNFpmlv6Eg-1; Mon, 24 Oct 2022 10:16:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D44E38279A6; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF85DC1908D; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A5A5B19465A4; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E5832194658F for ; Mon, 24 Oct 2022 14:15:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DB70B40C2089; Mon, 24 Oct 2022 14:15:31 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41B3F40C2088 for ; Mon, 24 Oct 2022 14:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620985; 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=uGBWCbSgRAHtiVEN4qjfwpEmpqT6EraGLHcUO5PRx+s=; b=BguHmePrH4bBZJELaKGB+C7aMhKDKyMLWMV4dheTM2NhRWZu+L+gomYMo6H2U1cFFE5PJn PVNs7afcwSawTLnftFSheIo1PjL6b5fux/G0JVoz+uF6HGJPstbioJqmHmzMMQYN3VwpB9 yJjr5kNlOZBFLyFNFVpPkC7tBlnudYs= X-MC-Unique: hnLGAgeZMVuRiNFpmlv6Eg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/43] virQEMUCapsLoadCache: Use 'virXMLPropUInt' instead of 'virXPathULong' Date: Mon, 24 Oct 2022 16:14:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620988480100001 Content-Type: text/plain; charset="utf-8" The libvirt version is stored in an 'unsigned int' use the proper XPath query function for the type and remove the temporary variable. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index dd50f85c73..63590f139f 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4385,7 +4385,6 @@ virQEMUCapsLoadCache(virArch hostArch, g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; long long int l; - unsigned long lu; if (!(doc =3D virXMLParse(filename, NULL, NULL, "qemuCaps", &ctxt, NUL= L, false))) return -1; @@ -4397,9 +4396,9 @@ virQEMUCapsLoadCache(virArch hostArch, } qemuCaps->libvirtCtime =3D (time_t)l; - qemuCaps->libvirtVersion =3D 0; - if (virXPathULong("string(./selfvers)", ctxt, &lu) =3D=3D 0) - qemuCaps->libvirtVersion =3D lu; + if (virXMLPropUInt(ctxt->node, "selfvers", 10, VIR_XML_PROP_NONE, + &qemuCaps->libvirtVersion) < 0) + return -1; if (!skipInvalidation && (qemuCaps->libvirtCtime !=3D virGetSelfLastChanged() || --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620978; cv=none; d=zohomail.com; s=zohoarc; b=EQJ2h6PZO4kidwA6eTi+ozelhfLCVOA5g/jJNfk9CXAoGfUNS/v3rxs3NVMFdFAP4RPZK/jtlCmV+aTfxvpLWfCR1sGncMH6vE0q9runZbjvXeztQS5WR0cGqpXJr5BQKfeWbxz6r+3d2+LfXL2jjLkWxRGOM3fcGn9yW+fCJrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620978; 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=QID97BznGXHFWGzG0+bDdfSdBSLDwdo9v3tnYfXc+wU=; b=TTYlLr7Iq/5bS5Vxc16IqsmPPQPdnC1YpiTqex5p7DwvaGsWzhTP2Rm4yeHkuOyhpA0uc0oqLOyzkcASdKvUOhhzi6WuoV5bhsxDOAhxq+C5bKGkNZNp0a0L/b6QMvCE0OGmSsWXsWfDiEo5c4JrdTgP7QhnzaK4yebro3QyK2A= 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 1666620978429521.027351873991; Mon, 24 Oct 2022 07:16:18 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-NcU-W-gpMjKCfp-HVmBEUw-1; Mon, 24 Oct 2022 10:16:04 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4AB9E811E81; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38239C2C8C5; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1882C194658D; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DC96D194658D for ; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF76640C2089; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 486AF40C2064 for ; Mon, 24 Oct 2022 14:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620977; 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=QID97BznGXHFWGzG0+bDdfSdBSLDwdo9v3tnYfXc+wU=; b=PjOsQfaAReqVye5lAnRvxljDTvuk141lTxvmLQo9xHplpPejsCiZBHjY/WXDtTCWdmps7g Vk/aY4/47iQGbzsP2IyzAgnLwpFQ1ESuxKR0YuZNLBJE7tsImQGwo+xvkIVx2fF2GUSRhH oACpyeKcZ7W2OCmldm3ESi8iQJT5RW4= X-MC-Unique: NcU-W-gpMjKCfp-HVmBEUw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/43] virNetDevIPRouteParseXML: Refactor to use 'virXMLProp*' instead of XPath Date: Mon, 24 Oct 2022 16:14:31 +0200 Message-Id: <367ee29be1fc8e760f05d37ca1bf4372da0785bb.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666620980491100002 Content-Type: text/plain; charset="utf-8" The function extracts multiple attributes form a single element. Modify the function to stop using multiple XPath lookups. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 2 +- src/conf/network_conf.c | 4 +-- src/conf/networkcommon_conf.c | 61 +++++++++-------------------------- src/conf/networkcommon_conf.h | 3 +- 4 files changed, 19 insertions(+), 51 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8be37a4040..cdf05e8fae 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6263,7 +6263,7 @@ virDomainNetIPInfoParseXML(const char *source, for (i =3D 0; i < nrouteNodes; i++) { virNetDevIPRoute *route =3D NULL; - if (!(route =3D virNetDevIPRouteParseXML(source, routeNodes[i], ct= xt))) + if (!(route =3D virNetDevIPRouteParseXML(source, routeNodes[i]))) goto error; VIR_APPEND_ELEMENT(def->routes, def->nroutes, route); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index be43894050..44ac5408d1 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1824,9 +1824,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, for (i =3D 0; i < nRoutes; i++) { virNetDevIPRoute *route =3D NULL; - if (!(route =3D virNetDevIPRouteParseXML(def->name, - routeNodes[i], - ctxt))) + if (!(route =3D virNetDevIPRouteParseXML(def->name, routeNodes= [i]))) return NULL; def->routes[i] =3D route; def->nroutes++; diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 7bfcd2e9b4..275847853d 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -211,58 +211,29 @@ virNetDevIPRouteCreate(const char *errorDetail, virNetDevIPRoute * virNetDevIPRouteParseXML(const char *errorDetail, - xmlNodePtr node, - xmlXPathContextPtr ctxt) + xmlNodePtr node) { - /* - * virNetDevIPRoute object is already allocated as part - * of an array. On failure clear: it out, but don't free it. - */ - - VIR_XPATH_NODE_AUTORESTORE(ctxt) - g_autofree char *family =3D NULL; - g_autofree char *address =3D NULL; - g_autofree char *netmask =3D NULL; - g_autofree char *gateway =3D NULL; - unsigned long prefix =3D 0, metric =3D 0; - int prefixRc, metricRc; + g_autofree char *family =3D virXMLPropString(node, "family"); + g_autofree char *address =3D virXMLPropString(node, "address"); + g_autofree char *netmask =3D virXMLPropString(node, "netmask"); + g_autofree char *gateway =3D virXMLPropString(node, "gateway"); + unsigned int prefix =3D 0; + unsigned int metric =3D 0; bool hasPrefix =3D false; bool hasMetric =3D false; + int rc; - ctxt->node =3D node; - - /* grab raw data from XML */ - family =3D virXPathString("string(./@family)", ctxt); - address =3D virXPathString("string(./@address)", ctxt); - netmask =3D virXPathString("string(./@netmask)", ctxt); - gateway =3D virXPathString("string(./@gateway)", ctxt); - prefixRc =3D virXPathULong("string(./@prefix)", ctxt, &prefix); - if (prefixRc =3D=3D -2) { - virReportError(VIR_ERR_XML_ERROR, - _("%s: Invalid prefix specified " - "in route definition"), - errorDetail); + if ((rc =3D virXMLPropUInt(node, "prefix", 10, VIR_XML_PROP_NONE, &pre= fix)) < 0) return NULL; - } - hasPrefix =3D (prefixRc =3D=3D 0); - metricRc =3D virXPathULong("string(./@metric)", ctxt, &metric); - if (metricRc =3D=3D -2) { - virReportError(VIR_ERR_XML_ERROR, - _("%s: Invalid metric specified " - "in route definition"), - errorDetail); + + if (rc =3D=3D 1) + hasPrefix =3D true; + + if ((rc =3D virXMLPropUInt(node, "metric", 10, VIR_XML_PROP_NONZERO, &= metric)) < 0) return NULL; - } - if (metricRc =3D=3D 0) { + + if (rc =3D=3D 1) hasMetric =3D true; - if (metric =3D=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("%s: Invalid metric value, must be > 0 " - "in route definition"), - errorDetail); - return NULL; - } - } return virNetDevIPRouteCreate(errorDetail, family, address, netmask, gateway, prefix, hasPrefix, metric, diff --git a/src/conf/networkcommon_conf.h b/src/conf/networkcommon_conf.h index b5955d9f99..9ac981d0d7 100644 --- a/src/conf/networkcommon_conf.h +++ b/src/conf/networkcommon_conf.h @@ -42,8 +42,7 @@ virNetDevIPRouteCreate(const char *networkName, virNetDevIPRoute * virNetDevIPRouteParseXML(const char *networkName, - xmlNodePtr node, - xmlXPathContextPtr ctxt); + xmlNodePtr node); int virNetDevIPRouteFormat(virBuffer *buf, const virNetDevIPRoute *def); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620990; cv=none; d=zohomail.com; s=zohoarc; b=BSRY/jIQe/ehoOj8X+P+8fVjj+wmoX3dLJ5kpT2tC75HQtHED20JgE3cfNnebDToM+mQ9Rf7G3XR+PqjHh6+R78WfZ9OdadY8Wt7Kxz9n+4mKRJGvjJFfeg20EjZ6jmAzUpvpbDJF1ndk3IkhTZPBBiZculeAU1Q1rqDbkCfuO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620990; 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=F5j/pSESDPhwID5/xfxTYNhEtWolS5iKxUVsDVAm2aI=; b=j9jS83EHslpWWKG08w2s5sHgRi+fTjyKj/7yb3vdiRYwMEAsQ9Vn7fiUhYrLqbo2L7GQZamK9mLstrp1pglJqvBixHsnW1sLGq5C6jFysqF+eE4q13FQOWxfhfHbTIsLfypkMOoLX0vFKBDqAetjLiV7LDuzf48FKpcqgznV74w= 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 1666620990400951.3355466552833; Mon, 24 Oct 2022 07:16:30 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-74-oeS6VE3OMyigryx53D2Zfw-1; Mon, 24 Oct 2022 10:16:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABB783814941; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9812640C2064; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8D4BB194658F; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1FB9C194658D for ; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 11DF340C83AD; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53B5840C2064 for ; Mon, 24 Oct 2022 14:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620989; 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=F5j/pSESDPhwID5/xfxTYNhEtWolS5iKxUVsDVAm2aI=; b=T8NhkyAYeVTZB+gJ9K42BtkMexQ3kPeMHkOqTyXwBLNzKvMkp9Afutyk5iaR9GtJbrsMNP vT9x32mO476T8rUsLlQt7KC/UjFq0C7jQXkZhEpDevs/L0Ty46tthHZtaq6m9/5+REheGC ZfL0OHs/PKac4yI2ZcDls3C/pt/bYJM= X-MC-Unique: oeS6VE3OMyigryx53D2Zfw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/43] virNetworkIPDefParseXML: Use virXMLPropUInt instead of virXPathULong Date: Mon, 24 Oct 2022 16:14:32 +0200 Message-Id: <3f8a443ee01cc61923c13d3f31656b18ee836db4.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: 1666620992507100003 Content-Type: text/plain; charset="utf-8" Parse the 'prefix' field directly and adjust the the error message format strings. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/network_conf.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 44ac5408d1..b98ae6aa3f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1057,8 +1057,6 @@ virNetworkIPDefParseXML(const char *networkName, xmlNodePtr dhcp; g_autofree char *address =3D NULL; g_autofree char *netmask =3D NULL; - unsigned long prefix =3D 0; - int prefixRc; int ret =3D -1; ctxt->node =3D node; @@ -1089,17 +1087,8 @@ virNetworkIPDefParseXML(const char *networkName, goto cleanup; } - prefixRc =3D virXPathULong("string(./@prefix)", ctxt, &prefix); - if (prefixRc =3D=3D -2) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid ULong value specified for prefix in defi= nition of network '%s'"), - networkName); + if (virXMLPropUInt(node, "prefix", 10, VIR_XML_PROP_NONE, &def->prefix= ) < 0) goto cleanup; - } - if (prefixRc < 0) - def->prefix =3D 0; - else - def->prefix =3D prefix; if (virXMLPropTristateBool(node, "localPtr", VIR_XML_PROP_NONE, @@ -1131,8 +1120,8 @@ virNetworkIPDefParseXML(const char *networkName, } } else if (def->prefix > 32) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid IPv4 prefix '%lu' in network '%s'"), - prefix, networkName); + _("Invalid IPv4 prefix '%u' in network '%s'"), + def->prefix, networkName); goto cleanup; } } else if (STREQ(def->family, "ipv6")) { @@ -1150,8 +1139,8 @@ virNetworkIPDefParseXML(const char *networkName, } if (def->prefix > 128) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid IPv6 prefix '%lu' in network '%s'"), - prefix, networkName); + _("Invalid IPv6 prefix '%u' in network '%s'"), + def->prefix, networkName); goto cleanup; } } else { --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621162; cv=none; d=zohomail.com; s=zohoarc; b=THgFdKf3Hzkm4Hd7G7e+GExhQm3MGeNa1PgDmKpcS4JyPgVghQ+Dq1tBmfQytbIbrfNdGsRSFuJVBFzU4Vz2+Xnq+Qd7BWDJK98FF093vFyA+0xaqLUDaI4AHCH31e1hWlvpm6m5HWBkIh0IRrXsyADxDiwj9wwZr/FHsF7Darc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621162; 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=Ym4CKoXCpfVxiaFpn/lk8dhziydel1AiVSpAyFxt6Sc=; b=AQkTDgnd53ZHUIuvrFG57q9o3mmALFa7XSGjupDB5bW85QrUsbaFkwpsmVVW6dzgOKiCNqk4URw2ZvJNjuMZEXL9I/Z55Q/ELPDEduNAhfN0nrgAvDy3EspfQnQy56JdMJM+YCw0p2MvaL5HjzNZOVVGNfSOZ2vbh+X7rIHI5Hg= 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 1666621162356271.47116166207115; Mon, 24 Oct 2022 07:19:22 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-l7mq5rpJNWqN4caLntJ1gQ-1; Mon, 24 Oct 2022 10:16:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 917653C138C4; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75C032166B34; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6B1981946595; Mon, 24 Oct 2022 14:15:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EF14194658D for ; Mon, 24 Oct 2022 14:15:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8203640C83AD; Mon, 24 Oct 2022 14:15:35 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E05D140C83BB for ; Mon, 24 Oct 2022 14:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621161; 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=Ym4CKoXCpfVxiaFpn/lk8dhziydel1AiVSpAyFxt6Sc=; b=KiNvOI5eGuHO2o445Tbz5Duf2N2NXI/aaE1RoZKQWyYABtFdm7qhUotBLcNuBsEUuMXrRe smIcFEisBQJs6zfjnuOOTt5u+0wvQQvyYE+mcldzyQL1Df8qjekbCuE4A1NUqERgQP209L ArZMyeQmCcTyWB7QGHTC5r7lbEzKS60= X-MC-Unique: l7mq5rpJNWqN4caLntJ1gQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/43] virInterfaceDefParseMtu: Use virXPathUInt instead of virXPathULong Date: Mon, 24 Oct 2022 16:14:33 +0200 Message-Id: <2677bdda40e6d2aa1c3948a07611e8d02fb9f6d1.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1666621163612100001 Content-Type: text/plain; charset="utf-8" Use the proper convertor function and refactor error reporting. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/interface_conf.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index b31fdce101..671b8b088f 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -113,17 +113,15 @@ static int virInterfaceDefParseMtu(virInterfaceDef *def, xmlXPathContextPtr ctxt) { - unsigned long mtu; - int ret; + if (virXPathUInt("string(./mtu/@size)", ctxt, &def->mtu) =3D=3D -2) + return -1; - ret =3D virXPathULong("string(./mtu/@size)", ctxt, &mtu); - if ((ret =3D=3D -2) || ((ret =3D=3D 0) && (mtu > 100000))) { - virReportError(VIR_ERR_XML_ERROR, - "%s", _("interface mtu value is improper")); + if (def->mtu > 100000) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("value of the 'size' attribute of 'mtu' element m= ust be at most 100000")); return -1; - } else if (ret =3D=3D 0) { - def->mtu =3D (unsigned int) mtu; } + return 0; } --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621007; cv=none; d=zohomail.com; s=zohoarc; b=On52RTIvZnIW6aouTVFhwTG2QMz8TsZelB+/TqPkSjXGuCUrulLwjuxYwoN1QJ8mFzpTRTFv4YhrhJ6c1wBKm06u2BNdYo6QBZL5tP5Ya9o+mTHWfvJXsp5oPOQvcj+ULP0uO3fLlrv4VLf8ijIfADjXWtcDJeHSYaw1HSewd1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621007; 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=2Kw/ACL7kgZvpOpgFnHd+pMk0Blj0l7nQpJotxzb4oo=; b=FRnmSNw5EXBQnQxjBfBb0rmAE9Wu3o0u6tDrNsrw4bprobJ7hjOhrLsU3dr0HJ71KGYzn1ueU15u9YTYQMlOkbfZ3TFrZ8amwnxjyCHfRPtaoUuznZA8kj1DyJSSluCT59V3QNOvQ/LqMg5Na6LJbbe4NP0COppu5G659JjUZHM= 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 1666621007088183.452722327654; Mon, 24 Oct 2022 07:16:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-MQiRfHlrNK2TWnjQ0cZsGw-1; Mon, 24 Oct 2022 10:16:28 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E03CD1818212; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE95A492CA2; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BDC691946594; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2A327194658D for ; Mon, 24 Oct 2022 14:15:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 102CA40C83BA; Mon, 24 Oct 2022 14:15:38 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BB1540C83AA for ; Mon, 24 Oct 2022 14:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621006; 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=2Kw/ACL7kgZvpOpgFnHd+pMk0Blj0l7nQpJotxzb4oo=; b=NTzZvTUm3ZKNm9ceBpmPYb5kL5+GBwyBzdnV1VEtNYU8H4vYtJ8V7jwE2BNXM9y2qyLKGZ hj4XRY1XK6Tg/GIRCD5zywe0qNetPUB7C4lw5S/NpyRDP/Fb4s0sIQPkeJ/O3LK2/XpSbs 0xM2i+YS5Us58XgNhRq+E0PJwJQ5VkM= X-MC-Unique: MQiRfHlrNK2TWnjQ0cZsGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/43] virNetDevVlanParse: Use virXMLProp* helpers instead of XPath lookups Date: Mon, 24 Oct 2022 16:14:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1666621008599100003 Content-Type: text/plain; charset="utf-8" The loop inside virNetDevVlanParse fetches multiple attributes from the element. Convert it to use the virXMLProp* helpers, which also simplifies error reporting. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/netdev_vlan_conf.c | 39 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c index 9d7cc732ba..28a818ad85 100644 --- a/src/conf/netdev_vlan_conf.c +++ b/src/conf/netdev_vlan_conf.c @@ -35,7 +35,6 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ct= xt, virNetDevVlan *def) int ret =3D -1; VIR_XPATH_NODE_AUTORESTORE(ctxt) char *trunk =3D NULL; - char *nativeMode =3D NULL; xmlNodePtr *tagNodes =3D NULL; int nTags; size_t i; @@ -57,37 +56,34 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr = ctxt, virNetDevVlan *def) def->nativeMode =3D 0; def->nativeTag =3D 0; for (i =3D 0; i < nTags; i++) { - unsigned long id; + unsigned int nativeMode =3D 0; + int rc; - ctxt->node =3D tagNodes[i]; - if (virXPathULong("string(./@id)", ctxt, &id) < 0) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing or invalid vlan tag id attribute")); + if (virXMLPropUInt(tagNodes[i], "id", 10, VIR_XML_PROP_REQUIRED, + &def->tag[i]) < 0) goto cleanup; - } - if (id > 4095) { + + if (def->tag[i] > 4095) { virReportError(VIR_ERR_XML_ERROR, - _("vlan tag id %lu too large (maximum 4095)"), = id); + _("vlan tag id %u too large (maximum 4095)"), d= ef->tag[i]); goto cleanup; } - if ((nativeMode =3D virXPathString("string(./@nativeMode)", ctxt))= ) { + + if ((rc =3D virXMLPropEnum(tagNodes[i], "nativeMode", + virNativeVlanModeTypeFromString, + VIR_XML_PROP_NONZERO, &nativeMode)) < 0) + return -1; + + if (rc =3D=3D 1) { if (def->nativeMode !=3D 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("duplicate native vlan setting")); goto cleanup; } - if ((def->nativeMode - =3D virNativeVlanModeTypeFromString(nativeMode)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid \"nativeMode=3D'%s'\" " - "in vlan element"), - nativeMode); - goto cleanup; - } - VIR_FREE(nativeMode); - def->nativeTag =3D id; + + def->nativeMode =3D nativeMode; + def->nativeTag =3D def->tag[i]; } - def->tag[i] =3D id; } def->nTags =3D nTags; @@ -128,7 +124,6 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr = ctxt, virNetDevVlan *def) cleanup: VIR_FREE(tagNodes); VIR_FREE(trunk); - VIR_FREE(nativeMode); if (ret < 0) virNetDevVlanClear(def); return ret; --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666620995; cv=none; d=zohomail.com; s=zohoarc; b=P/kSymopUyGs2bXl5X22ivzwNZ3yIQgYRTi4uZARZSI9Pka9mVrqO5JyB5n3Dih9GzaF+SMRGIt2gS4n7HWe9a+o+O3/T+hAXICPdaKgTLbGRguy5WtmJ5pAnuq14/xR0P4k8L/N/aLrUDJaoW7xyvFdFpReirzQWm/M3XaIwaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666620995; 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=qSt04Y39rHf3oJDQZ/+pq3dgwEW1+5CUyDm8FPzs0u0=; b=Lc6Fo69ZBeq/gHnVDye/PkhZKz2Kzbn6iBPOX4DWFUDF4dyzsDUV47APeRYPFkYT6JqSaaKZr+aqA/JgLYegkwXfb5SUTq+WvxKvV6hUVKz+jgqpgfdPNC5USW4LC/ne29OqtFhfRpcqWNjcQGOzShJuJeN5srPZi21Goofyk+g= 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 1666620995673132.82847357348533; Mon, 24 Oct 2022 07:16:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-s5fUNE9_P0ew65ZPmCvrQA-1; Mon, 24 Oct 2022 10:16:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29FAC823F74; Mon, 24 Oct 2022 14:15:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 156D74C819; Mon, 24 Oct 2022 14:15:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E92F119465A8; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8912D194658D for ; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7E34940C2088; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCAD940C83AA for ; Mon, 24 Oct 2022 14:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620993; 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=qSt04Y39rHf3oJDQZ/+pq3dgwEW1+5CUyDm8FPzs0u0=; b=Z58m4oQAEi+vBxWPPAQwSVcn8sce7lPXmh1TmKj1MLABTksB7FUaonSj3mmL6YeIDTo9OS bUXY58wPNMBPgURS6ydelGAUf8u9HPqIg39hhzBjBcFatT6bPsc9m5PBCW4s60n/zQhqRf fiBxZgw7IHfVw8GUfEQ7rgwwR3mAUig= X-MC-Unique: s5fUNE9_P0ew65ZPmCvrQA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/43] virDomainTimerCatchupDef: Change members to 'unsigned long long' Date: Mon, 24 Oct 2022 16:14:35 +0200 Message-Id: <59010e4ab581927f6e3e9c46203920e6c17f481c.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1666620996533100002 Content-Type: text/plain; charset="utf-8" The struct used 'unsigned long' variables which we try to avoid due to being different size on different architectures. Convert the stuct and use virXMLPropULongLong instead of virXPathULong when parsing the XML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 34 +++++++++------------------------- src/conf/domain_conf.h | 6 +++--- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cdf05e8fae..ee9eb6bcc4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10610,33 +10610,17 @@ virDomainTimerDefParseXML(xmlNodePtr node, catchup =3D virXPathNode("./catchup", ctxt); if (catchup !=3D NULL) { - ret =3D virXPathULong("string(./catchup/@threshold)", ctxt, - &def->catchup.threshold); - if (ret =3D=3D -1) { - def->catchup.threshold =3D 0; - } else if (ret < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup threshold")); + if (virXMLPropULongLong(catchup, "threshold", 10, VIR_XML_PROP_NON= E, + &def->catchup.threshold) < 0) goto error; - } - ret =3D virXPathULong("string(./catchup/@slew)", ctxt, &def->catch= up.slew); - if (ret =3D=3D -1) { - def->catchup.slew =3D 0; - } else if (ret < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup slew")); + if (virXMLPropULongLong(catchup, "slew", 10, VIR_XML_PROP_NONE, + &def->catchup.slew) < 0) goto error; - } - ret =3D virXPathULong("string(./catchup/@limit)", ctxt, &def->catc= hup.limit); - if (ret =3D=3D -1) { - def->catchup.limit =3D 0; - } else if (ret < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid catchup limit")); + if (virXMLPropULongLong(catchup, "limit", 10, VIR_XML_PROP_NONE, + &def->catchup.limit) < 0) goto error; - } } return def; @@ -24896,11 +24880,11 @@ virDomainTimerDefFormat(virBuffer *buf, } if (def->catchup.threshold > 0) - virBufferAsprintf(&catchupAttr, " threshold=3D'%lu'", def->catchup= .threshold); + virBufferAsprintf(&catchupAttr, " threshold=3D'%llu'", def->catchu= p.threshold); if (def->catchup.slew > 0) - virBufferAsprintf(&catchupAttr, " slew=3D'%lu'", def->catchup.slew= ); + virBufferAsprintf(&catchupAttr, " slew=3D'%llu'", def->catchup.sle= w); if (def->catchup.limit > 0) - virBufferAsprintf(&catchupAttr, " limit=3D'%lu'", def->catchup.lim= it); + virBufferAsprintf(&catchupAttr, " limit=3D'%llu'", def->catchup.li= mit); virXMLFormatElement(&timerChld, "catchup", &catchupAttr, NULL); virXMLFormatElement(buf, "timer", &timerAttr, &timerChld); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8f8a54bc41..ba411bfa02 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2466,9 +2466,9 @@ struct _virDomainThreadSchedParam { }; struct _virDomainTimerCatchupDef { - unsigned long threshold; - unsigned long slew; - unsigned long limit; + unsigned long long threshold; + unsigned long long slew; + unsigned long long limit; }; struct _virDomainTimerDef { --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621005; cv=none; d=zohomail.com; s=zohoarc; b=bt9UdfdGFMeCl6yyqq7tTWqcc5N6lit5QiFcrmtpqJ4iSS+Sbbfwt+twXMgzG6zt+TCGHW+UvwRhrUUOPPr9e6w4SaTbFoAarMbxC/ibnyKFGb/gQ/Dm63rVdOcXQ8qLXKsVogaAk1s7jBaiRanN0zIGjZWYZSjPqATPkbj0fSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621005; 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=xi/svI7douv8A82OQCEPOc3mmCDU/Ml8qkFMTBwT/Bc=; b=PLIe5Csa01w3EN4tsOdTksyL4YkA0OSMicxD6GKYLoTVYU4X0CM2AG/QavzvGwv/DflkZFCEVG+C6ip3YPlS+bsAF8w+ZKxCcvlK45L/HlUQAgJEuQi/wKO+2Djo70o7Y/XTfvD0pz7X7iD2G/mrFIZS2lJ25A5P//VNMvQe/Zs= 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 1666621005005111.38097036919964; Mon, 24 Oct 2022 07:16:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-JMdMUgK4MRqgA0L2no07gQ-1; Mon, 24 Oct 2022 10:16:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BC9F3803914; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47C0C2028E94; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3267519465A2; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 77FC81946594 for ; Mon, 24 Oct 2022 14:15:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 66A5440C2088; Mon, 24 Oct 2022 14:15:42 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B064040C83AD for ; Mon, 24 Oct 2022 14:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621004; 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=xi/svI7douv8A82OQCEPOc3mmCDU/Ml8qkFMTBwT/Bc=; b=XIoaorv9+pD/1IbiH5QU4Ce8LUcVR0b301Y/+AlNzuEZoskZWrbNdU3lU3niIIE+G6kRFy zjB9LkdQ4a9EfSRsZ4QuW793UrP61Bh8jpwTsyfwZ5CPNXHxaKjv+N8mkMbbWcsQiajJrD NELceWOFmtwMe1saEDAeR1pAYK6Wiig= X-MC-Unique: JMdMUgK4MRqgA0L2no07gQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/43] virDomainTimerDefParseXML: Refactor cleanup Date: Mon, 24 Oct 2022 16:14:36 +0200 Message-Id: <29de36013849f76616728e7f0b45576d82c31646.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1666621006680100001 Content-Type: text/plain; charset="utf-8" Automatically free the 'def' variable and remove the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee9eb6bcc4..7c718ce799 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10542,7 +10542,7 @@ static virDomainTimerDef * virDomainTimerDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt) { - virDomainTimerDef *def; + g_autofree virDomainTimerDef *def =3D g_new0(virDomainTimerDef, 1); VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; @@ -10551,33 +10551,31 @@ virDomainTimerDefParseXML(xmlNodePtr node, g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; - def =3D g_new0(virDomainTimerDef, 1); - ctxt->node =3D node; name =3D virXMLPropString(node, "name"); if (name =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing timer name")); - goto error; + return NULL; } if ((def->name =3D virDomainTimerNameTypeFromString(name)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer name '%s'"), name); - goto error; + return NULL; } if (virXMLPropTristateBool(node, "present", VIR_XML_PROP_NONE, &def->present) < 0) - goto error; + return NULL; tickpolicy =3D virXMLPropString(node, "tickpolicy"); if (tickpolicy !=3D NULL) { if ((def->tickpolicy =3D virDomainTimerTickpolicyTypeFromString(ti= ckpolicy)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer tickpolicy '%s'"), tickpolicy); - goto error; + return NULL; } } @@ -10586,7 +10584,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, if ((def->track =3D virDomainTimerTrackTypeFromString(track)) <=3D= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer track '%s'"), track); - goto error; + return NULL; } } @@ -10596,7 +10594,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, } else if (ret < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid timer frequency")); - goto error; + return NULL; } mode =3D virXMLPropString(node, "mode"); @@ -10604,7 +10602,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) <=3D 0)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown timer mode '%s'"), mode); - goto error; + return NULL; } } @@ -10612,22 +10610,18 @@ virDomainTimerDefParseXML(xmlNodePtr node, if (catchup !=3D NULL) { if (virXMLPropULongLong(catchup, "threshold", 10, VIR_XML_PROP_NON= E, &def->catchup.threshold) < 0) - goto error; + return NULL; if (virXMLPropULongLong(catchup, "slew", 10, VIR_XML_PROP_NONE, &def->catchup.slew) < 0) - goto error; + return NULL; if (virXMLPropULongLong(catchup, "limit", 10, VIR_XML_PROP_NONE, &def->catchup.limit) < 0) - goto error; + return NULL; } - return def; - - error: - VIR_FREE(def); - return def; + return g_steal_pointer(&def); } --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621033; cv=none; d=zohomail.com; s=zohoarc; b=P8RbwBjgEggx/W4ahIlp+0qNatzcsyzPOY0q94nNfyKU0X+5s4Zb9HmlL9BY4geLy0UuJoHxFedGUqyzD+OpK7uyi8feAVL3yPL1PxL0M5NS8jAHjBpDMTBUk/HH5VMwAlfZJNCq1amxi3UUDBNWcmyHt9gCBCGgmDego6EGg2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621033; 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=DTtPWnDLzn4tfH0D6yuEN/jt2PFJrNJN8zseR7/pxdI=; b=Gjij4pL9xNOkDNofMEJOX68l7ZVURtarTrTDdCEmpXhI2rMjV1u6iiu7VOu/j0yVqYCYueWJPgaYOfaCbC7GzYqIC8Qw2qqqREXwfYhpo0dKGzBl+hixiA82IdzLCqMgdZXbE9WC9w6bv7FKUR5C/4d+BJM+p+4DXdylOzlCLyU= 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 1666621033731590.1009148227593; Mon, 24 Oct 2022 07:17:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-83-u4EGVHU4NK6FX5JtGsuOiQ-1; Mon, 24 Oct 2022 10:16:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FBE93C1486A; Mon, 24 Oct 2022 14:15:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF2AD202322E; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA5DA19465B1; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6A0951946597 for ; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5B01640C2089; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id C048640C2064 for ; Mon, 24 Oct 2022 14:15:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621032; 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=DTtPWnDLzn4tfH0D6yuEN/jt2PFJrNJN8zseR7/pxdI=; b=HD541egebcuK3+ahRFw5Z5UWZMvbSSPCw64oMlRTwbi8xn28/Tlfb5a9pWiS4qLrm5uQTF wCP8iMuq8Py1LXYhaOW+MFbEC+LPRm1ID3i4n3PStr/chqjUy8insaX4y6JvVthDL5U275 lPY6SqoImKrpbN4I/xRECFBMWLATUrw= X-MC-Unique: u4EGVHU4NK6FX5JtGsuOiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/43] virDomainTimerDef: Convert 'name' field to proper enum type Date: Mon, 24 Oct 2022 16:14:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1666621034968100005 Content-Type: text/plain; charset="utf-8" Adjust the type and the corresponding parser to use virXMLPropEnum. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 13 ++----------- src/conf/domain_conf.h | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c718ce799..aa949766e1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,24 +10546,15 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *name =3D NULL; g_autofree char *tickpolicy =3D NULL; g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; ctxt->node =3D node; - name =3D virXMLPropString(node, "name"); - if (name =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing timer name")); + if (virXMLPropEnum(node, "name", virDomainTimerNameTypeFromString, + VIR_XML_PROP_REQUIRED, &def->name) < 0) return NULL; - } - if ((def->name =3D virDomainTimerNameTypeFromString(name)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer name '%s'"), name); - return NULL; - } if (virXMLPropTristateBool(node, "present", VIR_XML_PROP_NONE, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba411bfa02..de6aefed2d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2472,7 +2472,7 @@ struct _virDomainTimerCatchupDef { }; struct _virDomainTimerDef { - int name; + virDomainTimerNameType name; virTristateBool present; int tickpolicy; /* enum virDomainTimerTickpolicyType */ --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621000; cv=none; d=zohomail.com; s=zohoarc; b=akHFpRHw6Nyr+zFP8z7fvJ0vgj6QaSBSdhWb5rQffnBkSRdyi8vBxbIDAOtmOYvMyC5+UBqbbtD7yp0bpLBr6bSySkaRCSE7ahwEBeiGyMDw0l0YyITX5HugWZXN/dXKDNLtrWIpmEoyBglQRfoC8svh0RXnVB8WLuokj+fvJOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621000; 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=sfvGitCSLtQQ7029/Cavd5aaidXkgpVi1jK5+8vEOQA=; b=PV91Z9GaDB5NFJ+d1NsJB4VC5ZzHLEDsT9xAgHDNiLKiC/3+9zoth3vswAQ5DlGaDC/aHZWi1GKV49egSWmdIftDUJABm7rAz98BqTIYPhDXHyB3feiy7MFS37LABJdiLgPfYGBVMiTs/lgReleUccyih8+eZgnbDAW/IHEI5zE= 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 1666621000547250.75213407692547; Mon, 24 Oct 2022 07:16:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-356-RtcAjzdNOjyj7_W1Sa4r2w-1; Mon, 24 Oct 2022 10:16:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A65981F46A; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68A5240C2064; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5D3781946595; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A9D3619465A2 for ; Mon, 24 Oct 2022 14:15:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9D04E40C2088; Mon, 24 Oct 2022 14:15:44 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1838F40C2089 for ; Mon, 24 Oct 2022 14:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666620999; 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=sfvGitCSLtQQ7029/Cavd5aaidXkgpVi1jK5+8vEOQA=; b=AW5nvb6BUMLV6RZS1GBBm7nxHfMMINPtzCuDPQs90l2AxnYOM0+wEM4D6r90WYcwAn92um ogQtBo226IeJYy/AOdw6esc67nJvlBO2Qk/Yl2D8stwCTK8EhW/hBRNUyXFxHwlymkdY6r 4M5BgpNkYxTQujgYwv30Ak7qMVPJ7p0= X-MC-Unique: RtcAjzdNOjyj7_W1Sa4r2w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/43] virDomainTimerDef: Convert 'tickpolicy' field to proper enum type Date: Mon, 24 Oct 2022 16:14:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: 1666621002582100010 Content-Type: text/plain; charset="utf-8" Convert the field, adjust the XML parser to use virXMLPropEnum and add the VIR_DOMAIN_TIMER_TICKPOLICY_LAST enum case to all appropriate 'switch' statements. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 +++--------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_validate.c | 6 ++++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aa949766e1..4810aa7b82 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *tickpolicy =3D NULL; g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; @@ -10561,14 +10560,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, &def->present) < 0) return NULL; - tickpolicy =3D virXMLPropString(node, "tickpolicy"); - if (tickpolicy !=3D NULL) { - if ((def->tickpolicy =3D virDomainTimerTickpolicyTypeFromString(ti= ckpolicy)) <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer tickpolicy '%s'"), tickpolicy); - return NULL; - } - } + if (virXMLPropEnum(node, "tickpolicy", virDomainTimerTickpolicyTypeFro= mString, + VIR_XML_PROP_NONZERO, &def->tickpolicy) < 0) + return NULL; track =3D virXMLPropString(node, "track"); if (track !=3D NULL) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index de6aefed2d..2733d12fcd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2474,7 +2474,7 @@ struct _virDomainTimerCatchupDef { struct _virDomainTimerDef { virDomainTimerNameType name; virTristateBool present; - int tickpolicy; /* enum virDomainTimerTickpolicyType */ + virDomainTimerTickpolicyType tickpolicy; virDomainTimerCatchupDef catchup; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 150824f2e1..7507ab46ab 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5747,6 +5747,8 @@ qemuBuildClockArgStr(virDomainClockDef *def) case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE: case VIR_DOMAIN_TIMER_TICKPOLICY_DISCARD: return NULL; + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: + break; } break; /* no need to check other timers - there is only one rt= c */ } @@ -5818,6 +5820,8 @@ qemuBuildClockCommandLine(virCommand *cmd, case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE: /* no way to support this mode for pit in qemu */ return -1; + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: + break; } break; @@ -6201,6 +6205,7 @@ qemuBuildCpuCommandLine(virCommand *cmd, case VIR_DOMAIN_TIMER_TICKPOLICY_NONE: case VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP: case VIR_DOMAIN_TIMER_TICKPOLICY_MERGE: + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: break; } break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 079009ea4b..f8f2a0fd32 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -572,6 +572,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, virDomainTimerTickpolicyTypeToString( timer->tickpolicy)); return -1; + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: + break; } break; @@ -598,6 +600,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, virDomainTimerTickpolicyTypeToString( timer->tickpolicy)); return -1; + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: + break; } break; @@ -650,6 +654,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, virDomainTimerNameTypeToString(timer->name), virDomainTimerTickpolicyTypeToString(timer-= >tickpolicy)); return -1; + case VIR_DOMAIN_TIMER_TICKPOLICY_LAST: + break; } break; } --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621010; cv=none; d=zohomail.com; s=zohoarc; b=AtGsaNb6WOdrghLWLEdHloMcU+0TZEsDOz4+mDygUnIxxEBokjfK+dtA6suei+nc2GithcysKNUQ+J5C2qgIvZe8LNAb/AIMCj50Gh73kfp7u4AV3Ar63pnEwI53clUDVga70SNd1V2CI5INX4F7KYbz7aMNfqMffkv/z64wItk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621010; 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=0MCL8Ea4XY5WJdTxnSi+3enChYsCjCjObunhTsgwHWE=; b=ERJ99WXnkbcDj5fwMpx67+5uW+ck8v3IJTwRDgvYVlbEU7vMd+Cu/gW61Vh9cvpTDhC9hLvYlweiqThFoxjnoxaYwWi/7+xOtltQBQZ9Bw5IGoj7Zk25YVZIiO+8LUTcnyq0Nbymeysdjvgs171BLsPKhNN1mtx5DmPPN4FcuOw= 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 1666621010346672.7810754812749; Mon, 24 Oct 2022 07:16:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-Zy3pVRMoMI6rv78zmId2tA-1; Mon, 24 Oct 2022 10:16:39 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C77CC86EB38; Mon, 24 Oct 2022 14:15:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2DDC492B0A; Mon, 24 Oct 2022 14:15:47 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A850C1946595; Mon, 24 Oct 2022 14:15:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64EF819465A0 for ; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 58A5040C2064; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9779740C2089 for ; Mon, 24 Oct 2022 14:15:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621009; 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=0MCL8Ea4XY5WJdTxnSi+3enChYsCjCjObunhTsgwHWE=; b=gyD6H29bgmkSMLp/Q7JezrfdaJLWOGP8ugtXOSnoYeejT4CUWTJuntQKu+o/IAIspEyvZM 0CB7RZGjgylVpKoic2ZwK7nQw+FqMGpP+KlRzIL7PovWqImG2HzgDuJy7O8zVZEJGlmyQH SUBaHzOzB4osPn17z/PxhUR6oZZ3JRI= X-MC-Unique: Zy3pVRMoMI6rv78zmId2tA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/43] virDomainTimerDef: Convert 'track' field to proper enum type Date: Mon, 24 Oct 2022 16:14:39 +0200 Message-Id: <849934a4ca491bf73a55a19f45b537bf22d11448.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1666621010651100006 Content-Type: text/plain; charset="utf-8" Adjust the parser and add missing switch cases to make the complier happy. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 13 ++++--------- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 ++ src/qemu/qemu_validate.c | 2 ++ 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4810aa7b82..d91c058868 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; ctxt->node =3D node; @@ -10564,14 +10563,10 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XML_PROP_NONZERO, &def->tickpolicy) < 0) return NULL; - track =3D virXMLPropString(node, "track"); - if (track !=3D NULL) { - if ((def->track =3D virDomainTimerTrackTypeFromString(track)) <=3D= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer track '%s'"), track); - return NULL; - } - } + if (virXMLPropEnum(node, "track", virDomainTimerTrackTypeFromString, + VIR_XML_PROP_NONZERO, &def->track) < 0) + return NULL; + ret =3D virXPathULongLong("string(./@frequency)", ctxt, &def->frequenc= y); if (ret =3D=3D -1) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2733d12fcd..36b6757c3c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2479,7 +2479,7 @@ struct _virDomainTimerDef { virDomainTimerCatchupDef catchup; /* track is only valid for name=3D'platform|rtc' */ - int track; /* enum virDomainTimerTrackType */ + virDomainTimerTrackType track; /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7507ab46ab..bf82878e7a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5732,6 +5732,8 @@ qemuBuildClockArgStr(virDomainClockDef *def) case VIR_DOMAIN_TIMER_TRACK_REALTIME: virBufferAddLit(&buf, ",clock=3Drt"); break; + case VIR_DOMAIN_TIMER_TRACK_LAST: + break; } switch (def->timers[i]->tickpolicy) { diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f8f2a0fd32..1456a69351 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -554,6 +554,8 @@ qemuValidateDomainDefClockTimers(const virDomainDef *de= f, _("unsupported rtc timer track '%s'"), virDomainTimerTrackTypeToString(timer->trac= k)); return -1; + case VIR_DOMAIN_TIMER_TRACK_LAST: + break; } switch (timer->tickpolicy) { --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621009; cv=none; d=zohomail.com; s=zohoarc; b=S0jxsVxDBfo6wqAMnEJrSKKys/gJG64sqTgumeESFE2eT2nBgmzLm6bS4tWsbaowuKbpBnrk/TmVr0JtdpxBjkoOT7T+17kBHj7PNNVRpDPhTL/ko1Sfazar3KOsJox+s2hvKd3cUZ2uXrMA+R5eOymoq+KiUu0ZBFh4Zzy6uXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621009; 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=mcQ5aYgdLg61CSyuFljTaOHcrbjplAVJchF0aRy8Adc=; b=cbE/9v7qp2oSzaiy2gAsrcFMFhPYv7/1xJWtG79HC5QLMCIJtNKSxP6Cao5KzLIL7WGwt9vyK0DNsPEKC7LMroNBWZu0JlDsW6uEtVGqyiWcAMAOfrDG2uG24s5XIIaOeoTsn3r9XUinojh4B7PZCU59OtDPiEPCRg/5xqMyhGQ= 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 166662100983784.17118400561299; Mon, 24 Oct 2022 07:16:49 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-cJbA71ZJO-mw9Q75z5mGpA-1; Mon, 24 Oct 2022 10:16:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22C0A80253E; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CDFD1415117; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E5A7E1946594; Mon, 24 Oct 2022 14:15:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0D035194658D for ; Mon, 24 Oct 2022 14:15:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0081940C2140; Mon, 24 Oct 2022 14:15:48 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24FE840C2064 for ; Mon, 24 Oct 2022 14:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621007; 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=mcQ5aYgdLg61CSyuFljTaOHcrbjplAVJchF0aRy8Adc=; b=OuIcgIFE6X5lHmawsSvt0QfBYZzdYhiQYQ9FFbzMijj4yFvDQukcVS/2KQ57Ar1SVnqKRr Q2k5ujzX69/jlODPWR+86U2eNw90yuxz/KPtA8hbsI5/0RYRHezzRzZbepjLzhelvDuPDd Fcqd/HhXNnhDfs0VpjBf92D21R0Dx9g= X-MC-Unique: cJbA71ZJO-mw9Q75z5mGpA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/43] virDomainTimerDef: Convert 'mode' field to proper enum type Date: Mon, 24 Oct 2022 16:14:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1666621010640100005 Content-Type: text/plain; charset="utf-8" Adjust the parser and switch statements to go with it. Note that the XEN/libxl drivers had a 'default:' case for few of the swtich statements so this patch blindly expands it to what it would be in those cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 12 +++--------- src/conf/domain_conf.h | 2 +- src/libxl/libxl_conf.c | 6 +++++- src/libxl/xen_common.c | 6 +++++- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d91c058868..6c976b366a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *mode =3D NULL; ctxt->node =3D node; @@ -10577,14 +10576,9 @@ virDomainTimerDefParseXML(xmlNodePtr node, return NULL; } - mode =3D virXMLPropString(node, "mode"); - if (mode !=3D NULL) { - if ((def->mode =3D virDomainTimerModeTypeFromString(mode)) <=3D 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer mode '%s'"), mode); - return NULL; - } - } + if (virXMLPropEnum(node, "mode", virDomainTimerModeTypeFromString, + VIR_XML_PROP_NONZERO, &def->mode) < 0) + return NULL; catchup =3D virXPathNode("./catchup", ctxt); if (catchup !=3D NULL) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 36b6757c3c..f5825138e7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2483,7 +2483,7 @@ struct _virDomainTimerDef { /* frequency & mode are only valid for name=3D'tsc' */ unsigned long long frequency; /* in Hz, unspecified =3D 0 */ - int mode; /* enum virDomainTimerModeType */ + virDomainTimerModeType mode; }; typedef enum { diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 918303c8d0..d13e48abb2 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -409,8 +409,12 @@ libxlMakeDomBuildInfo(virDomainDef *def, case VIR_DOMAIN_TIMER_MODE_EMULATE: b_info->tsc_mode =3D LIBXL_TSC_MODE_ALWAYS_EMULATE; break; - default: + case VIR_DOMAIN_TIMER_MODE_NONE: + case VIR_DOMAIN_TIMER_MODE_AUTO: + case VIR_DOMAIN_TIMER_MODE_SMPSAFE: b_info->tsc_mode =3D LIBXL_TSC_MODE_DEFAULT; + case VIR_DOMAIN_TIMER_MODE_LAST: + break; } break; diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 6918a4b121..f61719adac 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -2102,9 +2102,13 @@ xenFormatHypervisorFeatures(virConf *conf, virDomain= Def *def) if (xenConfigSetString(conf, "tsc_mode", "always_emulate")= < 0) return -1; break; - default: + case VIR_DOMAIN_TIMER_MODE_NONE: + case VIR_DOMAIN_TIMER_MODE_AUTO: + case VIR_DOMAIN_TIMER_MODE_SMPSAFE: if (xenConfigSetString(conf, "tsc_mode", "default") < 0) return -1; + case VIR_DOMAIN_TIMER_MODE_LAST: + break; } break; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621011; cv=none; d=zohomail.com; s=zohoarc; b=BNNfH9ayvwtAX27uPltWIUBZD7dM1dCNGyiRH8lQTLKsX1PmrFtL35E3X6DaUxlfPr2JIoYXipuFM/s+Sl/9/6L16i8PQrtdoKkoR7fFCKL5VkVqkXBIf0qxrOVII6GXe62s+M8r/Aqc0S/HRMveuev4B96vmrnqtIxu2s3j7js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621011; 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=B6ZHhvN89HqlAYPChYY5uDRD4Pjhuv9u6kPQiBq9Jyw=; b=bC+CyLR2p3aUAHEtaD0aVZR8O75hgyT9t1+Nm4kzEGNozN/UEaRMkMRIlVgIM3W+1P/DNtXKwK8TIxAb2OVPpkrybFmC/euuLrrk0lhKRxmTPEzBXOA/nwIje9dphzYLsE9NP+vXmWs+v6vbZYa9oiyICy2cGaTcrmBw3g1GHKY= 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 1666621011269586.78252110852; Mon, 24 Oct 2022 07:16:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-rWOTjXEpMMubqgEnLN7VZA-1; Mon, 24 Oct 2022 10:16:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D27086F12C; Mon, 24 Oct 2022 14:15:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4826940C6FA0; Mon, 24 Oct 2022 14:15:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38A7719465A3; Mon, 24 Oct 2022 14:15:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B39A0194658D for ; Mon, 24 Oct 2022 14:15:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A717540C83AA; Mon, 24 Oct 2022 14:15:49 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DAF840C2064 for ; Mon, 24 Oct 2022 14:15:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621010; 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=B6ZHhvN89HqlAYPChYY5uDRD4Pjhuv9u6kPQiBq9Jyw=; b=MU5dAwychEn/fHumq5nKLjYgaYw1rxdcj+lrxySbF1EwT5rhYjBAIBDPXVraNd+rOylpZj qBOjHqbE34y14E4/6gRlkD9eKLfV4+a18SJhIbRv4xN8t790gTGxVTwjnlDTndLhdP+QCo O2MsOVSPLM/WpKStxtNKed9OmTxNpg0= X-MC-Unique: rWOTjXEpMMubqgEnLN7VZA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 36/43] virDomainTimerDefParseXML: Use virXMLProp instead of virXPath Date: Mon, 24 Oct 2022 16:14:41 +0200 Message-Id: <8d96cd431ab669ef0d06ba32fbe87d2f9afb61ac.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1666621012836100001 Content-Type: text/plain; charset="utf-8" Parse the 'frequency' field without an extra XPath. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c976b366a..2d01693a31 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10545,7 +10545,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, g_autofree virDomainTimerDef *def =3D g_new0(virDomainTimerDef, 1); VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; - int ret; ctxt->node =3D node; @@ -10566,15 +10565,8 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XML_PROP_NONZERO, &def->track) < 0) return NULL; - - ret =3D virXPathULongLong("string(./@frequency)", ctxt, &def->frequenc= y); - if (ret =3D=3D -1) { - def->frequency =3D 0; - } else if (ret < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("invalid timer frequency")); + if (virXMLPropULongLong(node, "frequency", 10, VIR_XML_PROP_NONE, &def= ->frequency) < 0) return NULL; - } if (virXMLPropEnum(node, "mode", virDomainTimerModeTypeFromString, VIR_XML_PROP_NONZERO, &def->mode) < 0) --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621144; cv=none; d=zohomail.com; s=zohoarc; b=Tmkn0qOK7FzLzOrt2t4XBPs/wE8EGPEGgh0CTHGUdRGYLN8rdqP0IRkJMoaZwHpelQVA1Jivb1p/UaHKObvvBHtLGyo89cPnU0wmi5DA9jNAHL7WuNR+3uq1nJGEMQkLcz8hspAE18Ozy+u2Jw4QAxDWsgbwkTlIHLxAVfhgkJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621144; 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=MiL1NKe/6Uxfs7OiabnE73+v9JFJI7H9JNKpjpq5UW8=; b=FV5rvV+JP+rBOR4I/IOBHkQ+2M3nOIotxGkfgoV+fgvs3ZjI1oPn8MruvwIy99UGVcW4kL/E6KBRvlWXsdP/iR8Cdfi0MpcOUCYR/kxDlv/D6zVlXb60OxLS0LHFy1fxFpnIUIccOTX3qKHfJv1mJB/bg+uURcvZ53gFqyyj6+0= 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 1666621144472862.9049993074324; Mon, 24 Oct 2022 07:19:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-383-v90ZwJEkN2aYNZk5M5rp3A-1; Mon, 24 Oct 2022 10:16:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 548A01C004FB; Mon, 24 Oct 2022 14:15:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F882112132E; Mon, 24 Oct 2022 14:15:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 01CEC194658F; Mon, 24 Oct 2022 14:15:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B8A14194658D for ; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AE33D40C2088; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CE5940C2064 for ; Mon, 24 Oct 2022 14:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621143; 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=MiL1NKe/6Uxfs7OiabnE73+v9JFJI7H9JNKpjpq5UW8=; b=Dz30n+WnX22pl7khlQnBp8IfmWVSGD1lg7uXqpe21rtiTAQJ5LXaWTDAl4+6Kgn0c0KOEp 7sctJcVc4Cw5wVfneyG0U9lCp+ZkxnFWd+IOUP4PIufhycTECKdaMFZlcFE7KjtIVoohWO PGbQPMZ+l7zGTMXE9b5HFaPryelOzBg= X-MC-Unique: v90ZwJEkN2aYNZk5M5rp3A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 37/43] virDomainNetDef: Change type of 'tune.sndbuf' Date: Mon, 24 Oct 2022 16:14:42 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1666621145539100001 Content-Type: text/plain; charset="utf-8" Use 'unsigned long long' instead of 'unsigned long' and fix the parser and formatter. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2d01693a31..7c6caa01e5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9376,7 +9376,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (virDomainNetTeamingInfoParseXML(ctxt, &def->teaming) < 0) return NULL; - rv =3D virXPathULong("string(./tune/sndbuf)", ctxt, &def->tune.sndbuf); + rv =3D virXPathULongLong("string(./tune/sndbuf)", ctxt, &def->tune.snd= buf); if (rv >=3D 0) { def->tune.sndbuf_specified =3D true; } else if (rv =3D=3D -2) { @@ -23585,7 +23585,7 @@ virDomainNetDefFormat(virBuffer *buf, if (def->tune.sndbuf_specified) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "%lu\n", def->tune.sndbuf); + virBufferAsprintf(buf, "%llu\n", def->tune.sndbuf= ); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f5825138e7..54dc9098df 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1146,7 +1146,7 @@ struct _virDomainNetDef { virNetDevVPortProfile *virtPortProfile; struct { bool sndbuf_specified; - unsigned long sndbuf; + unsigned long long sndbuf; } tune; char *script; char *downscript; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621084; cv=none; d=zohomail.com; s=zohoarc; b=XuFipgiKKCMrWm1OYOvIoJML07nfo+pzHKq3oMVtbeDC8f4H7YHFarnXtuYWrDlqoiFdPftM1kG4JGoxTyrSro7XEDslx9sjgUS9dHJVSwv/YDoVcYalG98H84kcuiQBi7E+/uJSQ/2ZlbN0uiGQWLqvKopn79qxRFVAYwz+FO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621084; 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=eojYjVGE/mEtgn/OGikvLeNqJJM1be2gb4Xb5NKfyDc=; b=P7CbBkjg/mHUm4RaQHmLXx2J0NE6GlEvp19pP+Z2VgT7z4dOhjKKyBf8bTq9WO5PncfMzd4v5oU1DZzaLXOk9361asTurZdg9Duw1d+hrSWgphAFJMt3tq1DFK3Dp8+SEZoYOZAmI7H+jX4/Xm2kVUr03de/D/Hd8zA2wAbGMNE= 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 1666621084566133.22255635078068; Mon, 24 Oct 2022 07:18:04 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-kotf9DzXMgWnSdPOgLEJbA-1; Mon, 24 Oct 2022 10:16:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDBF2823F77; Mon, 24 Oct 2022 14:15:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C89F6C15BB2; Mon, 24 Oct 2022 14:15:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BACCE194658F; Mon, 24 Oct 2022 14:15:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5D709194658F for ; Mon, 24 Oct 2022 14:15:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4218440C2064; Mon, 24 Oct 2022 14:15:52 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA9BF40C83AD for ; Mon, 24 Oct 2022 14:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621083; 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=eojYjVGE/mEtgn/OGikvLeNqJJM1be2gb4Xb5NKfyDc=; b=DIyxGmCPoD0Z9WuA0vT821LybIQX+1ciPkRd2/Aq9YerSSijhPnAEqrfteTMZrHmD3Xq25 OKrGWu5oqDqMaIK6I/fk1wq4Vvs6DKsPlYcesE0TJeGvmaSFm0nM2w0Gmd6m9bCUjie1p1 CwEH0njv6Bq8Bs4bLPppm2AU7TEQ0YE= X-MC-Unique: kotf9DzXMgWnSdPOgLEJbA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 38/43] virDomainSEVDefParseXML: Use virXPathUIntBase instead of virXPathULongHex Date: Mon, 24 Oct 2022 16:14:43 +0200 Message-Id: <53d7a7f64c8f768ebdabe1a50db66163e56733fe.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1666621085330100001 Content-Type: text/plain; charset="utf-8" Use the proper function for an unsigned int. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c6caa01e5..8b1a28c0d3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13178,14 +13178,13 @@ static int virDomainSEVDefParseXML(virDomainSEVDef *def, xmlXPathContextPtr ctxt) { - unsigned long policy; int rc; if (virXMLPropTristateBool(ctxt->node, "kernelHashes", VIR_XML_PROP_NO= NE, &def->kernel_hashes) < 0) return -1; - if (virXPathULongHex("string(./policy)", ctxt, &policy) < 0) { + if (virXPathUIntBase("string(./policy)", ctxt, 16, &def->policy) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("failed to get launch security policy")); return -1; @@ -13214,7 +13213,6 @@ virDomainSEVDefParseXML(virDomainSEVDef *def, return -1; } - def->policy =3D policy; def->dh_cert =3D virXPathString("string(./dhCert)", ctxt); def->session =3D virXPathString("string(./session)", ctxt); --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621018; cv=none; d=zohomail.com; s=zohoarc; b=dYhXZah+xbN7hrjtlP4r59+VDGLFtJQdFmqZGi+VQjAh+zpRqeZ97rTf3fzE3Sm/1wkUP4mO0YwW/KT3a5b59ODCktrm+InjgGrPULZ1jtsvzVpKO9W88RTL/nQgwCAROvPxG9qzJ6DzLGPJyXtuSlH4IPJknr6Pll5TS+vZGpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621018; 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=d13ebuApMhIX993nPA+VmBT6b8qDTZnVasgzKZ8Wm5A=; b=kl7vDKP+hgigQV1/IwYdrl/fVQ65oWfymyrLqXf1ryVcrVU/Xei18txMdpq/YaiRW3d2cpc3aeckS8gLreZOywV7BxYD3lroc47JHrrffgSCp8cgOtm5/WWYJLhjKBAP/t9YCr2tGV0ZwZT/aCGPveOKzVZZ/8CSwLwxuG1Q6Z4= 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 1666621018850691.8887993080324; Mon, 24 Oct 2022 07:16:58 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-iLF_LHIEN9Cy-xtAC7q9xg-1; Mon, 24 Oct 2022 10:16:54 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B37861C0A115; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FA91492B0A; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 81E1A194658F; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D3E2A194658D for ; Mon, 24 Oct 2022 14:15:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C9CD540C2064; Mon, 24 Oct 2022 14:15:53 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BCBE40C2088 for ; Mon, 24 Oct 2022 14:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621017; 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=d13ebuApMhIX993nPA+VmBT6b8qDTZnVasgzKZ8Wm5A=; b=UenLadd9irrYD7In0gCWzP0u0xv7cEuf6BIQfpTYMc4w4BEBQBgyOekOaD4qFIveL4EUxX 01HYQhBcfnVIVUJvDMs42onnI3IgOFMIf1rI47TFiuubqfrd3Ov3LD4a7ZSRVIKKWIK02l X4GNr8CXNRiXoXvGgUUF22rUG8qJWnY= X-MC-Unique: iLF_LHIEN9Cy-xtAC7q9xg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 39/43] ppc64ModelParse: Switch to virXMLPropUInt from virXPathULongHex Date: Mon, 24 Oct 2022 16:14:44 +0200 Message-Id: <586833bb8cc303bab29b8ec606e22caff94ecf48.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1666621020889100001 Content-Type: text/plain; charset="utf-8" We don't need to do the extra XPath lookups and we can use the proper type right away. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_ppc64.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index 7da67ec94a..30db99cca1 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -305,7 +305,6 @@ ppc64ModelParse(xmlXPathContextPtr ctxt, g_autoptr(virCPUppc64Model) model =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *vendor =3D NULL; - unsigned long pvr; size_t i; int n; @@ -346,23 +345,13 @@ ppc64ModelParse(xmlXPathContextPtr ctxt, model->data.len =3D n; for (i =3D 0; i < n; i++) { - ctxt->node =3D nodes[i]; - - if (virXPathULongHex("string(./@value)", ctxt, &pvr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing or invalid PVR value in CPU model %s= "), - model->name); + if (virXMLPropUInt(nodes[i], "value", 16, VIR_XML_PROP_REQUIRED, + &model->data.pvr[i].value) < 0) return -1; - } - model->data.pvr[i].value =3D pvr; - if (virXPathULongHex("string(./@mask)", ctxt, &pvr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing or invalid PVR mask in CPU model %s"= ), - model->name); + if (virXMLPropUInt(nodes[i], "mask", 16, VIR_XML_PROP_REQUIRED, + &model->data.pvr[i].mask) < 0) return -1; - } - model->data.pvr[i].mask =3D pvr; } VIR_APPEND_ELEMENT(map->models, map->nmodels, model); --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621011; cv=none; d=zohomail.com; s=zohoarc; b=LlmtV1kzIL77w6n+mTpMwUg+mhFyebWZYGIZ/KG0uqYDjYkj44CZdwJX14vEG1IDLi16rgyW7neMeDgHvl14wc3p3ajD7xrh2km1gQANvmcdtBONKgSiDdEvWER5TUQYx3Y73IooH2yRMGd00YOA0hGtsRikppxjZvQFpJvOHWc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621011; 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=PNqQJCcgfA/2EXLO8vxsRnazlfScvaibgkvV0ifA998=; b=VqEwuDaDXxBC0vAaH8NH88Zngqviccw95b/zf6axYj5bZDdkccEgoav29O182g+RkcRL6n2JdrAlkhZC9M7v0Bo0Hr/HTG+AAgo+l4o/YcDVWoSJJSNjzyHHBdhcWaGr92aVNxxSCW1Ruf5mkeert06kEHDyszRh72Q0Z+po8GE= 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 1666621011341780.5104301117713; Mon, 24 Oct 2022 07:16:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-NguW_lwMMAmQlEVQdder2A-1; Mon, 24 Oct 2022 10:16:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA3BB87B2B7; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7C5B201F403; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8AD1919465A2; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6EEED194658D for ; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3AC3140C2140; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 445B940C2064 for ; Mon, 24 Oct 2022 14:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621010; 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=PNqQJCcgfA/2EXLO8vxsRnazlfScvaibgkvV0ifA998=; b=c7l5DRFQHh1XrzvyUCeD+cUjEzuSETUzycCzZcftA/3QCvkV3fTd+UGCrg8VxfxAyVGjVL PMSsjNGMBdtI7FktinXCqIX6nYyj8ogy+I1oTLvEusvUsSXNHK8zvzLVNt20MLeHgaXBDg OwQX2cmC/JzBmRiUHet5Eg36MjTto/I= X-MC-Unique: NguW_lwMMAmQlEVQdder2A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 40/43] qemuDomainObjPrivateXMLParseBlockjobData: Use virXMLPropUInt instead of virXPathULongHex Date: Mon, 24 Oct 2022 16:14:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1666621012847100002 Content-Type: text/plain; charset="utf-8" Use the function for the proper type. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9ef6c8bb64..c3afc6c9d3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2764,7 +2764,6 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= *vm, int newstate =3D -1; bool invalidData =3D false; xmlNodePtr tmp; - unsigned long jobflags =3D 0; ctxt->node =3D node; @@ -2804,7 +2803,8 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= *vm, STRNEQ(mirror, "yes")) invalidData =3D true; - if (virXPathULongHex("string(./@jobflags)", ctxt, &jobflags) !=3D 0) + if (virXMLPropUInt(ctxt->node, "jobflags", 16, VIR_XML_PROP_NONE, + &job->jobflags) !=3D 1) job->jobflagsmissing =3D true; if (!disk && !invalidData) { @@ -2826,7 +2826,6 @@ qemuDomainObjPrivateXMLParseBlockjobData(virDomainObj= *vm, job->state =3D state; job->newstate =3D newstate; - job->jobflags =3D jobflags; job->errmsg =3D virXPathString("string(./errmsg)", ctxt); job->invalidData =3D invalidData; job->disk =3D disk; --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621092; cv=none; d=zohomail.com; s=zohoarc; b=eycxCSAVnHz52FPni2VTiVrgHvzz5mrL3jFb5/fABcUYwb1Te+GX7ACpBWmu8FUmya8qniy8bL5nXQ/YQP0Hz/UEsNKqQZ9V7aidH5Z9jWN+U99OCTjnz845j4GTBpLWMPQ+9LByPEYEe/EO/fWo8Nr+/e/SLOvMnMtNK+DaScQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621092; 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=BH8OL5LXqf8NcRy+ePDI5993kAKa6jHTNScRGpy3O/A=; b=ZWzZlv6SpIO/f0NeqX3j5O5mCtoZ9XtwCub1QsbE7pyLE+m7rbea7Ma56lzfgn3SVPPAeJq4nJkjIsvJkz0WqSW2b/wH7mR6mWpVIgt3UQXKfyK0SvIGJfm9ghLyS0uGS5fT5hmLTGQdBBrXVujR9o9JZ/GDpJAiQZEk3enK8ss= 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 1666621092539482.46276941885105; Mon, 24 Oct 2022 07:18:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-GbIW52kmPS-tzXeO8FIL-Q-1; Mon, 24 Oct 2022 10:16:51 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D749823F91; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64B79492CA2; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 413EC194658F; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C82FF194658F for ; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B0DA540C2140; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72A440C2064 for ; Mon, 24 Oct 2022 14:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621091; 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=BH8OL5LXqf8NcRy+ePDI5993kAKa6jHTNScRGpy3O/A=; b=T25VOjbH6N99RrRLuPLDw47TE9VaEFGN5F2lR91AB2l7TCtLsM5ug2YMgeIXggVKI5H1kj AQSuZEC8Dk4HPZM8SdJq1PIg6FL955d++mY31oL4Da3hEznzfXuRMOu5RJP1Td8tFSDZG3 2x+UxWx6KtUdRfsMz9SEZ8UkkNLCukk= X-MC-Unique: GbIW52kmPS-tzXeO8FIL-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 41/43] virDomainJobObj: Use 'unsigned int' instead of 'unsigned long' for 'apiFlags' field Date: Mon, 24 Oct 2022 16:14:46 +0200 Message-Id: <3796569dd86d9e0b187e2a798e8c7e438e70aa4a.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1666621093351100001 Content-Type: text/plain; charset="utf-8" The callers store only an 'unsigned int' in the field. Convert it to the proper type including parser/formatter. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/virdomainjob.c | 4 ++-- src/conf/virdomainjob.h | 4 ++-- src/qemu/qemu_domainjob.c | 7 +++---- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_migration_params.c | 8 ++++---- src/qemu/qemu_migration_params.h | 4 ++-- src/qemu/qemu_process.c | 2 +- src/qemu/qemu_process.h | 2 +- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index ca0215bc23..256b665a42 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -431,7 +431,7 @@ virDomainObjBeginJobInternal(virDomainObj *obj, VIR_WARN("Cannot start job (%s, %s, %s) in API %s for domain %s; " "current job is (%s, %s, %s) " - "owned by (%llu %s, %llu %s, %llu %s (flags=3D0x%lx)) " + "owned by (%llu %s, %llu %s, %llu %s (flags=3D0x%x)) " "for (%llus, %llus, %llus)", virDomainJobTypeToString(job), virDomainAgentJobTypeToString(agentJob), @@ -550,7 +550,7 @@ virDomainObjBeginAgentJob(virDomainObj *obj, int virDomainObjBeginAsyncJob(virDomainObj *obj, virDomainAsyncJob asyncJob, virDomainJobOperation operation, - unsigned long apiFlags) + unsigned int apiFlags) { if (virDomainObjBeginJobInternal(obj, obj->job, VIR_JOB_ASYNC, VIR_AGENT_JOB_NONE, diff --git a/src/conf/virdomainjob.h b/src/conf/virdomainjob.h index c101334596..b1ac36a2fa 100644 --- a/src/conf/virdomainjob.h +++ b/src/conf/virdomainjob.h @@ -182,7 +182,7 @@ struct _virDomainJobObj { virDomainJobData *completed; /* statistics data of a recently comp= leted job */ bool abortJob; /* abort of the job requested */ char *error; /* job event completion error */ - unsigned long apiFlags; /* flags passed to the API which started the a= sync job */ + unsigned int apiFlags; /* flags passed to the API which started the as= ync job */ void *privateData; /* job specific collection of data= */ virDomainObjPrivateJobCallbacks *cb; @@ -255,7 +255,7 @@ int virDomainObjBeginAgentJob(virDomainObj *obj, int virDomainObjBeginAsyncJob(virDomainObj *obj, virDomainAsyncJob asyncJob, virDomainJobOperation operation, - unsigned long apiFlags) + unsigned int apiFlags) G_GNUC_WARN_UNUSED_RESULT; int virDomainObjBeginNestedJob(virDomainObj *obj, virDomainAsyncJob asyncJob) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index a170fdd97d..4d320f075e 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -692,7 +692,7 @@ qemuDomainObjPrivateXMLFormatJob(virBuffer *buf, } if (vm->job->asyncJob !=3D VIR_ASYNC_JOB_NONE) { - virBufferAsprintf(&attrBuf, " flags=3D'0x%lx'", vm->job->apiFlags); + virBufferAsprintf(&attrBuf, " flags=3D'0x%x'", vm->job->apiFlags); virBufferAsprintf(&attrBuf, " asyncStarted=3D'%llu'", vm->job->asy= ncStarted); } @@ -758,10 +758,9 @@ qemuDomainObjPrivateXMLParseJob(virDomainObj *vm, } } - if (virXPathULongHex("string(@flags)", ctxt, &vm->job->apiFlags) =3D= =3D -2) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid job flags"= )); + if (virXMLPropUInt(ctxt->node, "flags", 16, VIR_XML_PROP_NONE, + &vm->job->apiFlags) < 0) return -1; - } if (vm->job->cb && vm->job->cb->parseJobPrivate(ctxt, job, vm) < 0) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 33105cf07b..53c655fb93 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -101,7 +101,7 @@ qemuMigrationJobIsAllowed(virDomainObj *vm) static int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RE= SULT qemuMigrationJobStart(virDomainObj *vm, virDomainAsyncJob job, - unsigned long apiFlags) + unsigned int apiFlags) { virDomainJobOperation op; unsigned long long mask; diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 7a023b36c8..bee0af9fca 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -919,7 +919,7 @@ int qemuMigrationParamsApply(virDomainObj *vm, int asyncJob, qemuMigrationParams *migParams, - unsigned long apiFlags) + unsigned int apiFlags) { bool postcopyResume =3D !!(apiFlags & VIR_MIGRATE_POSTCOPY_RESUME); int ret =3D -1; @@ -1117,7 +1117,7 @@ static void qemuMigrationParamsResetTLS(virDomainObj *vm, int asyncJob, qemuMigrationParams *origParams, - unsigned long apiFlags) + unsigned int apiFlags) { g_autofree char *tlsAlias =3D NULL; g_autofree char *secAlias =3D NULL; @@ -1280,7 +1280,7 @@ void qemuMigrationParamsReset(virDomainObj *vm, int asyncJob, qemuMigrationParams *origParams, - unsigned long apiFlags) + unsigned int apiFlags) { virErrorPtr err; g_autoptr(virBitmap) clearCaps =3D NULL; @@ -1288,7 +1288,7 @@ qemuMigrationParamsReset(virDomainObj *vm, virErrorPreserveLast(&err); - VIR_DEBUG("Resetting migration parameters %p, flags 0x%lx", + VIR_DEBUG("Resetting migration parameters %p, flags 0x%x", origParams, apiFlags); if (!virDomainObjIsActive(vm) || !origParams) diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_par= ams.h index c58a933ab6..5612a4d283 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -98,7 +98,7 @@ int qemuMigrationParamsApply(virDomainObj *vm, int asyncJob, qemuMigrationParams *migParams, - unsigned long apiFlags); + unsigned int apiFlags); int qemuMigrationParamsEnableTLS(virQEMUDriver *driver, @@ -145,7 +145,7 @@ void qemuMigrationParamsReset(virDomainObj *vm, int asyncJob, qemuMigrationParams *origParams, - unsigned long apiFlags); + unsigned int apiFlags); void qemuMigrationParamsFormat(virBuffer *buf, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f405326312..48b3e07f09 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4689,7 +4689,7 @@ qemuProcessIncomingDefNew(virQEMUCaps *qemuCaps, int qemuProcessBeginJob(virDomainObj *vm, virDomainJobOperation operation, - unsigned long apiFlags) + unsigned int apiFlags) { if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_START, operation, apiFlags) < 0) diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 4dfb2485c0..d1f58ee258 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -65,7 +65,7 @@ void qemuProcessIncomingDefFree(qemuProcessIncomingDef *i= nc); int qemuProcessBeginJob(virDomainObj *vm, virDomainJobOperation operation, - unsigned long apiFlags); + unsigned int apiFlags); void qemuProcessEndJob(virDomainObj *vm); typedef enum { --=20 2.37.3 From nobody Fri May 17 22:40:28 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=1666621093; cv=none; d=zohomail.com; s=zohoarc; b=f5lRWj5mHlHLQeQ8xKMJXOwmr1x/otLMNAPUV4eLzowjcC+bBvSeVRWpbGIyZbwUmQJCcZf3hYrerfMBtK5Qo6PGZH4E+siLe7Hrz+pjH8TNoM59gfLyycN9nrPNRlFHLbJRMfH/ASg0CNyzE7FaOiuGe6WvDFvPsDuzilw0P9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621093; 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=zc2wwFwULPM4eV6PL1RnyplAaoAsnlmDRMSSLWdvRaM=; b=hPpHG9xiYJpFoiSKj5VRLS8y0erMT54GZPWqdLkCqveODI67JsAfV2xlu85YQ/JHn/Lsf0nUzQDMGLsikdR2h7H8DmDWlWOUdSyqX2enAoTJL5k4tCdLVbNArYBaZIiLKPOqYgaHjRGNILroq0FGoWx68W1ZEOj3mHz3gbTRRQU= 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 1666621093792347.1694908517658; Mon, 24 Oct 2022 07:18:13 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-43-EP8hEkyTNoGtG2fH-SHTHQ-1; Mon, 24 Oct 2022 10:16:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F88D2999B23; Mon, 24 Oct 2022 14:16:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C65340C6FA3; Mon, 24 Oct 2022 14:16:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0B8121946594; Mon, 24 Oct 2022 14:16:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B229A194658D for ; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A516240C2140; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12B4440C2064 for ; Mon, 24 Oct 2022 14:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621091; 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=zc2wwFwULPM4eV6PL1RnyplAaoAsnlmDRMSSLWdvRaM=; b=BfUEA8tntHmdt8xqBDbUBYLMGfLFcAXn0wYPuYs+p5/9Mk4S2r45nv2JGnkbWXduITfdew gTNEe4w2umyj35OxiwfO9UKM3u7yBiZrJ890ekfIdoThvx/67Ktop4JfunBYrRJpSXfNy4 FXgtWWG2YoeNY8d5VWCmeKSmS9Vx+ow= X-MC-Unique: EP8hEkyTNoGtG2fH-SHTHQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 42/43] cpu_arm: Avoid use of 'unsigned long' Date: Mon, 24 Oct 2022 16:14:47 +0200 Message-Id: <09ef991aded35cbb0b8ff3239f4deeb906b51768.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1666621095321100003 Content-Type: text/plain; charset="utf-8" Covert all use of 'unsigned long' to 'unsigned long long'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_arm.c | 37 +++++++++++++++---------------------- src/cpu/cpu_arm_data.h | 4 ++-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 409b397155..ef72d6dceb 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -57,7 +57,7 @@ static const virArch archs[] =3D { typedef struct _virCPUarmVendor virCPUarmVendor; struct _virCPUarmVendor { char *name; - unsigned long value; + unsigned long long value; }; typedef struct _virCPUarmModel virCPUarmModel; @@ -266,7 +266,7 @@ virCPUarmMapFeatureParse(xmlXPathContextPtr ctxt G_GNUC= _UNUSED, static virCPUarmVendor * virCPUarmVendorFindByID(virCPUarmMap *map, - unsigned long vendor_id) + unsigned long long vendor_id) { size_t i; @@ -312,15 +312,13 @@ virCPUarmVendorParse(xmlXPathContextPtr ctxt, return -1; } - if (virXPathULongHex("string(@value)", ctxt, &vendor->value) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Missing CPU vendor value")); + if (virXMLPropULongLong(ctxt->node, "value", 16, VIR_XML_PROP_REQUIRED, + &vendor->value) < 0) return -1; - } if (virCPUarmVendorFindByID(map, vendor->value)) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU vendor value 0x%2lx already defined"), + _("CPU vendor value 0x%2llx already defined"), vendor->value); return -1; } @@ -347,7 +345,7 @@ virCPUarmModelFind(virCPUarmMap *map, #if defined(__aarch64__) static virCPUarmModel * virCPUarmModelFindByPVR(virCPUarmMap *map, - unsigned long pvr) + unsigned long long pvr) { size_t i; @@ -367,7 +365,8 @@ virCPUarmModelParse(xmlXPathContextPtr ctxt, { virCPUarmMap *map =3D data; g_autoptr(virCPUarmModel) model =3D NULL; - g_autofree char *vendor =3D NULL; + xmlNodePtr vendorNode =3D NULL; + xmlNodePtr pvrNode =3D NULL; model =3D g_new0(virCPUarmModel, 1); model->name =3D g_strdup(name); @@ -379,14 +378,11 @@ virCPUarmModelParse(xmlXPathContextPtr ctxt, return -1; } - if (virXPathBoolean("boolean(./vendor)", ctxt)) { - vendor =3D virXPathString("string(./vendor/@name)", ctxt); - if (!vendor) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid vendor element in CPU model %s"), - model->name); + if ((vendorNode =3D virXPathNode("./vendor", ctxt))) { + g_autofree char *vendor =3D NULL; + + if (!(vendor =3D virXMLPropStringRequired(vendorNode, "name"))) return -1; - } if (!(model->vendor =3D virCPUarmVendorFindByName(map, vendor))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -396,19 +392,16 @@ virCPUarmModelParse(xmlXPathContextPtr ctxt, } } - if (!virXPathBoolean("boolean(./pvr)", ctxt)) { + if (!(pvrNode =3D virXPathNode("./pvr", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing PVR information for CPU model %s"), model->name); return -1; } - if (virXPathULongHex("string(./pvr/@value)", ctxt, &model->data.pvr) <= 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing or invalid PVR value in CPU model %s"), - model->name); + if (virXMLPropULongLong(pvrNode, "value", 16, VIR_XML_PROP_REQUIRED, + &model->data.pvr) < 0) return -1; - } VIR_APPEND_ELEMENT(map->models, map->nmodels, model); diff --git a/src/cpu/cpu_arm_data.h b/src/cpu/cpu_arm_data.h index 36f1a60533..15a2c72d1c 100644 --- a/src/cpu/cpu_arm_data.h +++ b/src/cpu/cpu_arm_data.h @@ -25,7 +25,7 @@ typedef struct _virCPUarmData virCPUarmData; struct _virCPUarmData { - unsigned long vendor_id; - unsigned long pvr; + unsigned long long vendor_id; + unsigned long long pvr; char **features; }; --=20 2.37.3 From nobody Fri May 17 22:40:28 2024 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=1666621028; cv=none; d=zohomail.com; s=zohoarc; b=fh2W/oGy9S26CIQLNP/lLdzD3BbTCLMSSjAYvjITqTAc1u+djwDt6ti0VFeXkxYzTX9TYh314+rxGrrsxyEbOGzd+hxKECHWW34f5FEHagxdrmuzOmPIlThUVfvzqYXcpsG8gbk7CyH4gtJWzlW2jmqZuvao8+MClvgsHEpxRuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666621028; 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=4J/NhLeUtRBYh+LV2iodQ5Ihjb/ZWSzxytKRDBWAa6k=; b=gqrN9hRH0lZEYn/doJXAytFwF1ldKtlJ9KRGAbtTDFnV9E3viOoFlChFWmu/k3QGCLMyF3U4Myra1ScH+H6eXq5oAVafO5m20GouqQKfXxKOrfUzYDyJksR2P7RT6lYjLs5BO/XZdZcmsWOFMmxjZntbVpuUJ+r/1JKimv44UGs= 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 1666621028740765.293884131592; Mon, 24 Oct 2022 07:17:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-474-Mfu8cNXqMgeCr__PQnonmw-1; Mon, 24 Oct 2022 10:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BCE45811E84; Mon, 24 Oct 2022 14:16:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8BB835429; Mon, 24 Oct 2022 14:16:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 959311946595; Mon, 24 Oct 2022 14:16:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D0B2A194658D for ; Mon, 24 Oct 2022 14:15:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C31CE40C2064; Mon, 24 Oct 2022 14:15:59 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-27.brq.redhat.com [10.40.208.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C7EF40C2140 for ; Mon, 24 Oct 2022 14:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666621027; 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=4J/NhLeUtRBYh+LV2iodQ5Ihjb/ZWSzxytKRDBWAa6k=; b=IiTDnbRCKtYcHu2NLkKU+DDFL9sifdVbRetprX+mghlF0JUBZe3bjFkjo+kGAivo0POBQV ekQCT0PXW1bNqmkkZh/ekGdgjYIhpV3WFb85Hnnr4vBlHdzZ+4yDi4XxwC91QwD1rB8VtZ u+w5Grwkp4dhgaE3vM8oiPUGqdRwFZE= X-MC-Unique: Mfu8cNXqMgeCr__PQnonmw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 43/43] util: xml: Remove unused virXPathULong* Date: Mon, 24 Oct 2022 16:14:48 +0200 Message-Id: <8ce3a63f560dd111dbfce299af74563b31e8991a.1666619795.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1666621031000100001 Content-Type: text/plain; charset="utf-8" Remove the now-unused functions for parsing 'unsigned long' values via XPath. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 2 -- src/util/virxml.c | 75 ---------------------------------------- src/util/virxml.h | 8 ----- 3 files changed, 85 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0fc5481a26..5bc58d9281 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3699,8 +3699,6 @@ virXPathNodeSet; virXPathString; virXPathUInt; virXPathUIntBase; -virXPathULong; -virXPathULongHex; virXPathULongLong; virXPathULongLongBase; diff --git a/src/util/virxml.c b/src/util/virxml.c index f5ee9284a6..ca83ea1dd5 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -142,38 +142,6 @@ virXPathInt(const char *xpath, } -static int -virXPathULongBase(const char *xpath, - xmlXPathContextPtr ctxt, - int base, - unsigned long *value) -{ - g_autoptr(xmlXPathObject) obj =3D NULL; - int ret =3D 0; - - if ((ctxt =3D=3D NULL) || (xpath =3D=3D NULL) || (value =3D=3D NULL)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Invalid parameter to virXPathULong()")); - return -1; - } - obj =3D xmlXPathEval(BAD_CAST xpath, ctxt); - if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_STRING) && - (obj->stringval !=3D NULL) && (obj->stringval[0] !=3D 0)) { - if (virStrToLong_ul((char *) obj->stringval, NULL, base, value) < = 0) - ret =3D -2; - } else if ((obj !=3D NULL) && (obj->type =3D=3D XPATH_NUMBER) && - (!(isnan(obj->floatval)))) { - *value =3D (unsigned long) obj->floatval; - if (*value !=3D obj->floatval) - ret =3D -2; - } else { - ret =3D -1; - } - - return ret; -} - - /** * virXPathUIntBase: * @xpath: the XPath string to evaluate @@ -216,49 +184,6 @@ virXPathUInt(const char *xpath, } -/** - * virXPathULong: - * @xpath: the XPath string to evaluate - * @ctxt: an XPath context - * @value: the returned long value - * - * Convenience function to evaluate an XPath number - * - * Returns 0 in case of success in which case @value is set, - * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have a long format. - */ -int -virXPathULong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value) -{ - return virXPathULongBase(xpath, ctxt, 10, value); -} - - -/** - * virXPathUHex: - * @xpath: the XPath string to evaluate - * @ctxt: an XPath context - * @value: the returned long value - * - * Convenience function to evaluate an XPath number - * according to base of 16 - * - * Returns 0 in case of success in which case @value is set, - * or -1 if the XPath evaluation failed or -2 if the - * value doesn't have a long format. - */ -int -virXPathULongHex(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value) -{ - return virXPathULongBase(xpath, ctxt, 16, value); -} - - /** * virXPathULongLongBase: * @xpath: the XPath string to evaluate diff --git a/src/util/virxml.h b/src/util/virxml.h index 439a2a9991..f19cbe59ae 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -60,10 +60,6 @@ virXPathUInt(const char *xpath, xmlXPathContextPtr ctxt, unsigned int *value); int -virXPathULong(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value); -int virXPathULongLongBase(const char *xpath, xmlXPathContextPtr ctxt, unsigned int base, @@ -76,10 +72,6 @@ int virXPathLongLong(const char *xpath, xmlXPathContextPtr ctxt, long long *value); -int -virXPathULongHex(const char *xpath, - xmlXPathContextPtr ctxt, - unsigned long *value); xmlNodePtr virXPathNode(const char *xpath, xmlXPathContextPtr ctxt); --=20 2.37.3