From nobody Sun Feb 8 22:07:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642772440; cv=none; d=zohomail.com; s=zohoarc; b=LLs9Zo7CVBEBKCq7ux1YYSoCYpZqzdrif4w3nWeUwIL7Co+FHYYk06kxiQmNGDXTxCATWu7OHcd+mRjZmWnd45n6glwnFB5gFAIUl9MlI5RC3xv7zgqVAEwROJ++AWqNpF9leYq2rqYKYDBYIi0FrV0XaHvC2xQ2yNgg1xiBVbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642772440; 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=FpDqJHhxxGyZD52CK+Kd2xOqcZLqAtTuFq2eZ+MR0V0=; b=LUQ4kbVLHU5E3Z5DOTR97pgq/FaFdOycfdPEZyMc3vz5aaIuT8bwm+2qMp6sBVN2JYuX9C6PFDsSSj6zm2qddjifHMRSi+KOhgYM38Hx/cNOVN9xn/3ZNue7VsZEtAnW1YrXbIoO1OCTDET8RA1KndJumvqujPZXJuobMJEFRcM= 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 1642772440808182.59850684456046; Fri, 21 Jan 2022 05:40:40 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-116-YG51tNERPlmu9rFJr-WbEw-1; Fri, 21 Jan 2022 08:40:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D71BA8519E0; Fri, 21 Jan 2022 13:40:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB5D47ED86; Fri, 21 Jan 2022 13:40:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6FAEB1832DC0; Fri, 21 Jan 2022 13:40:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20LDSXeW012011 for ; Fri, 21 Jan 2022 08:28:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id DEA8F10A401C; Fri, 21 Jan 2022 13:28:33 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6842810A3BDB for ; Fri, 21 Jan 2022 13:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642772439; 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=FpDqJHhxxGyZD52CK+Kd2xOqcZLqAtTuFq2eZ+MR0V0=; b=TNq1rAT+NuqWimu/EjuSDb115nEo04ii7KmBSx9wAZU9udh8Z4cVpq2uOcQhV7Ue32Zsxh xVOWJLATPP3UMFO+mmxY5CylLm+nfiuSVn6y6pwV9oMC6/k4fP8PsqUDNvB2NCIv6Dw+ZH DV4QVx5o9P0MOpINsJUecI2QnqAkBDc= X-MC-Unique: YG51tNERPlmu9rFJr-WbEw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/12] conf: Convert virNetworkPortDefParseXML() to virXMLProp*() Date: Fri, 21 Jan 2022 14:28:18 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642772442579100001 Content-Type: text/plain; charset="utf-8" After previous cleanups, the virNetworkPortDefParseXML() function uses a mixture of virXMLProp*() and the old virXMLPropString() + virXXXTypeFromString() patterns. Rework it so that virXMLProp*() is used. Signed-off-by: Michal Privoznik --- src/conf/virnetworkportdef.c | 20 +++++++++----------- src/conf/virnetworkportdef.h | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index 1d75436085..fcd9e55a55 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -92,7 +92,6 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) g_autofree char *mac =3D NULL; g_autofree char *macmgr =3D NULL; g_autofree char *mode =3D NULL; - g_autofree char *plugtype =3D NULL; g_autofree char *driver =3D NULL; =20 def =3D g_new0(virNetworkPortDef, 1); @@ -176,13 +175,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) return NULL; =20 plugNode =3D virXPathNode("./plug", ctxt); - plugtype =3D virXPathString("string(./plug/@type)", ctxt); =20 - if (plugtype && - (def->plugtype =3D virNetworkPortPlugTypeFromString(plugtype)) < 0= ) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid network port plug type '%s'"), plugtype); - } + if (virXMLPropEnum(plugNode, "type", + virNetworkPortPlugTypeFromString, + VIR_XML_PROP_NONE, + &def->plugtype) < 0) + return NULL; =20 switch (def->plugtype) { case VIR_NETWORK_PORT_PLUG_TYPE_NONE: @@ -190,12 +188,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) =20 case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK: case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE: - if (!(def->plug.bridge.brname =3D virXPathString("string(./plug/@b= ridge)", ctxt))) { + if (!(def->plug.bridge.brname =3D virXMLPropString(plugNode, "brid= ge"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing network port bridge name")); return NULL; } - macmgr =3D virXPathString("string(./plug/@macTableManager)", ctxt); + macmgr =3D virXMLPropString(plugNode, "macTableManager"); if (macmgr && (def->plug.bridge.macTableManager =3D virNetworkBridgeMACTableManagerTypeFromString(macmgr)) <=3D 0= ) { @@ -207,12 +205,12 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) break; =20 case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT: - if (!(def->plug.direct.linkdev =3D virXPathString("string(./plug/@= dev)", ctxt))) { + if (!(def->plug.direct.linkdev =3D virXMLPropString(plugNode, "dev= "))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing network port link device name")); return NULL; } - mode =3D virXPathString("string(./plug/@mode)", ctxt); + mode =3D virXMLPropString(plugNode, "mode"); if (mode && (def->plug.direct.mode =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { diff --git a/src/conf/virnetworkportdef.h b/src/conf/virnetworkportdef.h index c6474c4ad8..ee13f8a084 100644 --- a/src/conf/virnetworkportdef.h +++ b/src/conf/virnetworkportdef.h @@ -58,7 +58,7 @@ struct _virNetworkPortDef { virTristateBool trustGuestRxFilters; virTristateBool isolatedPort; =20 - int plugtype; /* virNetworkPortPlugType */ + virNetworkPortPlugType plugtype; union { struct { char *brname; --=20 2.34.1