From nobody Fri May 17 23:30:01 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=1663577733; cv=none; d=zohomail.com; s=zohoarc; b=dgeTvpUzI71chbWUE9uheqRQMxn6bqCejY+ARWCZbkKnCysVUoomwPM0hboW8mOEWggKZPRe/J/DaoxHecRkEvBKkyYZkSapUEOs6gQpGJ/Uy3+YJX3NCyL6uMS3NnKvyT5dXJN3B4glPDy5rNLOp3ehp8Geg4ll7ktKvbr5WdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577733; 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=4uh+i+/vIyZMJcgBuR8GikhEO4s3mDO+nHQvILK1CDI=; b=Vn/FgxThx267yWcLP0R5Vv22pAZ38N8iECA/nvwSpGk/HRai6jx0ZyCNboommNHllwDqfvQWJLycg6SdbxjbVDCWJC1aUB5uG7o1SI4Yie5mxh6DWLAZflRY7GNyIm75EwoWea6iVci/bRGcLLWANO2JpNKomlJXOfdo16fvCDw= 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 1663577733231479.93177966095016; Mon, 19 Sep 2022 01:55:33 -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-169-6ARpl-PaOdSF4YQyA_4-4w-1; Mon, 19 Sep 2022 04:55:28 -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 D026985A5A6; Mon, 19 Sep 2022 08:55: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 BC7D717583; Mon, 19 Sep 2022 08:55: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 A9E0119465A8; Mon, 19 Sep 2022 08:55:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A2E101946A40 for ; Mon, 19 Sep 2022 08:55:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 914DB40C6EC2; Mon, 19 Sep 2022 08:55:24 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AA8A40C6EC3 for ; Mon, 19 Sep 2022 08:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577732; 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=4uh+i+/vIyZMJcgBuR8GikhEO4s3mDO+nHQvILK1CDI=; b=PRtK0Zizpe4EH5crHAovVMhJJw9V2OPy30+K+QYlx+7d/O/o7YrNWfV38wMw2UMYyXP0PL 2bs6tlf1EJ+nBAjS1k9R4LZXtoh6c8+sGUCmNb/6qn5ADHMUkBO15UNyVAn6UQda6eHOpT z3uHCuUY+BfDLS274bE7R9tMlwAB9Fk= X-MC-Unique: 6ARpl-PaOdSF4YQyA_4-4w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/37] conf: domain: Register automatic pointer freeing for virDomainActualNetDef Date: Mon, 19 Sep 2022 10:54:46 +0200 Message-Id: <3ec4256dda8543f9f57d097c1e3c2906af4589a0.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577735113100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 42fa2a4400..3d13c7a3de 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3416,6 +3416,7 @@ bool virDomainControllerIsPSeriesPHB(const virDomainC= ontrollerDef *cont); virDomainFSDef *virDomainFSDefNew(virDomainXMLOption *xmlopt); void virDomainFSDefFree(virDomainFSDef *def); void virDomainActualNetDefFree(virDomainActualNetDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainActualNetDef, virDomainActualNetDef= Free); virDomainIOMMUDef *virDomainIOMMUDefNew(void); void virDomainIOMMUDefFree(virDomainIOMMUDef *iommu); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainIOMMUDef, virDomainIOMMUDefFree); --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577737; cv=none; d=zohomail.com; s=zohoarc; b=ah3dfAseyCCKo6APU6LaTUk39liF3XdCWx+xIRFrrCPuf6FAdSZ6TXcCAKPwihjUlwWk0+3b+WqxrnIkLjMswFEZAwsCTNEQ2hl1Hmnc2HuhsbUWhipXQB3HTG6RtoxulTDKWDZFqP8tchPcqQKpzifUcEU29jhquTBqnQT8GKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577737; 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=FG8Wn5tEDVIxx1vYDTMOdEYbhcoOeYWgOntBnG+oZg4=; b=lePLFlwikqFdLsVeIMUWvuxklM8MuFhZjx/QwwzyxRt6AAYq9/9qfqKNisZ1I/l0OkXho2OeslR60u0h00PINNgMrRUIH1xyc6HeDgyuPSIr/QCKwSUwps2bx/VNIFD69lz/MPqWNbs7e+TdUAd2v04232g2v6/mM9eK72vi2ZE= 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 1663577737129452.02072172181965; Mon, 19 Sep 2022 01:55:37 -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-466-lxCppqb9O8-mpK2kANk3Tg-1; Mon, 19 Sep 2022 04:55:29 -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 685C7868A3C; Mon, 19 Sep 2022 08:55: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 222181121315; Mon, 19 Sep 2022 08:55: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 055AA1946594; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 94DA61946597 for ; Mon, 19 Sep 2022 08:55:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 86AD440C6EC3; Mon, 19 Sep 2022 08:55:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F226240C6EC4 for ; Mon, 19 Sep 2022 08:55:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577736; 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=FG8Wn5tEDVIxx1vYDTMOdEYbhcoOeYWgOntBnG+oZg4=; b=Gi3nytVOi5K1iBTxkXKdHvchfBEJXT6lcwi8vC1Z9loPOWNGzieIxV0B15nAWpGaJ+SrXA 3Zl1MIVwSZC6SaxQaIKzzlEChspJk4GQ/SALqhr95mfD5npf59axHyV7c9f1XQJXb/bQf0 6wTDRoVU0+7gGVRngBrAmPKBUgoi/jA= X-MC-Unique: lxCppqb9O8-mpK2kANk3Tg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/37] conf: domain: Automatically free 'def' and 'actual' in virDomainNetDefParseXML Date: Mon, 19 Sep 2022 10:54:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577739029100009 Content-Type: text/plain; charset="utf-8" Convert the last two variables having inline cleanup to automatic cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 406c348a00..7f5efa205c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8833,7 +8833,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlXPathContextPtr ctxt, unsigned int flags) { - virDomainNetDef *def; + g_autoptr(virDomainNetDef) def =3D NULL; virDomainHostdevDef *hostdev; xmlNodePtr source_node =3D NULL; xmlNodePtr virtualport_node =3D NULL; @@ -8845,7 +8845,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr tmpNode; xmlNodePtr mac_node =3D NULL; g_autoptr(GHashTable) filterparams =3D NULL; - virDomainActualNetDef *actual =3D NULL; + g_autoptr(virDomainActualNetDef) actual =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; @@ -9571,13 +9571,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0) goto error; - cleanup: - virDomainActualNetDefFree(actual); - return def; + return g_steal_pointer(&def); error: - g_clear_pointer(&def, virDomainNetDefFree); - goto cleanup; + return NULL; } static int --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577733; cv=none; d=zohomail.com; s=zohoarc; b=QSrixJNZhZkAyzbDvlQ4zoJaajfqIVvX0qcq66/vpIN8tDTIVNb82iiFLO7r8D5neMFPWZAaphntxWmoLe6e4VsMtvhc+ebctKAXnz5kyCP74AuwNIrODNkwotK6udf9jT/NHErnGV/y/0LP5EKGmZZvAOj1eJhr01l2Q47+V5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577733; 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=bGnr/Zz9EHY+hGdQDnPcJj+QaviTgR8YOIc4E4rOYlo=; b=aj2kke0yfMPlVNlHG6ZgKt26kiEacdTV13sN4dtFX8sLxdDVR+cvW0fZ4gByz0eKcZz/Dufpw4nORQ7rcZopoT44ZHaSwUPrejPNosBhV5jo2j66gMTWBtpWKTBM7DWZfZMMbf7Z8WoJpepvWFh0KMMWDh7ZC22UhoBKltK5RSQ= 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 1663577733866750.8703039804356; Mon, 19 Sep 2022 01:55:33 -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-662-Za0-w404P--Tl485f0lVMA-1; Mon, 19 Sep 2022 04:55:30 -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 8BB2A3C119AA; Mon, 19 Sep 2022 08:55: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 75CA640C2066; Mon, 19 Sep 2022 08:55: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 42B4E1946A42; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AA40F1946586 for ; Mon, 19 Sep 2022 08:55:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9EE4D40C6EC2; Mon, 19 Sep 2022 08:55:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB28B40C6EC4 for ; Mon, 19 Sep 2022 08:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577731; 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=bGnr/Zz9EHY+hGdQDnPcJj+QaviTgR8YOIc4E4rOYlo=; b=LHYwNGwy12uH3XFTxtZpaL2Q620e9r23q2saogwMHfO0b2fkbdVcwdLAfi1w4RaFbqKU+b 7VNST1ksM2wGCPT1sQ7nPeNPypyNj2XUe2h/hGaTOq06Wfbxq+zerGmqTb/x/9wE4wWFrj r6bToMYAbTLGSmy5oVX2QhSWklkLu+E= X-MC-Unique: Za0-w404P--Tl485f0lVMA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/37] conf: domain: Remove 'error' label in virDomainNetDefParseXML Date: Mon, 19 Sep 2022 10:54:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577735124100002 Content-Type: text/plain; charset="utf-8" The 'error' label was an alias to 'return NULL;'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 155 ++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7f5efa205c..a544ab6ce4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8889,21 +8889,21 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if ((rv =3D virXMLPropEnum(node, "type", virDomainNetTypeFromString, VIR_XML_PROP_NONE, &def->type)) < 0) - goto error; + return NULL; if (rv =3D=3D 0) def->type =3D VIR_DOMAIN_NET_TYPE_USER; if (virXMLPropTristateBool(node, "trustGuestRxFilters", VIR_XML_PROP_N= ONE, &def->trustGuestRxFilters) < 0) - goto error; + return NULL; if ((source_node =3D virXPathNode("./source", ctxt))) { xmlNodePtr tmpnode =3D ctxt->node; ctxt->node =3D source_node; if (virDomainNetIPInfoParseXML(_("interface host IP"), ctxt, &def-= >hostIP) < 0) - goto error; + return NULL; ctxt->node =3D tmpnode; if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -8947,7 +8947,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, "Use (for host-side) " "or (for guest-side) inst= ead."), dev, dev, dev); - goto error; + return NULL; } if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { @@ -8955,7 +8955,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, vhostuser_path =3D virXMLPropString(source_node, "path"); vhostuser_mode =3D virXMLPropString(source_node, "mode"); if (virDomainChrSourceReconnectDefParseXML(&reconnect, source_= node, ctxt) < 0) - goto error; + return NULL; } if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) @@ -8985,7 +8985,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (!(def->virtPortProfile =3D virNetDevVPortProfileParse(virtualport_node, VIR_VPORT_XML_GENERATE_MISS= ING_DEFAULTS))) { - goto error; + return NULL; } } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || @@ -8994,14 +8994,14 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, =3D virNetDevVPortProfileParse(virtualport_node, VIR_VPO= RT_XML_GENERATE_MISSING_DEFAULTS| VIR_VPORT_XML_REQUIRE_ALL_A= TTRIBUTES| VIR_VPORT_XML_REQUIRE_TYPE)= )) { - goto error; + return NULL; } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(" element unsupported for" " "), virDomainNetTypeToString(def->type)); - goto error; + return NULL; } } @@ -9019,7 +9019,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if ((driver_node =3D virXPathNode("./driver", ctxt)) && (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0)) - goto error; + return NULL; if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { filter =3D virXMLPropString(filterref_node, "filter"); @@ -9031,16 +9031,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, (actual_node =3D virXPathNode("./actual", ctxt)) && (virDomainActualNetDefParseXML(actual_node, ctxt, def, &actual, flags, xmlopt) < 0)) - goto error; + return NULL; if ((bandwidth_node =3D virXPathNode("./bandwidth", ctxt)) && (virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidth_node, def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETW= ORK) < 0)) - goto error; + return NULL; if ((vlan_node =3D virXPathNode("./vlan", ctxt)) && (virNetDevVlanParse(vlan_node, ctxt, &def->vlan) < 0)) - goto error; + return NULL; if ((tap =3D virXPathString("string(./backend/@tap)", ctxt))) def->backend.tap =3D virFileSanitizePath(tap); @@ -9055,13 +9055,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_XML_ERROR, _("unable to parse mac address '%s'"), (const char *)macaddr); - goto error; + return NULL; } if (virMacAddrIsMulticast(&def->mac)) { virReportError(VIR_ERR_XML_ERROR, _("expected unicast mac address, found multicas= t '%s'"), (const char *)macaddr); - goto error; + return NULL; } } else { virDomainNetGenerateMAC(xmlopt, &def->mac); @@ -9072,22 +9072,22 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainNetMacTypeTypeFromString, VIR_XML_PROP_NONZERO, &def->mac_type) < 0) - goto error; + return NULL; if (virXMLPropTristateBool(mac_node, "check", VIR_XML_PROP_NONE, &def->mac_check) < 0) - goto error; + return NULL; if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)= { - goto error; + return NULL; } if (model !=3D NULL && virDomainNetSetModelString(def, model) < 0) - goto error; + return NULL; switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -9095,13 +9095,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'network' attribute " "specified with = ")); - goto error; + return NULL; } if (portid && virUUIDParse(portid, def->data.network.portid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse port id '%s'"), portid); - goto error; + return NULL; } def->data.network.name =3D g_steal_pointer(&network); @@ -9115,7 +9115,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, _("Wrong or no 'type' attribute " "specified with . " "vhostuser requires the virtio-net* frontend"= )); - goto error; + return NULL; } if (STRNEQ_NULLABLE(vhostuser_type, "unix")) { @@ -9129,7 +9129,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, _("No 'type' attribute " "specified for ")); - goto error; + return NULL; } if (vhostuser_path =3D=3D NULL) { @@ -9137,7 +9137,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, _("No 'path' attribute " "specified with ")); - goto error; + return NULL; } if (vhostuser_mode =3D=3D NULL) { @@ -9145,11 +9145,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, _("No 'mode' attribute " "specified with ")); - goto error; + return NULL; } if (!(def->data.vhostuser =3D virDomainChrSourceDefNew(xmlopt))) - goto error; + return NULL; def->data.vhostuser->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; def->data.vhostuser->data.nix.path =3D g_steal_pointer(&vhostuser_= path); @@ -9160,7 +9160,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("'reconnect' attribute unsupported " "'server' mode for ")); - goto error; + return NULL; } } else if (STREQ(vhostuser_mode, "client")) { def->data.vhostuser->data.nix.listen =3D false; @@ -9170,7 +9170,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, _("Wrong 'mode' attribute " "specified with ")); - goto error; + return NULL; } break; @@ -9179,7 +9179,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'dev' attribute " "specified with ")); - goto error; + return NULL; } def->data.vdpa.devicepath =3D g_steal_pointer(&dev); break; @@ -9189,7 +9189,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'bridge' attribute " "specified with "= )); - goto error; + return NULL; } def->data.bridge.brname =3D g_steal_pointer(&bridge); break; @@ -9202,13 +9202,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'port' attribute " "specified with socket interface")); - goto error; + return NULL; } if (virStrToLong_i(port, NULL, 10, &def->data.socket.port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse 'port' attribute " "with socket interface")); - goto error; + return NULL; } if (address =3D=3D NULL) { @@ -9218,7 +9218,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'address' attribute " "specified with socket interface")); - goto error; + return NULL; } } else { def->data.socket.address =3D g_steal_pointer(&address); @@ -9231,20 +9231,20 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'port' attribute " "specified with socket interface")); - goto error; + return NULL; } if (virStrToLong_i(localport, NULL, 10, &def->data.socket.localpor= t) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse 'port' attribute " "with socket interface")); - goto error; + return NULL; } if (localaddr =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'address' attribute " "specified with socket interface")); - goto error; + return NULL; } else { def->data.socket.localaddr =3D g_steal_pointer(&localaddr); } @@ -9255,7 +9255,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'name' attribute specified " "with ")); - goto error; + return NULL; } def->data.internal.name =3D g_steal_pointer(&internal); break; @@ -9265,14 +9265,14 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No 'dev' attribute specified " "with ")); - goto error; + return NULL; } if (mode !=3D NULL) { if ((val =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unknown mode has been specified")); - goto error; + return NULL; } def->data.direct.mode =3D val; } else { @@ -9297,7 +9297,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, hostdev, flags, xmlopt) < 0)= { - goto error; + return NULL; } break; @@ -9306,46 +9306,46 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_XML_ERROR, _("Missing source switchid for interface type '= %s'"), virDomainNetTypeToString(def->type)); - goto error; + return NULL; } if (!portid) { virReportError(VIR_ERR_XML_ERROR, _("Missing source portid for interface type '%s= '"), virDomainNetTypeToString(def->type)); - goto error; + return NULL; } if (!connectionid) { virReportError(VIR_ERR_XML_ERROR, _("Missing source connectionid for interface ty= pe '%s'"), virDomainNetTypeToString(def->type)); - goto error; + return NULL; } if (!portgroup) { virReportError(VIR_ERR_XML_ERROR, _("Missing source portgroup for interface type = '%s'"), virDomainNetTypeToString(def->type)); - goto error; + return NULL; } if (virUUIDParse(switchid, def->data.vds.switch_id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse switchid '%s'"), switchid); - goto error; + return NULL; } if (virStrToLong_ll(portid, NULL, 0, &def->data.vds.port_id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse portid '%s'"), portid); - goto error; + return NULL; } if (virStrToLong_ll(connectionid, NULL, 0, &def->data.vds.connecti= on_id) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse connectionid '%s'"), connect= ionid); - goto error; + return NULL; } def->data.vds.portgroup_id =3D g_steal_pointer(&portgroup); @@ -9361,7 +9361,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (virDomainNetIPInfoParseXML(_("guest interface"), ctxt, &def->guestIP) < 0) - goto error; + return NULL; if (managed_tap) { bool state =3D false; @@ -9369,7 +9369,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_XML_ERROR, _("invalid 'managed' value '%s'"), managed_tap); - goto error; + return NULL; } def->managed_tap =3D virTristateBoolFromBool(state); } @@ -9404,28 +9404,28 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainNetBackendTypeFromString, VIR_XML_PROP_NONZERO, &def->driver.virtio.name) < 0) - goto error; + return NULL; if (virXMLPropEnum(driver_node, "txmode", virDomainNetVirtioTxModeTypeFromString, VIR_XML_PROP_NONZERO, &def->driver.virtio.txmode) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(driver_node, "ioeventfd", VIR_XML_PROP_NONE, &def->driver.virtio.ioeventfd) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(driver_node, "event_idx", VIR_XML_PROP_NONE, &def->driver.virtio.event_idx) < 0) - goto error; + return NULL; if (virXMLPropUInt(driver_node, "queues", 10, VIR_XML_PROP_NONE, &def->driver.virtio.queues) < 0) - goto error; + return NULL; /* There's always at least one TX/RX queue. */ if (def->driver.virtio.queues =3D=3D 1) @@ -9434,74 +9434,74 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (virXMLPropUInt(driver_node, "rx_queue_size", 10, VIR_XML_PROP_NONE, &def->driver.virtio.rx_queue_size) < 0) - goto error; + return NULL; if (virXMLPropUInt(driver_node, "tx_queue_size", 10, VIR_XML_PROP_NONE, &def->driver.virtio.tx_queue_size) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(driver_node, "rss", VIR_XML_PROP_NONE, &def->driver.virtio.rss) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(driver_node, "rss_hash_report", VIR_XML_PROP_NONE, &def->driver.virtio.rss_hash_report) = < 0) - goto error; + return NULL; if ((tmpNode =3D virXPathNode("./driver/host", ctxt))) { if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NON= E, &def->driver.virtio.host.csum) < = 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "gso", VIR_XML_PROP_NONE, &def->driver.virtio.host.gso) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "tso4", VIR_XML_PROP_NON= E, &def->driver.virtio.host.tso4) < = 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "tso6", VIR_XML_PROP_NON= E, &def->driver.virtio.host.tso6) < = 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "ecn", VIR_XML_PROP_NONE, &def->driver.virtio.host.ecn) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "ufo", VIR_XML_PROP_NONE, &def->driver.virtio.host.ufo) < 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "mrg_rxbuf", VIR_XML_PROP_NONE, &def->driver.virtio.host.mrg_rxbu= f) < 0) - goto error; + return NULL; } if ((tmpNode =3D virXPathNode("./driver/guest", ctxt))) { if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NON= E, &def->driver.virtio.guest.csum) <= 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "tso4", VIR_XML_PROP_NON= E, &def->driver.virtio.guest.tso4) <= 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "tso6", VIR_XML_PROP_NON= E, &def->driver.virtio.guest.tso6) <= 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "ecn", VIR_XML_PROP_NONE, &def->driver.virtio.guest.ecn) < = 0) - goto error; + return NULL; if (virXMLPropTristateSwitch(tmpNode, "ufo", VIR_XML_PROP_NONE, &def->driver.virtio.guest.ufo) < = 0) - goto error; + return NULL; } def->backend.vhost =3D g_steal_pointer(&vhost_path); } @@ -9512,7 +9512,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown interface link state '%s'"), linkstate); - goto error; + return NULL; } } @@ -9540,12 +9540,12 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, case VIR_DOMAIN_NET_TYPE_LAST: default: virReportEnumRangeError(virDomainNetType, def->type); - goto error; + return NULL; } } if (virDomainNetTeamingInfoParseXML(ctxt, &def->teaming) < 0) - goto error; + return NULL; rv =3D virXPathULong("string(./tune/sndbuf)", ctxt, &def->tune.sndbuf); if (rv >=3D 0) { @@ -9553,28 +9553,25 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } else if (rv =3D=3D -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("sndbuf must be a positive integer")); - goto error; + return NULL; } if (virXPathUInt("string(./mtu/@size)", ctxt, &def->mtu) < -1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed mtu size")); - goto error; + return NULL; } node =3D virXPathNode("./coalesce", ctxt); if (node) { if (virDomainNetDefCoalesceParseXML(node, ctxt, &def->coalesce) < = 0) - goto error; + return NULL; } if (virNetworkPortOptionsParseXML(ctxt, &def->isolatedPort) < 0) - goto error; + return NULL; return g_steal_pointer(&def); - - error: - return NULL; } static int --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577898; cv=none; d=zohomail.com; s=zohoarc; b=areeGPHwoEnuaSIpr+izAaKqg5rmZ8D1aVst8BnPkYawMiSuL9NefIU9YAViGj65ohM6oaa8Vq6JSsHf5UUlVkPSuGpS33i9ohSIaFpWDMSrAnhN0MOnF/pphvhWF+cm1KwIjTwcB31Oju5SJ/gGgBvAsziCPWUaP7fR51OkKmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577898; 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=cTHkfCfs51HXcv6ahsYNfFi7r0piT8P5gKhwV5dE2Ik=; b=n8eKHHpDtD5HeqnJVfXL8MjBBnnfgajtAuc38zW6eicsuRmtg+hSxk+dmsIZNu6lLkK+uvPmIoeoIhvdfUdi6HLE5EPysrZfxPTeoXSafw36a0WnfJP5nbDwVOBxXwGF1xw2DKHTDTHoC++A7t1SdeSEGUhl8gPXz9OZwD1MbfY= 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 166357789892444.75760273794833; Mon, 19 Sep 2022 01:58:18 -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-652-RzixbiLyNMWUC245PLX3Hg-1; Mon, 19 Sep 2022 04:55:30 -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 C957E29ABA05; Mon, 19 Sep 2022 08:55:28 +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 B693F2086F60; Mon, 19 Sep 2022 08:55:28 +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 A8B941946594; Mon, 19 Sep 2022 08:55:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A8D401946586 for ; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8B8C440C6EC3; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02EC040C6EC2 for ; Mon, 19 Sep 2022 08:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577896; 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=cTHkfCfs51HXcv6ahsYNfFi7r0piT8P5gKhwV5dE2Ik=; b=gk8VljeWbQBi5rkmJ1Q2oj7weM/y9Cd7o0uhTC8paq54fC9f2lDZSWstp0qmIuGFtNANx/ eSMnzdG8O2/wcgJZ8JtZ5jWrtp667wTTffpJTa2tsAVs9BPXiG+5qJk5v0lTCLqFs3DUFS bmUSivfcKCtiN80RR3NRSl0oiEdcX5A= X-MC-Unique: RzixbiLyNMWUC245PLX3Hg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/37] virDomainNetDefParseXML: Remove unnecessary temporary variables Date: Mon, 19 Sep 2022 10:54:49 +0200 Message-Id: <72438bd1b2100138c71425bb3ed6a746fa0ac9ac.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577900153100001 Content-Type: text/plain; charset="utf-8" Some values were extracted into a temporary variable and then assigned to the definition later without a modification. Directly assign them instead. One slight modification was done to 'ifname' which was cleared in certain cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 45 ++++++++++++------------------------------ 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a544ab6ce4..390263d806 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8855,12 +8855,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *portid =3D NULL; g_autofree char *bridge =3D NULL; g_autofree char *dev =3D NULL; - g_autofree char *ifname =3D NULL; g_autofree char *managed_tap =3D NULL; - g_autofree char *ifname_guest =3D NULL; - g_autofree char *ifname_guest_actual =3D NULL; - g_autofree char *script =3D NULL; - g_autofree char *downscript =3D NULL; g_autofree char *address =3D NULL; g_autofree char *port =3D NULL; g_autofree char *localaddr =3D NULL; @@ -8871,7 +8866,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *mode =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; - g_autofree char *domain_name =3D NULL; g_autofree char *vhostuser_mode =3D NULL; g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =3D NULL; @@ -9005,16 +8999,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } } - ifname =3D virXPathString("string(./target/@dev)", ctxt); + def->ifname =3D virXPathString("string(./target/@dev)", ctxt); managed_tap =3D virXPathString("string(./target/@managed)", ctxt); - ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); - ifname_guest_actual =3D virXPathString("string(./guest/@actual)", ctxt= ); + def->ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); + def->ifname_guest_actual =3D virXPathString("string(./guest/@actual)",= ctxt); linkstate =3D virXPathString("string(./link/@state)", ctxt); - script =3D virXPathString("string(./script/@path)", ctxt); - downscript =3D virXPathString("string(./downscript/@path)", ctxt); - domain_name =3D virXPathString("string(./backenddomain/@name)", ctxt); + def->script =3D virXPathString("string(./script/@path)", ctxt); + def->downscript =3D virXPathString("string(./downscript/@path)", ctxt); + def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); model =3D virXPathString("string(./model/@type)", ctxt); if ((driver_node =3D virXPathNode("./driver", ctxt)) && @@ -9374,28 +9368,15 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->managed_tap =3D virTristateBoolFromBool(state); } - if (def->managed_tap !=3D VIR_TRISTATE_BOOL_NO && ifname && + if (def->managed_tap !=3D VIR_TRISTATE_BOOL_NO && def->ifname && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && - (STRPREFIX(ifname, VIR_NET_GENERATED_VNET_PREFIX) || - STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || - STRPREFIX(ifname, VIR_NET_GENERATED_MACVLAN_PREFIX) || - (prefix && STRPREFIX(ifname, prefix)))) { + (STRPREFIX(def->ifname, VIR_NET_GENERATED_VNET_PREFIX) || + STRPREFIX(def->ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || + STRPREFIX(def->ifname, VIR_NET_GENERATED_MACVLAN_PREFIX) || + (prefix && STRPREFIX(def->ifname, prefix)))) { /* An auto-generated target name, blank it out */ - VIR_FREE(ifname); - } - - if (script !=3D NULL) - def->script =3D g_steal_pointer(&script); - if (downscript !=3D NULL) - def->downscript =3D g_steal_pointer(&downscript); - if (domain_name !=3D NULL) - def->domain_name =3D g_steal_pointer(&domain_name); - if (ifname !=3D NULL) - def->ifname =3D g_steal_pointer(&ifname); - if (ifname_guest !=3D NULL) - def->ifname_guest =3D g_steal_pointer(&ifname_guest); - if (ifname_guest_actual !=3D NULL) - def->ifname_guest_actual =3D g_steal_pointer(&ifname_guest_actual); + g_clear_pointer(&def->ifname, g_free); + } if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && virDomainNetIsVirtioModel(def)) { --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577736; cv=none; d=zohomail.com; s=zohoarc; b=UQK6ZxRQDJSkmwVLBViNnkqyty+wUFe49bhZAVORMvh1YOAZgnFHoLQct1tswTBVKbL21sflmq40G+el6arPOObO/N133/4tZtzS5YwUVcFY/ww4CsIydThGj06g8mk8sB6iqYaEuhMdtgWb2RyFm/6/8lXD/6gIEwcu+pBriOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577736; 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=TBuyZJwcldlNVllNltN7CdZJsdSw8lg41GTaP/dXOKI=; b=WSN12z11Yg1j2R/ZTEjIDd3THByBO6N4I4op0tDVqQ1XxtAeBjjWQjoMx3ARrGnTe0PpEJMC5FtgtVa702sogN2qRSRRnJSrTAtc0kREujj65IHroiRXJfzrhDB9Rk0ISp7rUid6Da82mTRZDtsrAr+BvxbsUzpnhtdDpEv7tQg= 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 1663577736534197.3817817953053; Mon, 19 Sep 2022 01:55:36 -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-633-6C7sCQQdPU-Ej9h8RP4l4A-1; Mon, 19 Sep 2022 04:55:32 -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 CDFED3817A7A; Mon, 19 Sep 2022 08:55:29 +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 BB6FC1121315; Mon, 19 Sep 2022 08:55:29 +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 A9C4F19465A3; Mon, 19 Sep 2022 08:55:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 92E771946594 for ; Mon, 19 Sep 2022 08:55:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 758EC40C6EC3; Mon, 19 Sep 2022 08:55:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0B5740C6EC2 for ; Mon, 19 Sep 2022 08:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577735; 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=TBuyZJwcldlNVllNltN7CdZJsdSw8lg41GTaP/dXOKI=; b=Jd+V162yJ1qgYTvB+CditBmnf9JukyIniuodR2DbjtTJ4ngoBlnYsZ2chiGCkRuKY4Qo01 8pSaQ5YKrWyHTu4D9JwldZvj2KpfECLyWPcGjmKiNOsqjvoLDr0GRUspNd7r7I+gSVP+rt RJyvLmicGh1mqDK9sogxDTHUVdfDXsw= X-MC-Unique: 6C7sCQQdPU-Ej9h8RP4l4A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/37] virDomainNetDefParseXML: Separate and localize parsing of 'backend/@vhost' Date: Mon, 19 Sep 2022 10:54:50 +0200 Message-Id: <8a3c1ec90081f2eda5177a43b7e3c08a3eb4c443.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577737016100005 Content-Type: text/plain; charset="utf-8" Move it into an independent block and move temporary variables locally. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 390263d806..0e25d585c8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8869,9 +8869,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_mode =3D NULL; g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =3D NULL; - g_autofree char *vhost_path =3D NULL; g_autofree char *tap =3D NULL; - g_autofree char *vhost =3D NULL; g_autofree char *switchid =3D NULL; g_autofree char *connectionid =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; @@ -9039,9 +9037,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if ((tap =3D virXPathString("string(./backend/@tap)", ctxt))) def->backend.tap =3D virFileSanitizePath(tap); - if ((vhost =3D virXPathString("string(./backend/@vhost)", ctxt))) - vhost_path =3D virFileSanitizePath(vhost); - mac_node =3D virXPathNode("./mac", ctxt); if ((macaddr =3D virXMLPropString(mac_node, "address"))) { @@ -9484,7 +9479,14 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, &def->driver.virtio.guest.ufo) < = 0) return NULL; } - def->backend.vhost =3D g_steal_pointer(&vhost_path); + } + + if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && + virDomainNetIsVirtioModel(def)) { + g_autofree char *vhost =3D virXPathString("string(./backend/@vhos= t)", ctxt); + + if (vhost) + def->backend.vhost =3D virFileSanitizePath(vhost); } def->linkstate =3D VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577763; cv=none; d=zohomail.com; s=zohoarc; b=k/BM0qZJqw+7YrCcTJz9dTeRdudcnK1PbQU+MlpEgKy0lUq2zconzwk+3ZqsmLU3ubmxfc7TE2SrFWYNEx4GjLSEvysohgLoe7agjqInqbMh0efY/AmflrxtELSX66Un21QYv97XUjEiY4fjc6pOqTsA2J3UyLlzrVXOGmYV9sY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577763; 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=P6nDkuFBKo525epoOxBjErGmLJ/7FWFWix0aANIWypY=; b=MMP8q2p8ORgQOAlzg6bZ3W1p6M4OR1QlI7L+ul35YVprzo/C8J5rBup5yK9GElb3CeAL+R8zM26VRD4yuICorSlstV7HaEjt7a0Xlj0QvUzPuvcbMR7G0DLnlh+Chzj1+9aKIeAmj1fDc5+gg+zMAKGlB6CfDi5oG1+THbtt+o8= 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 1663577763819458.1999191218182; Mon, 19 Sep 2022 01:56:03 -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-127-k06qSqdQNQ6ucsK94_hy8A-1; Mon, 19 Sep 2022 04:55:33 -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 2C00F3C0257E; Mon, 19 Sep 2022 08:55:31 +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 18EFA49BB60; Mon, 19 Sep 2022 08:55:31 +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 F042219465A2; Mon, 19 Sep 2022 08:55:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 677451946586 for ; Mon, 19 Sep 2022 08:55:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 59EB140C6EC2; Mon, 19 Sep 2022 08:55:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDAB940C6EC4 for ; Mon, 19 Sep 2022 08:55:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577762; 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=P6nDkuFBKo525epoOxBjErGmLJ/7FWFWix0aANIWypY=; b=drxwQBRUoCkX/Tv45YCqLLMT6MA7cSe+78yr7iAGPR/h+7IPhLzAb7WnjbAGUAlKdabzkX ce4HCrUJnD04pcFAxjVvSaLAgf6wDV35tKeN5XVDsuWAdNOC8wBa7toPUIW68cw2FoJ+hn sgYYBMiZcVtD+iw/rOwoDmG7btztSYY= X-MC-Unique: k06qSqdQNQ6ucsK94_hy8A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/37] virDomainNetDefParseXML: Split out parsing of 'driver' subelement Date: Mon, 19 Sep 2022 10:54:51 +0200 Message-Id: <0a21cf4a1c1d84e1c798a21fd9a9d189adf860e7.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577765482100002 Content-Type: text/plain; charset="utf-8" Separate the code into virDomainNetDefParseXMLDriver. Some local variables were renamed and the scope decreased. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 238 ++++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 112 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0e25d585c8..621b1df6c8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8827,6 +8827,130 @@ virDomainNetTeamingInfoParseXML(xmlXPathContextPtr = ctxt, } +static int +virDomainNetDefParseXMLDriver(virDomainNetDef *def, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr driver_node; + + if ((driver_node =3D virXPathNode("./driver", ctxt)) && + (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0)) + return -1; + + if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && + virDomainNetIsVirtioModel(def)) { + xmlNodePtr hostNode; + xmlNodePtr guestNode; + + if (virXMLPropEnum(driver_node, "name", + virDomainNetBackendTypeFromString, + VIR_XML_PROP_NONZERO, + &def->driver.virtio.name) < 0) + return -1; + + if (virXMLPropEnum(driver_node, "txmode", + virDomainNetVirtioTxModeTypeFromString, + VIR_XML_PROP_NONZERO, + &def->driver.virtio.txmode) < 0) + return -1; + + if (virXMLPropTristateSwitch(driver_node, "ioeventfd", + VIR_XML_PROP_NONE, + &def->driver.virtio.ioeventfd) < 0) + return -1; + + if (virXMLPropTristateSwitch(driver_node, "event_idx", + VIR_XML_PROP_NONE, + &def->driver.virtio.event_idx) < 0) + return -1; + + if (virXMLPropUInt(driver_node, "queues", 10, + VIR_XML_PROP_NONE, + &def->driver.virtio.queues) < 0) + return -1; + + /* There's always at least one TX/RX queue. */ + if (def->driver.virtio.queues =3D=3D 1) + def->driver.virtio.queues =3D 0; + + if (virXMLPropUInt(driver_node, "rx_queue_size", 10, + VIR_XML_PROP_NONE, + &def->driver.virtio.rx_queue_size) < 0) + return -1; + + if (virXMLPropUInt(driver_node, "tx_queue_size", 10, + VIR_XML_PROP_NONE, + &def->driver.virtio.tx_queue_size) < 0) + return -1; + + if (virXMLPropTristateSwitch(driver_node, "rss", + VIR_XML_PROP_NONE, + &def->driver.virtio.rss) < 0) + return -1; + + if (virXMLPropTristateSwitch(driver_node, "rss_hash_report", + VIR_XML_PROP_NONE, + &def->driver.virtio.rss_hash_report) = < 0) + return -1; + + if ((hostNode =3D virXPathNode("./driver/host", ctxt))) { + if (virXMLPropTristateSwitch(hostNode, "csum", VIR_XML_PROP_NO= NE, + &def->driver.virtio.host.csum) < = 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "gso", VIR_XML_PROP_NON= E, + &def->driver.virtio.host.gso) < 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "tso4", VIR_XML_PROP_NO= NE, + &def->driver.virtio.host.tso4) < = 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "tso6", VIR_XML_PROP_NO= NE, + &def->driver.virtio.host.tso6) < = 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "ecn", VIR_XML_PROP_NON= E, + &def->driver.virtio.host.ecn) < 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "ufo", VIR_XML_PROP_NON= E, + &def->driver.virtio.host.ufo) < 0) + return -1; + + if (virXMLPropTristateSwitch(hostNode, "mrg_rxbuf", + VIR_XML_PROP_NONE, + &def->driver.virtio.host.mrg_rxbu= f) < 0) + return -1; + } + + if ((guestNode =3D virXPathNode("./driver/guest", ctxt))) { + if (virXMLPropTristateSwitch(guestNode, "csum", VIR_XML_PROP_N= ONE, + &def->driver.virtio.guest.csum) <= 0) + return -1; + + if (virXMLPropTristateSwitch(guestNode, "tso4", VIR_XML_PROP_N= ONE, + &def->driver.virtio.guest.tso4) <= 0) + return -1; + + if (virXMLPropTristateSwitch(guestNode, "tso6", VIR_XML_PROP_N= ONE, + &def->driver.virtio.guest.tso6) <= 0) + return -1; + + if (virXMLPropTristateSwitch(guestNode, "ecn", VIR_XML_PROP_NO= NE, + &def->driver.virtio.guest.ecn) < = 0) + return -1; + + if (virXMLPropTristateSwitch(guestNode, "ufo", VIR_XML_PROP_NO= NE, + &def->driver.virtio.guest.ufo) < = 0) + return -1; + } + } + + return 0; +} + + static virDomainNetDef * virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -8837,7 +8961,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainHostdevDef *hostdev; xmlNodePtr source_node =3D NULL; xmlNodePtr virtualport_node =3D NULL; - xmlNodePtr driver_node =3D NULL; xmlNodePtr filterref_node =3D NULL; xmlNodePtr actual_node =3D NULL; xmlNodePtr vlan_node =3D NULL; @@ -9009,10 +9132,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); model =3D virXPathString("string(./model/@type)", ctxt); - if ((driver_node =3D virXPathNode("./driver", ctxt)) && - (virDomainVirtioOptionsParseXML(driver_node, &def->virtio) < 0)) - return NULL; - if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { filter =3D virXMLPropString(filterref_node, "filter"); filterparams =3D virNWFilterParseParamAttributes(filterref_node); @@ -9373,113 +9492,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_clear_pointer(&def->ifname, g_free); } - if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainNetIsVirtioModel(def)) { - - if (virXMLPropEnum(driver_node, "name", - virDomainNetBackendTypeFromString, - VIR_XML_PROP_NONZERO, - &def->driver.virtio.name) < 0) - return NULL; - - if (virXMLPropEnum(driver_node, "txmode", - virDomainNetVirtioTxModeTypeFromString, - VIR_XML_PROP_NONZERO, - &def->driver.virtio.txmode) < 0) - return NULL; - - if (virXMLPropTristateSwitch(driver_node, "ioeventfd", - VIR_XML_PROP_NONE, - &def->driver.virtio.ioeventfd) < 0) - return NULL; - - if (virXMLPropTristateSwitch(driver_node, "event_idx", - VIR_XML_PROP_NONE, - &def->driver.virtio.event_idx) < 0) - return NULL; - - if (virXMLPropUInt(driver_node, "queues", 10, - VIR_XML_PROP_NONE, - &def->driver.virtio.queues) < 0) - return NULL; - - /* There's always at least one TX/RX queue. */ - if (def->driver.virtio.queues =3D=3D 1) - def->driver.virtio.queues =3D 0; - - if (virXMLPropUInt(driver_node, "rx_queue_size", 10, - VIR_XML_PROP_NONE, - &def->driver.virtio.rx_queue_size) < 0) - return NULL; - - if (virXMLPropUInt(driver_node, "tx_queue_size", 10, - VIR_XML_PROP_NONE, - &def->driver.virtio.tx_queue_size) < 0) - return NULL; - - if (virXMLPropTristateSwitch(driver_node, "rss", - VIR_XML_PROP_NONE, - &def->driver.virtio.rss) < 0) - return NULL; - - if (virXMLPropTristateSwitch(driver_node, "rss_hash_report", - VIR_XML_PROP_NONE, - &def->driver.virtio.rss_hash_report) = < 0) - return NULL; - - if ((tmpNode =3D virXPathNode("./driver/host", ctxt))) { - if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NON= E, - &def->driver.virtio.host.csum) < = 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "gso", VIR_XML_PROP_NONE, - &def->driver.virtio.host.gso) < 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "tso4", VIR_XML_PROP_NON= E, - &def->driver.virtio.host.tso4) < = 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "tso6", VIR_XML_PROP_NON= E, - &def->driver.virtio.host.tso6) < = 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "ecn", VIR_XML_PROP_NONE, - &def->driver.virtio.host.ecn) < 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "ufo", VIR_XML_PROP_NONE, - &def->driver.virtio.host.ufo) < 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "mrg_rxbuf", - VIR_XML_PROP_NONE, - &def->driver.virtio.host.mrg_rxbu= f) < 0) - return NULL; - } - - if ((tmpNode =3D virXPathNode("./driver/guest", ctxt))) { - if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NON= E, - &def->driver.virtio.guest.csum) <= 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "tso4", VIR_XML_PROP_NON= E, - &def->driver.virtio.guest.tso4) <= 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "tso6", VIR_XML_PROP_NON= E, - &def->driver.virtio.guest.tso6) <= 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "ecn", VIR_XML_PROP_NONE, - &def->driver.virtio.guest.ecn) < = 0) - return NULL; - - if (virXMLPropTristateSwitch(tmpNode, "ufo", VIR_XML_PROP_NONE, - &def->driver.virtio.guest.ufo) < = 0) - return NULL; - } - } + if (virDomainNetDefParseXMLDriver(def, ctxt) < 0) + return NULL; if (def->type !=3D VIR_DOMAIN_NET_TYPE_HOSTDEV && virDomainNetIsVirtioModel(def)) { --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577737; cv=none; d=zohomail.com; s=zohoarc; b=eQEa6ODK1z3p/8O5lLv5e7cPWsEiVmHtp13H/S4D3VJxIqxFayFjtK0yDIb2qQp/UX58O/4XlytbXUSM+xh9I+VxHZMLMj+ztzgVacZGztNI2c44QLjyBJWl96NYH2qeRoMiXHYeG3EBig1FehgT6qIK4tiPjSh+f+WyMddJ6Hw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577737; 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=jYH3TFr9g/Ecs6fSDV+HyaTHbU+6OfoEQNIxNnta4RA=; b=YF3oZ4JEzZcyKkChmgCmX5cbYt66CeMGFN2LadM94k6Ff7ErnWfbqSeCblZkHaq+kYVEmHiZr3CVGfx9M/GR5XkmqfOVahXeuw9PsY8DOcUno4bpHhiyO6Qr1U533uvcf7G0beg3ow2KB0MYmOvWgV04HOnjb7hnzCK8T4NltFY= 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 1663577736993757.2370994599827; Mon, 19 Sep 2022 01:55:36 -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-127-IL-pEIz1Pcig5cpg-P7Btg-1; Mon, 19 Sep 2022 04:55:33 -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 2C2BF3817A61; Mon, 19 Sep 2022 08:55:31 +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 196342166B26; Mon, 19 Sep 2022 08:55:31 +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 E92941946594; Mon, 19 Sep 2022 08:55:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 72A2C1946586 for ; Mon, 19 Sep 2022 08:55:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 555BF40C6EC4; Mon, 19 Sep 2022 08:55:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE41240C6EC2 for ; Mon, 19 Sep 2022 08:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577736; 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=jYH3TFr9g/Ecs6fSDV+HyaTHbU+6OfoEQNIxNnta4RA=; b=Kpi+oN0YQCbqO24CdnJWDgv0tsMrzs3Toutuym3oNsaNI91ryqY3067Bpd3jRtVNOIIxJg Zph3eTfS6r9EOyS451OzCpzKJYmxDZLM9y/JtExo1XLy7pyZvyUxIRnXx6FxdFLN2+e5qq 8+FdQ/UnfRCKFPjrlfdXne4Ivec37Ig= X-MC-Unique: IL-pEIz1Pcig5cpg-P7Btg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/37] virDomainNetDefParseXML: Use virXMLPropEnumDefault for parsing 'def->type' Date: Mon, 19 Sep 2022 10:54:52 +0200 Message-Id: <77948cb9246425b523d72c60b1747c407c05e20a.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577739036100011 Content-Type: text/plain; charset="utf-8" Replace ad-hoc logic that fills the default by use of the proper helper function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 621b1df6c8..745a7e428c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9002,13 +9002,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, ctxt->node =3D node; - if ((rv =3D virXMLPropEnum(node, "type", virDomainNetTypeFromString, - VIR_XML_PROP_NONE, &def->type)) < 0) + if (virXMLPropEnumDefault(node, "type", virDomainNetTypeFromString, + VIR_XML_PROP_NONE, &def->type, VIR_DOMAIN_NE= T_TYPE_USER) < 0) return NULL; - if (rv =3D=3D 0) - def->type =3D VIR_DOMAIN_NET_TYPE_USER; - if (virXMLPropTristateBool(node, "trustGuestRxFilters", VIR_XML_PROP_N= ONE, &def->trustGuestRxFilters) < 0) return NULL; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577738; cv=none; d=zohomail.com; s=zohoarc; b=Lxwo+BE5srJBSvTFiA415DxJdt33rBdTMMQ57V2/XThnbyZlNK+gOhpF81Bt0K+8JHJcPtjayQZuN+rLOpSvkjaIcIV4uxGsDCgvllsIZ3MwDZUI0TTc4s5hGvfUywYQ1/D9A4w/fx3V/nXnAjTj3YLGjd8wLb0rLONXzIuhEXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577738; 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=Nd0wQT+Ma9jI0Nt/n0N7nvbU3BeKjFqNSwovz7Q5EVI=; b=XaUtWTT7+6BnuitFLATNGSHWtaoK7iVBvgr/3hfjLtM2YhicsWJSwRN8MCuFnLIu2cdooqdA+BkxrY11tmbLWuxmfwOPNAJWhdAwQBg3PBZVeq5uFaKOqZnvA9OXYLfYub3V9D+A3vfhF15/3s8CO2IGTFlYsn33brSVFCe1xEc= 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 1663577738899452.39468113529733; Mon, 19 Sep 2022 01:55:38 -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-146-pkqp5jdxM5Ox2C6Watd7Iw-1; Mon, 19 Sep 2022 04:55:34 -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 9A48F185A7A4; Mon, 19 Sep 2022 08:55: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 88A111121314; Mon, 19 Sep 2022 08:55: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 6DC421946594; Mon, 19 Sep 2022 08:55:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 41AE01946A42 for ; Mon, 19 Sep 2022 08:55:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 303E240C6EC4; Mon, 19 Sep 2022 08:55:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C2C340C6EC2 for ; Mon, 19 Sep 2022 08:55:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577737; 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=Nd0wQT+Ma9jI0Nt/n0N7nvbU3BeKjFqNSwovz7Q5EVI=; b=YvQHea8davst4rAQ94Zw9baFIMTNdr4jiH+bw9iEjlSkmbG/pLMvqsigYRG2fK2xidzt1e o6bivtXAtW1tGHqHF6orZBkCZmrvor3ztNloelR4DZmTyInyg9J5qXotu6x1NOWnWwv6O6 XksMulPyyULzcL+jrbR/7BPZJdGznwc= X-MC-Unique: pkqp5jdxM5Ox2C6Watd7Iw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/37] virDomainNetIPInfoParseXML: Remove pointless automatic clearing of 'route' and 'ip' Date: Mon, 19 Sep 2022 10:54:53 +0200 Message-Id: <11cdca1917b7ac9b2e13f86583d1dcc9b2c64709.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577739030100010 Content-Type: text/plain; charset="utf-8" The variables are only used in code paths which can't fail after they are allocated. Additionally decrease scope of the variables. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 745a7e428c..5c91cbd0db 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6216,17 +6216,17 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { - g_autoptr(virNetDevIPRoute) route =3D NULL; int nnodes; int ret =3D -1; size_t i; g_autofree xmlNodePtr *nodes =3D NULL; - g_autofree virNetDevIPAddr *ip =3D NULL; if ((nnodes =3D virXPathNodeSet("./ip", ctxt, &nodes)) < 0) goto cleanup; for (i =3D 0; i < nnodes; i++) { + virNetDevIPAddr *ip =3D NULL; + if (!(ip =3D virDomainNetIPParseXML(nodes[i]))) goto cleanup; @@ -6238,6 +6238,8 @@ virDomainNetIPInfoParseXML(const char *source, goto cleanup; for (i =3D 0; i < nnodes; i++) { + virNetDevIPRoute *route =3D NULL; + if (!(route =3D virNetDevIPRouteParseXML(source, nodes[i], ctxt))) goto cleanup; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577824; cv=none; d=zohomail.com; s=zohoarc; b=IZXJk068A59N9E3vTGwYjm6fyd8Gh8YzpNEWv/GBy3oqq4/+jbGGdyGdMsazh8L5oRQ1R7UwdqRSb/lmrT9mRNgjoEGx3pU80VipqXf7nW/IX7h5ZH/cNY4yF4aa+H2jyQovmYw6UL4jyC3TTt72u6p4KwRwlExbZenCQP9cA80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577824; 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=A2YJ/DOkDBvzrtvV5T9Nv2MO1FBVSRbnllEX/ZgCT+k=; b=i2ZI1jB+Zt6KMJyPiBXW5GyDLsFINKdhByS4JWQwzVcwzT/8kVBIsR/cvKkVMo5cuDhqjbba4ucvF5T7dhbyr29Ws1u/dQJzQ/lbMLN/vUTi8dqMYAk2NKoVc9rNSEMh3JsdMcb/e1kWftCGB1uGDoHmTlSsLOWJc2O0TxT5qHs= 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 1663577824170715.0885718641592; Mon, 19 Sep 2022 01:57: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-270-5goPTMSNMV68U2ETC28u7w-1; Mon, 19 Sep 2022 04:55:35 -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 D15978001B8; Mon, 19 Sep 2022 08:55:33 +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 BD30C140EBF3; Mon, 19 Sep 2022 08:55:33 +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 ADA721946594; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3A91D1946586 for ; Mon, 19 Sep 2022 08:55:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1D08040C6EC2; Mon, 19 Sep 2022 08:55:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 874AA40C6EC4 for ; Mon, 19 Sep 2022 08:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577823; 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=A2YJ/DOkDBvzrtvV5T9Nv2MO1FBVSRbnllEX/ZgCT+k=; b=av9+6n67QNGdWcFFFKOauSxmqVLCXUGAal6TjO6DP2w/hRtX6lDA5n0cmowX7VgifTl2Ju 3kflHf0pi/Wn3gYbwb4aMtMdsSe3r7iRuLiaKVur2RTlAKDKld8odH4C/LZ9osipGygcmJ xF+Q94+5lmzCqeyrqBO9A32LVSsT/iI= X-MC-Unique: 5goPTMSNMV68U2ETC28u7w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/37] virDomainNetIPInfoParseXML: Don't VIR_FREE and overwrite autofreed 'nodes' Date: Mon, 19 Sep 2022 10:54:54 +0200 Message-Id: <75a1c016ef8947c72f3346b2aab0729d62c7b51a.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577825767100001 Content-Type: text/plain; charset="utf-8" Use two separate variables for the nodes and count instead. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5c91cbd0db..797914b7bc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6216,31 +6216,32 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { - int nnodes; int ret =3D -1; size_t i; - g_autofree xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *ipNodes =3D NULL; + int nipNodes; + g_autofree xmlNodePtr *routeNodes =3D NULL; + int nrouteNodes; - if ((nnodes =3D virXPathNodeSet("./ip", ctxt, &nodes)) < 0) + if ((nipNodes =3D virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0) goto cleanup; - for (i =3D 0; i < nnodes; i++) { + for (i =3D 0; i < nipNodes; i++) { virNetDevIPAddr *ip =3D NULL; - if (!(ip =3D virDomainNetIPParseXML(nodes[i]))) + if (!(ip =3D virDomainNetIPParseXML(ipNodes[i]))) goto cleanup; VIR_APPEND_ELEMENT(def->ips, def->nips, ip); } - VIR_FREE(nodes); - if ((nnodes =3D virXPathNodeSet("./route", ctxt, &nodes)) < 0) + if ((nrouteNodes =3D virXPathNodeSet("./route", ctxt, &routeNodes)) < = 0) goto cleanup; - for (i =3D 0; i < nnodes; i++) { + for (i =3D 0; i < nrouteNodes; i++) { virNetDevIPRoute *route =3D NULL; - if (!(route =3D virNetDevIPRouteParseXML(source, nodes[i], ctxt))) + if (!(route =3D virNetDevIPRouteParseXML(source, routeNodes[i], ct= xt))) goto cleanup; VIR_APPEND_ELEMENT(def->routes, def->nroutes, route); --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577743; cv=none; d=zohomail.com; s=zohoarc; b=VLKKjlaHqnszC0jM95tVqoBsba7ym5ZWCTXeSvf5CwGi10woPCDtjtqalHRjiQE4Fd/h/4UTqrW2yJVlGs7BOVIIhT0YHmGISQmG2DBG3BbQi2VgGmU//fXn+zE+rf373lmjIkTISqFGKVcfZU1yCJokDC8IxFBDFZ3UfP0R6OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577743; 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=VVJnDUE3vyvtjamXert0Qpjl73Zb/G3nWFDM7vgU4vA=; b=f8a6LPNwFJBrSfxp8K/DzttOYy6jZbr3r4ALrcHyU9sOCNo0QwXN+cLwbUzPM9N1UJ39qjgFEz64WGBTrRnW/CwxcPSydYDfyYtTGFUbDP6uNm83p8zrQmNSx6zra61h94nTUF4wS2Uw2FyzscPyDL4cKeNW9rEr1KvFv+p/1V4= 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 1663577743438875.0528218771793; Mon, 19 Sep 2022 01:55:43 -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-377-KYCx7lXyOz2Kxek-A_wYjA-1; Mon, 19 Sep 2022 04:55:36 -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 571BD87B2B3; Mon, 19 Sep 2022 08:55: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 3F48D4221F; Mon, 19 Sep 2022 08:55: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 0D4891946A44; Mon, 19 Sep 2022 08:55:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0B3B01946595 for ; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F3DA140C6EC4; Mon, 19 Sep 2022 08:55:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72B1740C6EC3 for ; Mon, 19 Sep 2022 08:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577742; 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=VVJnDUE3vyvtjamXert0Qpjl73Zb/G3nWFDM7vgU4vA=; b=VricZPO54352/dOA9yxIAOyA3wie9NWiH/vmHGv9L3MTcGfxFs5vPGakvRJi4YkX3pfBvc 5/XJL3SX8EBPmUYedqP7KC/3t6yBG6UWFh/joY0ak4PXRp81jZnaQg0XoPLmNeSXUYFa66 amoVkUMb/RfN3eIl03iyWiT1SKM3umc= X-MC-Unique: KYCx7lXyOz2Kxek-A_wYjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/37] virDomainNetIPInfoParseXML: Simplify cleanup Date: Mon, 19 Sep 2022 10:54:55 +0200 Message-Id: <3de2e89a0e79302de44e7bf0abaf54f0a2d8b557.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577745096100003 Content-Type: text/plain; charset="utf-8" Do the XPath fetches first as they don't require cleanup and rename 'cleanup' to 'error' and take it only on failure. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 797914b7bc..1b52ea52c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6216,42 +6216,38 @@ virDomainNetIPInfoParseXML(const char *source, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { - int ret =3D -1; size_t i; g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes; g_autofree xmlNodePtr *routeNodes =3D NULL; int nrouteNodes; - if ((nipNodes =3D virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0) - goto cleanup; + if ((nipNodes =3D virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0 || + (nrouteNodes =3D virXPathNodeSet("./route", ctxt, &routeNodes)) < = 0) + return -1; for (i =3D 0; i < nipNodes; i++) { virNetDevIPAddr *ip =3D NULL; if (!(ip =3D virDomainNetIPParseXML(ipNodes[i]))) - goto cleanup; + goto error; VIR_APPEND_ELEMENT(def->ips, def->nips, ip); } - if ((nrouteNodes =3D virXPathNodeSet("./route", ctxt, &routeNodes)) < = 0) - goto cleanup; - for (i =3D 0; i < nrouteNodes; i++) { virNetDevIPRoute *route =3D NULL; if (!(route =3D virNetDevIPRouteParseXML(source, routeNodes[i], ct= xt))) - goto cleanup; + goto error; VIR_APPEND_ELEMENT(def->routes, def->nroutes, route); } - ret =3D 0; - cleanup: - if (ret < 0) - virNetDevIPInfoClear(def); - return ret; + return 0; + error: + virNetDevIPInfoClear(def); + return -1; } --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577742; cv=none; d=zohomail.com; s=zohoarc; b=TBzNU4YynJLtqXuQFkWOMi53/8D2HquNlzGrrDRUCB2EkdHkXh3kTe29ZzJv0iFNeyM8YODmlyKFi21wjZUqV4Ocp+W2pd8tcm1R/VoyGbFMqn0PnZ+P3DP62cNb6wOUppkwqFsbfgyYNIwwm2eJK44LWlK0sERXvumWoCfdw2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577742; 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=rBGt1f9N78cKJQktjKG68bm1FSP1n5M5OojDIILTq5M=; b=DBPlnvT9Sz6JTRGGZ8S7ehqGMpZidMGAAXXn4zMFYJBNn6dIrGzmuGw03L0KnLLp0HvwQe6wpsneCYsxzAbhxpHYuTm25EfwYSkixtV1ponzzHmz60mZg+mwA2XmvQj/NNi295/FZ2OHZAFTU+nmtZIHILFbPyYmmgE3ejiMnC4= 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 16635777426887.611761713116039; Mon, 19 Sep 2022 01:55:42 -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-582-T5LA2r74McK0YhS4_Z3z1w-1; Mon, 19 Sep 2022 04:55:37 -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 9B37C85A5A6; Mon, 19 Sep 2022 08:55:35 +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 8685C17583; Mon, 19 Sep 2022 08:55:35 +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 65BDD1946594; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0EE311946A45 for ; Mon, 19 Sep 2022 08:55:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E81FE40C6EC3; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54EA040C6EC4 for ; Mon, 19 Sep 2022 08:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577741; 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=rBGt1f9N78cKJQktjKG68bm1FSP1n5M5OojDIILTq5M=; b=cjDn86Uc/lWcbAU7uWe9Hv0GSahkLMPkDkFWNWpIFkxYbgtOzpy2tRaOxn+TiwFm5ZO32g 23Mnfd1mMECtQBIZHmPgWQWgFz/nxbN/P2ECIMnoT8EmeFX2MFyTrtwH2LSaW0tsTooNDR WR28Wbsi+a2ivnydkatiGjbwsaxipPI= X-MC-Unique: T5LA2r74McK0YhS4_Z3z1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/37] virDomainNetIPInfoParseXML: Don't force callers to set proper 'ctxt->node' Date: Mon, 19 Sep 2022 10:54:56 +0200 Message-Id: <20e69ba72fe0bd8b2afb29969f34d3bd47577eda.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577743073100001 Content-Type: text/plain; charset="utf-8" In certain cases it's inconvenient to move the XPAth's context current node in the caller. Add a 'node' argument and override it inside the function. VIR_XPATH_NODE_AUTORESTORE handles the cleanup. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1b52ea52c4..8b529acef6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6213,15 +6213,20 @@ virDomainNetIPParseXML(xmlNodePtr node) */ static int virDomainNetIPInfoParseXML(const char *source, + xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevIPInfo *def) { + VIR_XPATH_NODE_AUTORESTORE(ctxt) size_t i; g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes; g_autofree xmlNodePtr *routeNodes =3D NULL; int nrouteNodes; + if (node) + ctxt->node =3D node; + if ((nipNodes =3D virXPathNodeSet("./ip", ctxt, &ipNodes)) < 0 || (nrouteNodes =3D virXPathNodeSet("./route", ctxt, &routeNodes)) < = 0) return -1; @@ -6368,7 +6373,7 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNU= C_UNUSED, _("Missing element in hostdev net d= evice")); return -1; } - if (virDomainNetIPInfoParseXML(_("Domain hostdev device"), + if (virDomainNetIPInfoParseXML(_("Domain hostdev device"), NULL, ctxt, &def->source.caps.u.net.ip) <= 0) return -1; break; @@ -9010,12 +9015,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; if ((source_node =3D virXPathNode("./source", ctxt))) { - xmlNodePtr tmpnode =3D ctxt->node; - - ctxt->node =3D source_node; - if (virDomainNetIPInfoParseXML(_("interface host IP"), ctxt, &def-= >hostIP) < 0) + if (virDomainNetIPInfoParseXML(_("interface host IP"), source_node= , ctxt, &def->hostIP) < 0) return NULL; - ctxt->node =3D tmpnode; if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { network =3D virXMLPropString(source_node, "network"); @@ -9463,7 +9464,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; } - if (virDomainNetIPInfoParseXML(_("guest interface"), + if (virDomainNetIPInfoParseXML(_("guest interface"), node, ctxt, &def->guestIP) < 0) return NULL; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577833; cv=none; d=zohomail.com; s=zohoarc; b=d49oTh+/RLozfWafIlGljUpvTpi5op+HEz8o4yB4w10pbk4tyduoU7a6v7pu1xQgea26T0drj5/hWTxrrroZoeuS/XJ7ikveI777SQaFpeoyHrd304/SAb0aYdj6M4efpxN+D92KUIN4FiCAUOd2DjAjhOMLda5YYlogo79eOHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577833; 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=2G8Gw7/0k3CgI+K8ZAhMn9U4caG/fFM+IMzQlxMFSxI=; b=C+Moct3TmwL2mVw35AJkaMhoGiNmVN4TbjO6mqXOKBMzDg8/HGM4whmr2g0XqLLoqpclqNvdtbuidZ0aoKCwumL3DqGHnRnTrd0H8k67UfC0PXMLDUL1OWnsCRHAqvB5kXFmJsdpqOgvbbs3oPd8Y2v2SAYgJ6q2oxMkZvdCBSI= 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 1663577833240945.307651390101; Mon, 19 Sep 2022 01:57:13 -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-144-olnylmcLP0OwXJcRhYIfug-1; Mon, 19 Sep 2022 04:55:39 -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 E26DE86C040; Mon, 19 Sep 2022 08:55: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 CDDE64A9254; Mon, 19 Sep 2022 08:55: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 BC15B1946595; Mon, 19 Sep 2022 08:55:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 05DB31946586 for ; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DEE3740C6EC2; Mon, 19 Sep 2022 08:55:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65C7440369A8 for ; Mon, 19 Sep 2022 08:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577831; 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=2G8Gw7/0k3CgI+K8ZAhMn9U4caG/fFM+IMzQlxMFSxI=; b=OexDSG1uEZfyYeyIz6EDE+S/0Y9cIbLDCv8P7HmCaznFTxNv9qWtI3fxol3xYWbySgHblA bNQdTa5vtt8fD3LgXpy6dpJpk5IV31HnvWxHKtVrsBHa1XuPyvJ4oDGtiwDDdgJD8NNZz6 +pMKuKiSGEKOdL04WCTOAcMngjFtuNg= X-MC-Unique: olnylmcLP0OwXJcRhYIfug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/37] util: xml: Introduce virXMLPropUUID Date: Mon, 19 Sep 2022 10:54:57 +0200 Message-Id: <2074d74066cc62b8db887fe16450fc1832cd0c40.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577833815100001 Content-Type: text/plain; charset="utf-8" The helper function extracts an UUID with semantics similar to other helpers we have. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virxml.c | 45 ++++++++++++++++++++++++++++++++++++++++ src/util/virxml.h | 7 +++++++ 3 files changed, 53 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 25794bc2f4..1e852902ab 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3688,6 +3688,7 @@ virXMLPropTristateBoolAllowDefault; virXMLPropTristateSwitch; virXMLPropUInt; virXMLPropULongLong; +virXMLPropUUID; virXMLSaveFile; virXMLValidateAgainstSchema; virXMLValidatorFree; diff --git a/src/util/virxml.c b/src/util/virxml.c index d6e2e5dd91..04a8b29ba3 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -33,6 +33,7 @@ #include "virfile.h" #include "virstring.h" #include "virutil.h" +#include "viruuid.h" #include "configmake.h" #define VIR_FROM_THIS VIR_FROM_XML @@ -808,6 +809,50 @@ virXMLPropEnumDefault(xmlNodePtr node, } +/** + * virXMLPropUUID: + * @node: XML dom node pointer + * @name: Name of the property (attribute) to get + * @flags: Bitwise or of virXMLPropFlags + * @result: array of VIR_UUID_BUFLEN bytes to store the raw UUID + * + * Convenience function to fetch a XML property as UUID. + * + * Returns 1 in case of success in which case @result is set, + * or 0 if the attribute is not present, + * or -1 and reports an error on failure. + */ +int +virXMLPropUUID(xmlNodePtr node, + const char* name, + virXMLPropFlags flags, + unsigned char *result) +{ + g_autofree char *tmp =3D NULL; + unsigned char val[VIR_UUID_BUFLEN]; + + if (!(tmp =3D virXMLPropString(node, name))) { + if (!(flags & VIR_XML_PROP_REQUIRED)) + return 0; + + virReportError(VIR_ERR_XML_ERROR, + _("Missing required attribute '%s' in element '%s'"= ), + name, node->name); + return -1; + } + + if (virUUIDParse(tmp, val) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : '%s'. Expected UUID"), + name, node->name, tmp); + return -1; + } + + memcpy(result, val, VIR_UUID_BUFLEN); + return 1; +} + + /** * virXMLPropEnum: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index 539228a9ba..dfb58ff276 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -154,6 +154,13 @@ virXMLPropEnum(xmlNodePtr node, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5); +int +virXMLPropUUID(xmlNodePtr node, + const char* name, + virXMLPropFlags flags, + unsigned char *result) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); + int virXMLPropEnumDefault(xmlNodePtr node, const char* name, --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577746; cv=none; d=zohomail.com; s=zohoarc; b=JhwY42AJlkTbfsOAy2lL3QUZd5MS5DCMOWBPORe16tZGrWTGv15HP/02SShtlzSvyiRCkdBW9AmdbC8cRrLoNI/h3TwHydjjNDsmsCP1ggdL4+rYNGW//PZx5beOazl8lCjmlqIO2I666A5RVFbwEdluXXZ/O7qWXXhCgCoHOV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577746; 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=sv+y42MZKZFoh2g4rRu20atjDRmhZZSF9A+8vnsvk1M=; b=hHdL0q9HzC2ta7qPujRfJjSIao/P6M+grpW2pBQRD+9v52HoNsNSh0ulUqnApCZrwsfZQ2h51vEiU+yjQt+Vy4taMV1w9i8Qk6KfHwSk0c4cMHAvh0yz+y3SwD3qdd2m+grEhcO/7/xiLfv2M88LppZS289eI3018ku7FrNB4nA= 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 166357774665939.59226340228679; Mon, 19 Sep 2022 01:55:46 -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-190-wWsEE_m9PNOz9csK2V8gBQ-1; Mon, 19 Sep 2022 04:55:39 -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 73862100DEAB; Mon, 19 Sep 2022 08:55:37 +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 4F426112131E; Mon, 19 Sep 2022 08:55:37 +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 10E071946A41; Mon, 19 Sep 2022 08:55:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C6DEC1946597 for ; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BB20140C6EC3; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3892940C6EC2 for ; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577745; 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=sv+y42MZKZFoh2g4rRu20atjDRmhZZSF9A+8vnsvk1M=; b=SGV77pLVq5lc+YSOurbLMIIU/avXjQs/1GhGyWV3DVTdHQiuCNRE/SOBc9rO7x6MpdyWJJ HhQmohI3gvser6P6GUzZqs29JNs2cT65PAvusR8P9nZWkxxQ1osVGLzydHyFWZZghhlSyG ghKGEwn0OvVo+0RQC1QD3ZhJX43H2bM= X-MC-Unique: wWsEE_m9PNOz9csK2V8gBQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/37] util: xml: Adjust documentation of virXMLPropString Date: Mon, 19 Sep 2022 10:54:58 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577747086100005 Content-Type: text/plain; charset="utf-8" All callers treat NULL as if the string is not present in the XML. Adjust the description so that it's implied that it's not an error and thus also no error reporting is expected. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 04a8b29ba3..eac2d0a73f 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -443,7 +443,8 @@ virXMLCheckIllegalChars(const char *nodeName, * * Convenience function to return copy of an attribute value of a XML node. * - * Returns the property (attribute) value as string or NULL in case of fai= lure. + * Returns the property (attribute) value as string or NULL if the attribu= te + * is not present (no error is reported). * The caller is responsible for freeing the returned buffer. */ char * --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577826; cv=none; d=zohomail.com; s=zohoarc; b=UyB+WnTWgzmjr9ije9HONWV03Hrje7eikImdfeOihDz10iKcad4o8hMZaD8sXOof2uP/azTEIPpPypPT+5f0kfaqhdiYJj1sxFSkgDX3AfaxEyC48oIQWoEl8QaKB+NjEDuw1woRNMTymxyxVm76U36IVoTFSXbrWhZ7E4p3Al0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577826; 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=9bfdpnDVV9qNv2llYo4GsCsNUR8ywIszmQsYJVTWoQI=; b=WqXfpOlFHAmuM5aIyHBD4+tOHlly0bpOrv6RZOYa/uEuBI4s2WAgDPYkv7+/aeQe+AYhXER6uK8B9azqUF4xrlZzJDJ8rhzGJ79Abg/l/nb1AmNjvYUhBeVdjGBCYUzv84jRfAdpyhSpxouRyqRb93FPaInlMLFZyBxkzLuO430= 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 166357782603426.650939177216287; Mon, 19 Sep 2022 01:57:06 -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-614-hpqHmDiZOQSfVY7puD6Rcg-1; Mon, 19 Sep 2022 04:55:42 -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 9ECED1C0BE00; Mon, 19 Sep 2022 08:55:37 +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 8C03F492B09; Mon, 19 Sep 2022 08:55:37 +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 7FF9819465A0; Mon, 19 Sep 2022 08:55:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BBEBD1946594 for ; Mon, 19 Sep 2022 08:55:36 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B21F140C6EC3; Mon, 19 Sep 2022 08:55:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 314C140C6EC2 for ; Mon, 19 Sep 2022 08:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577824; 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=9bfdpnDVV9qNv2llYo4GsCsNUR8ywIszmQsYJVTWoQI=; b=UQgp62voURVb5d6aICWGJbDbUc1e1g9uD9i9LkgXc++Xshd0r55T2P9kazLUEupHiVMqpY eR7vUMu5GzMBdsZvfp+rOzHWhC/m7vcmt/WFs12voZyxVn+oNH0lxgdlEyDE+FfmjfO7U3 Xy7JZ17Y9WiGTpLV7XBOz4+xmEOhf9E= X-MC-Unique: hpqHmDiZOQSfVY7puD6Rcg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/37] util: xml: Introduce virXMLPropStringRequired Date: Mon, 19 Sep 2022 10:54:59 +0200 Message-Id: <634b7fa169ac77ee84260b612dc425e4345befb9.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577827755100009 Content-Type: text/plain; charset="utf-8" Similarly to virXMLPropString it extracts a string but reports an errori similar to the newer virXMLProp helpers if the attribute is not present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virxml.c | 27 +++++++++++++++++++++++++++ src/util/virxml.h | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1e852902ab..01bb349e05 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3683,6 +3683,7 @@ virXMLPropEnum; virXMLPropEnumDefault; virXMLPropInt; virXMLPropString; +virXMLPropStringRequired; virXMLPropTristateBool; virXMLPropTristateBoolAllowDefault; virXMLPropTristateSwitch; diff --git a/src/util/virxml.c b/src/util/virxml.c index eac2d0a73f..b94af9c7a3 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -455,6 +455,33 @@ virXMLPropString(xmlNodePtr node, } +/** + * virXMLPropStringRequired: + * @node: XML dom node pointer + * @name: Name of the property (attribute) to get + * + * Convenience function to return copy of an mandatoryu attribute value of= a + * XML node. + * + * Returns the property (attribute) value as string or NULL and if the att= ribute + * is not present (libvirt error reported). + * The caller is responsible for freeing the returned buffer. + */ +char * +virXMLPropStringRequired(xmlNodePtr node, + const char *name) +{ + char *ret =3D virXMLPropString(node, name); + + if (!(*ret)) + virReportError(VIR_ERR_XML_ERROR, + _("Missing required attribute '%s' in element '%s'= "), + name, node->name); + + return ret; +} + + /** * virXMLNodeContentString: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index dfb58ff276..42d3740c58 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -97,6 +97,10 @@ char * virXMLPropString(xmlNodePtr node, const char *name); char * +virXMLPropStringRequired(xmlNodePtr node, + const char *name); + +char * virXMLNodeContentString(xmlNodePtr node); int --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577757; cv=none; d=zohomail.com; s=zohoarc; b=P7mQ3Agjlxr9gCvzCPneiRmwFLxgba+/sEYjfhThMryK01MhvORevJDRLWjv1WEO40Nj5ByXX7UT2HyTmqB1GIs5bSasnLGheygsf/7l9o9EwB19xKPMEtQA58+Um+NaE96YBtEiBX7BhGzfKUL2gwDl8IPcy5/Xqyfp3V+Vj7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577757; 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=9Kwmrdxx7XGNer+9qEJ6YTsTyNFGwaf5lOIPPK0Kpts=; b=H35kCmI62bA1cZooldbMZTcQwVS9RqjrEwu62M0PjZ9/WOfvWNC68SX8l/ERTfsf8pC7Bo0Uuyay3ApEBqKKOOi0+vv53HVk0MM7aotrVRr7Puj0YlYLlL/feJ/++oUdLfy29iIMic6vW59TjyT3GGNeEkMhZeDSFekdxJ5FZqU= 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 1663577756949804.9531508704222; Mon, 19 Sep 2022 01:55:56 -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-635-Wo7kYHVoPRihCyGP0a90ug-1; Mon, 19 Sep 2022 04:55:47 -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 1F090185A7AE; Mon, 19 Sep 2022 08:55: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 0BA86C15BA4; Mon, 19 Sep 2022 08:55: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 EA52B1946594; Mon, 19 Sep 2022 08:55:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C50A019465A2 for ; Mon, 19 Sep 2022 08:55:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A546F40C6EC5; Mon, 19 Sep 2022 08:55:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23F0D40C6EC3 for ; Mon, 19 Sep 2022 08:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577754; 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=9Kwmrdxx7XGNer+9qEJ6YTsTyNFGwaf5lOIPPK0Kpts=; b=XKNm6JvgyB5BR5Ga6lM3XdysSnnfyb7paggBysqMVhF+L6Ferf+1T9ES6aH9BLAfbgHk8O NXzZ1gS5LzoIgQCXdqPJP53DstW6lCm+MDJPp96+pW4Mre5RsoRFf9k5ovxyavbgKGsdFe 9rTduj2TN5gojkDwzNHnibeyRw4L9io= X-MC-Unique: Wo7kYHVoPRihCyGP0a90ug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/37] virDomainNetDefParseXML: Convert parsing of 'source_node' to a switch() statement Date: Mon, 19 Sep 2022 10:55:00 +0200 Message-Id: <82fe66c39926b07d6006c0c943efe55d74b4492a.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577759169100004 Content-Type: text/plain; charset="utf-8" Convert the individual 'if' clauses to a swtich statement. By moving the check that 'source_node' is non-null inside of each case rather we will be able to move more type specific code into the swithc statemen when it will be refactored in subsequent patches. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 71 +++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8b529acef6..d75ce46a7f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9017,32 +9017,47 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if ((source_node =3D virXPathNode("./source", ctxt))) { if (virDomainNetIPInfoParseXML(_("interface host IP"), source_node= , ctxt, &def->hostIP) < 0) return NULL; + } - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { + switch (def->type) { + case VIR_DOMAIN_NET_TYPE_NETWORK: + if (source_node) { network =3D virXMLPropString(source_node, "network"); portgroup =3D virXMLPropString(source_node, "portgroup"); if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) portid =3D virXMLPropString(source_node, "portid"); } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDS) { + case VIR_DOMAIN_NET_TYPE_VDS: + if (source_node) { switchid =3D virXMLPropString(source_node, "switchid"); portid =3D virXMLPropString(source_node, "portid"); portgroup =3D virXMLPropString(source_node, "portgroupid"); connectionid =3D virXMLPropString(source_node, "connectionid"); } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_INTERNAL) + case VIR_DOMAIN_NET_TYPE_INTERNAL: + if (source_node) { internal =3D virXMLPropString(source_node, "name"); + } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE) + case VIR_DOMAIN_NET_TYPE_BRIDGE: + if (source_node) { bridge =3D virXMLPropString(source_node, "bridge"); + } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT) { + case VIR_DOMAIN_NET_TYPE_DIRECT: + if (source_node) { dev =3D virXMLPropString(source_node, "dev"); mode =3D virXMLPropString(source_node, "mode"); } + break; + case VIR_DOMAIN_NET_TYPE_ETHERNET: /* This clause is only necessary because from 2010 to 2016 it was * possible (but never documented) to configure the name of the * guest-side interface of an openvz domain with . @@ -9051,33 +9066,40 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, * need to generate an error. If the openvz driver is ever * deprecated, this clause can be removed from here. */ - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && - (dev =3D virXMLPropString(source_node, "dev"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid attempt to set " - "device name with . " - "Use (for host-side) " - "or (for guest-side) inst= ead."), - dev, dev, dev); - return NULL; + if (source_node) { + if ((dev =3D virXMLPropString(source_node, "dev"))) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid attempt to set " + "device name with . " + "Use (for host-side)= " + "or (for guest-side) = instead."), + dev, dev, dev); + return NULL; + } } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VHOSTUSER) { + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + if (source_node) { vhostuser_type =3D virXMLPropString(source_node, "type"); vhostuser_path =3D virXMLPropString(source_node, "path"); vhostuser_mode =3D virXMLPropString(source_node, "mode"); if (virDomainChrSourceReconnectDefParseXML(&reconnect, source_= node, ctxt) < 0) return NULL; } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_VDPA) + case VIR_DOMAIN_NET_TYPE_VDPA: + if (source_node) { dev =3D virXMLPropString(source_node, "dev"); + } + break; - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_SERVER || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_CLIENT || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_MCAST || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { - + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_UDP: + if (source_node) { address =3D virXMLPropString(source_node, "address"); port =3D virXMLPropString(source_node, "port"); if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { @@ -9090,6 +9112,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, ctxt->node =3D tmp_node; } } + break; + + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_NULL: + case VIR_DOMAIN_NET_TYPE_LAST: + break; } if ((virtualport_node =3D virXPathNode("./virtualport", ctxt))) { --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577891; cv=none; d=zohomail.com; s=zohoarc; b=lEyB5hXHi2PlSyrf0FDzcIawsw9SklNB00tCeYyj2rzeX1Ftr/NvZ06+XMGFBgtnjmZTGmQjDmy85zLGxUOuH0o8Ybx1kjrShHvE6WTVK8GLiw2lWJjc49cYXJQmzKf6V8gNQRR8I9OHFTEBq4WkOg0eAvQStXF3qF9GXNY8hbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577891; 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=cBDhHR9atJYkk91rrJp2ULWwZh/GYKeKW2MW6TUDNe8=; b=c0OUcpEGZqVU97Wi1Ubc9ETHyhJv1sImnzteRvU2XEJ52yphEYx6O5kyuIY/SOIQo4ZOOTducEd2llMU/4YJ0pAMiJOjbdwL0N5JETboTsBL8L+jREsjgPiwqwma7omHYxteKqq/ohva7GXlgmfspS10pEEie5zNYMbiDTOG0+I= 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 1663577891456606.5941878758641; Mon, 19 Sep 2022 01:58:11 -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-_lZkFitFNOCU11wEMIK64A-1; Mon, 19 Sep 2022 04:55: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 8BF76100DEB1; Mon, 19 Sep 2022 08:55: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 756E11121314; Mon, 19 Sep 2022 08:55: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 594F81946595; Mon, 19 Sep 2022 08:55:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A32CC1946597 for ; Mon, 19 Sep 2022 08:55:38 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9840340C6EC3; Mon, 19 Sep 2022 08:55:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03BB440C6EC2 for ; Mon, 19 Sep 2022 08:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577890; 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=cBDhHR9atJYkk91rrJp2ULWwZh/GYKeKW2MW6TUDNe8=; b=Vuef+4X+Rwmp/GAi1O2Jj2o3RmvWZn1l+n67GSJPJGbTKZ7hwGJotBley6dcVPrZfO4hJ9 430sS7nik09BygySaQUgqoXkes8kdjT4T8BZL1gn9tQLDPR7R1tFy1nH4kkNU8hgFqJ4wM 3koEagTz2Rr1iNtp5mpVIeUTwsVgox4= X-MC-Unique: _lZkFitFNOCU11wEMIK64A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_NETWORK Date: Mon, 19 Sep 2022 10:55:01 +0200 Message-Id: <018d992d16dd833f976722eb7295c11df473b442.1663577577.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577892078100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 68 +++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d75ce46a7f..de0a038526 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8955,6 +8955,21 @@ virDomainNetDefParseXMLDriver(virDomainNetDef *def, } +static int +virDomainNetDefParseXMLRequireSource(virDomainNetDef *def, + xmlNodePtr source_node) +{ + if (!source_node) { + virReportError(VIR_ERR_XML_ERROR, + _("interface type=3D'%s' requires a 'source' elemen= t"), + virDomainNetTypeToString(def->type)); + return -1; + } + + return 0; +} + + static virDomainNetDef * virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -8966,18 +8981,15 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr source_node =3D NULL; xmlNodePtr virtualport_node =3D NULL; xmlNodePtr filterref_node =3D NULL; - xmlNodePtr actual_node =3D NULL; xmlNodePtr vlan_node =3D NULL; xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr tmpNode; xmlNodePtr mac_node =3D NULL; g_autoptr(GHashTable) filterparams =3D NULL; - g_autoptr(virDomainActualNetDef) actual =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; g_autofree char *macaddr =3D NULL; - g_autofree char *network =3D NULL; g_autofree char *portgroup =3D NULL; g_autofree char *portid =3D NULL; g_autofree char *bridge =3D NULL; @@ -9021,11 +9033,28 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: - if (source_node) { - network =3D virXMLPropString(source_node, "network"); - portgroup =3D virXMLPropString(source_node, "portgroup"); - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - portid =3D virXMLPropString(source_node, "portid"); + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.network.name =3D virXMLPropStringRequired(source_n= ode, "network"))) + return NULL; + + def->data.network.portgroup =3D virXMLPropString(source_node, "por= tgroup"); + + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + if (virXMLPropUUID(source_node, "portid", VIR_XML_PROP_NONE, + def->data.network.portid) < 0) + return NULL; + } + + if ((flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET)) { + xmlNodePtr actual_node =3D NULL; + + if ((actual_node =3D virXPathNode("./actual", ctxt)) && + (virDomainActualNetDefParseXML(actual_node, ctxt, def, + &def->data.network.actual, + flags, xmlopt) < 0)) + return NULL; } break; @@ -9163,13 +9192,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, filterparams =3D virNWFilterParseParamAttributes(filterref_node); } - if ((flags & VIR_DOMAIN_DEF_PARSE_ACTUAL_NET) && - def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && - (actual_node =3D virXPathNode("./actual", ctxt)) && - (virDomainActualNetDefParseXML(actual_node, ctxt, def, - &actual, flags, xmlopt) < 0)) - return NULL; - if ((bandwidth_node =3D virXPathNode("./bandwidth", ctxt)) && (virNetDevBandwidthParse(&def->bandwidth, NULL, bandwidth_node, def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETW= ORK) < 0)) @@ -9225,22 +9247,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: - if (network =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'network' attribute " - "specified with = ")); - return NULL; - } - if (portid && - virUUIDParse(portid, def->data.network.portid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse port id '%s'"), portid); - return NULL; - } - - def->data.network.name =3D g_steal_pointer(&network); - def->data.network.portgroup =3D g_steal_pointer(&portgroup); - def->data.network.actual =3D g_steal_pointer(&actual); break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577885; cv=none; d=zohomail.com; s=zohoarc; b=nlfnS+nVQlRSKLIcHOX63OZg9p4YOamXDPDvUArJoUptEgBWxTTud3mAnM+23jwSJQoqpoiu5ZcwGXQf8tvTk+Dg0pfDbwjNIxW6OUhxReUFxi01Sq/kLkFxWT8IthcQc2vLRZXPN5difhModbQPGHXw6fVvJCQf48Ac6mvNil8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577885; 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=DXzhKrrqge/+JBu+Hit1mfeDvvHDOltZEesusjP69Ac=; b=hFp0lb76IbrSv3LxBQHc1w8g+ceHgM0Rb7OHRon/ePBNiV6+K+fNPeX9OA7yY29NsiAy/1CctOkHTem/1Bv05dlNF7oSmSxIXr/PXtHDSe7luQqDBHYq4GDefxQRPTT3ERfiqj99oyUudKvH0HyrFh9F8cfgEqpaTa3uZdlqnkM= 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 1663577885294831.2651508621042; Mon, 19 Sep 2022 01:58: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-219-CETWpB66OfqUZZyp90Q-PQ-1; Mon, 19 Sep 2022 04:55:43 -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 A5EA5800B30; Mon, 19 Sep 2022 08:55: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 93CC735429; Mon, 19 Sep 2022 08:55: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 78D4319465A3; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9529319465A3 for ; Mon, 19 Sep 2022 08:55:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 84C4540C6EC3; Mon, 19 Sep 2022 08:55:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F096140C6EC2 for ; Mon, 19 Sep 2022 08:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577884; 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=DXzhKrrqge/+JBu+Hit1mfeDvvHDOltZEesusjP69Ac=; b=TreO3caE1vW3DHKlTnV/toiei7u86evCLfrP2wBRS5eqU9j3zUKh8M04cC+vn7f4bIedNL DWlp1osjY5hJgaOP9heQS42mlcXDvm//AwMhOlqe89f7gBlsA3bByjIBmiAqvG0v01T8NN YAOvwwV7fWyEDIpWjxdOalND4rF0XfM= X-MC-Unique: CETWpB66OfqUZZyp90Q-PQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/37] util: xml: Introduce virXMLPropLongLong Date: Mon, 19 Sep 2022 10:55:02 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577886056100002 Content-Type: text/plain; charset="utf-8" Add a helper for parsing long long values from XML properties with semantics like virXMLPropInt. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virxml.c | 64 ++++++++++++++++++++++++++++++++++++++++ src/util/virxml.h | 9 ++++++ 3 files changed, 74 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 01bb349e05..5be40dbefe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3682,6 +3682,7 @@ virXMLPickShellSafeComment; virXMLPropEnum; virXMLPropEnumDefault; virXMLPropInt; +virXMLPropLongLong; virXMLPropString; virXMLPropStringRequired; virXMLPropTristateBool; diff --git a/src/util/virxml.c b/src/util/virxml.c index b94af9c7a3..0a91fd237e 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -750,6 +750,70 @@ virXMLPropUInt(xmlNodePtr node, } +/** + * virXMLPropLongLong: + * @node: XML dom node pointer + * @name: Name of the property (attribute) to get + * @base: Number base, see strtol + * @flags: Bitwise or of virXMLPropFlags + * @result: The returned value + * @defaultResult: default value of @result in case the property is not fo= und + * + * Convenience function to return value of a long long attribute. + * + * Returns 1 in case of success in which case @result is set, + * or 0 if the attribute is not present, + * or -1 and reports an error on failure. + */ +int +virXMLPropLongLong(xmlNodePtr node, + const char* name, + int base, + virXMLPropFlags flags, + long long *result, + long long defaultResult) +{ + g_autofree char *tmp =3D NULL; + long long val; + + *result =3D defaultResult; + + if (!(tmp =3D virXMLPropString(node, name))) { + if (!(flags & VIR_XML_PROP_REQUIRED)) + return 0; + + virReportError(VIR_ERR_XML_ERROR, + _("Missing required attribute '%s' in element '%s'"= ), + name, node->name); + return -1; + } + + if (virStrToLong_ll(tmp, NULL, base, &val) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : '%s'. Expected long long integer value"), + name, node->name, tmp); + return -1; + } + + if ((flags & VIR_XML_PROP_NONNEGATIVE) && (val < 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : '%s'. Expected non-negative value"), + name, node->name, tmp); + return -1; + } + + if ((flags & VIR_XML_PROP_NONZERO) && (val =3D=3D 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value for attribute '%s' in element '%s'= : Zero is not permitted"), + name, node->name); + return -1; + } + + *result =3D val; + return 1; +} + + /** * virXMLPropULongLong: * @node: XML dom node pointer diff --git a/src/util/virxml.h b/src/util/virxml.h index 42d3740c58..3b00d20ea9 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -141,6 +141,15 @@ virXMLPropUInt(xmlNodePtr node, unsigned int *result) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); +int +virXMLPropLongLong(xmlNodePtr node, + const char* name, + int base, + virXMLPropFlags flags, + long long *result, + long long defaultResult) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5); + int virXMLPropULongLong(xmlNodePtr node, const char* name, --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577779; cv=none; d=zohomail.com; s=zohoarc; b=RE5782HuajYIiCUtMOdcdZLkjzpooTSGr3+PU6Y7K9KtTeLLr6xU43+ra5ku+HpgtwM07ljnUTLKSNRSSdIrIQMbn0/Fm7uXoZ7RrhkZy1HCyTlgcMm1CPoxzU7xpT8HFaEJl6k9BeAMJmi6JatgfEqjpAVGK+ybs/kRaB2mTFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577779; 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=IMpDaLEX0IxCc/jCaD5q/lDBWI3L8jWD7BTDLqtOT0c=; b=mxulFQF+8TJxdK63Hs1uR1CbIEiiTCjsr7QzrvEc4e96TdpyNAqgvoKQKBEC77tN0yDEmywr0ZU7oyZs2USnVG0YnSyHx4Wn35cpLPZ6OqancYNLeEk0Exazh7GWOF+dtfzrcDU9nf97HM5gz49L1+S1CZJMURKC4OuzHXfj6CQ= 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 1663577779053228.48160935944702; Mon, 19 Sep 2022 01:56:19 -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-472-DgFmuGyZMxq_nraV2PxhOw-1; Mon, 19 Sep 2022 04:55:45 -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 284473825785; Mon, 19 Sep 2022 08:55: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 D1E7A2086F61; Mon, 19 Sep 2022 08:55:42 +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 C2E4119465A0; Mon, 19 Sep 2022 08:55:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 832A719465A4 for ; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 765B640C6EC2; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2DD040C6EC3 for ; Mon, 19 Sep 2022 08:55:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577778; 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=IMpDaLEX0IxCc/jCaD5q/lDBWI3L8jWD7BTDLqtOT0c=; b=IIUmL8y7xZJhBrcnx5S8N3HD3kZsMZu+3lTTB4uCPYMlKebNBNCTm4p9bN1PHJsdDzKD0b b7ve84B6GCXSeQxMxpVMaAYfqrk+r//ndpZtEhW0B0eWU6VNZtmGa+DcUoMeCZEMdUQPoI G7hUe8y5COPz4sQ5/qRdG+op3q+CbI8= X-MC-Unique: DgFmuGyZMxq_nraV2PxhOw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDS Date: Mon, 19 Sep 2022 10:55:03 +0200 Message-Id: <2909e25d0086335f993e1d5810ffe6ea12ab336c.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577779491100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 78 ++++++++++-------------------------------- 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de0a038526..cdf94ac75d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8990,8 +8990,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; g_autofree char *macaddr =3D NULL; - g_autofree char *portgroup =3D NULL; - g_autofree char *portid =3D NULL; g_autofree char *bridge =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; @@ -9009,8 +9007,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *vhostuser_path =3D NULL; g_autofree char *vhostuser_type =3D NULL; g_autofree char *tap =3D NULL; - g_autofree char *switchid =3D NULL; - g_autofree char *connectionid =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def =3D virDomainNetDefNew(xmlopt))) @@ -9059,12 +9055,24 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDS: - if (source_node) { - switchid =3D virXMLPropString(source_node, "switchid"); - portid =3D virXMLPropString(source_node, "portid"); - portgroup =3D virXMLPropString(source_node, "portgroupid"); - connectionid =3D virXMLPropString(source_node, "connectionid"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (virXMLPropUUID(source_node, "switchid", VIR_XML_PROP_REQUIRED, + def->data.vds.switch_id) < 0) + return NULL; + + if (virXMLPropLongLong(source_node, "portid", 0, VIR_XML_PROP_REQU= IRED, + &def->data.vds.port_id, def->data.vds.port_= id) < 0) + return NULL; + + if (!(def->data.vds.portgroup_id =3D virXMLPropStringRequired(sour= ce_node, "portgroupid"))) + return NULL; + + if (virXMLPropLongLong(source_node, "connectionid", 0, VIR_XML_PRO= P_REQUIRED, + &def->data.vds.connection_id, def->data.vds= .connection_id) < 0) + return NULL; + break; case VIR_DOMAIN_NET_TYPE_INTERNAL: @@ -9442,56 +9450,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDS: - if (!switchid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source switchid for interface type '= %s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!portid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source portid for interface type '%s= '"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!connectionid) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source connectionid for interface ty= pe '%s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (!portgroup) { - virReportError(VIR_ERR_XML_ERROR, - _("Missing source portgroup for interface type = '%s'"), - virDomainNetTypeToString(def->type)); - return NULL; - } - - if (virUUIDParse(switchid, def->data.vds.switch_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse switchid '%s'"), switchid); - return NULL; - } - - if (virStrToLong_ll(portid, NULL, 0, &def->data.vds.port_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse portid '%s'"), portid); - return NULL; - } - - if (virStrToLong_ll(connectionid, NULL, 0, &def->data.vds.connecti= on_id) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse connectionid '%s'"), connect= ionid); - return NULL; - } - - def->data.vds.portgroup_id =3D g_steal_pointer(&portgroup); - - break; - case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_NULL: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577775; cv=none; d=zohomail.com; s=zohoarc; b=Mx+M9Ch7tqUVLBU8VXL/C66TcmRiDTxq+/5OR+T/2A1uroNVBKCu9yPZuWXbxTHnWMb0CdgdiK/u5PLl6VKoWS2jqECNEV2FwlqvPlZUSovvnPPtDz6OC746SDvebPtp7bsihBW4UlRXapPj0aarxiny6nGDg2efpquK3uXcplk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577775; 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=u0Iq7ddgvhb4w/nUX36hOP0VAtOHtn7u1FesBKFjCyY=; b=ObMlIvLQyIIxc0BgD3Ye7OWXAWMuQMl2HBOzIFb7bRD5iI/AEee4orBC10V5xN2VZCMiz72iG8wACRKbmxv3RtnKlV8YbDECbVGj3CDViq1caEkoFnp3CVUeORP8KMuA+FgX0prlUx/+FW6mC2Ya2qg0ZJZQ8SDTF4Ca/HnfOfU= 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 1663577775352556.7648754526934; Mon, 19 Sep 2022 01:56: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-30-b6WfPnlZNHW38HbdWC-tBw-1; Mon, 19 Sep 2022 04:55:45 -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 E2C26100DEA2; Mon, 19 Sep 2022 08:55:42 +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 CC709C15BA4; Mon, 19 Sep 2022 08:55:42 +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 BCF1B1946594; Mon, 19 Sep 2022 08:55:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6898F1946586 for ; Mon, 19 Sep 2022 08:55:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5C5BF40C6EC2; Mon, 19 Sep 2022 08:55:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB98B414A814 for ; Mon, 19 Sep 2022 08:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577773; 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=u0Iq7ddgvhb4w/nUX36hOP0VAtOHtn7u1FesBKFjCyY=; b=gV2iLODsSA1TeJFMywwWd2rwx2wZ+VeDCH//w4p2nRIFWHQi8GSVq/LUhoyp/AEj3J3ZqS 1jwH/BXyUT9uH3qUTcI/h3CylKsMYwabHWNDkQ5NT7esuCRyBBqu+2ZHWULnUjiJxM5AM+ etW2GUGh2m/+pZXNqTkS4dpiJmJThaY= X-MC-Unique: b6WfPnlZNHW38HbdWC-tBw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_INTERNAL Date: Mon, 19 Sep 2022 10:55:04 +0200 Message-Id: <04e57b1d0455579f0180f99356a7d1385a1370b5.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577775432100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cdf94ac75d..0c97be1766 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8999,7 +8999,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *localport =3D NULL; g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; - g_autofree char *internal =3D NULL; g_autofree char *mode =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; @@ -9076,9 +9075,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_INTERNAL: - if (source_node) { - internal =3D virXMLPropString(source_node, "name"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.internal.name =3D virXMLPropStringRequired(source_= node, "name"))) + return NULL; break; case VIR_DOMAIN_NET_TYPE_BRIDGE: @@ -9399,13 +9400,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_INTERNAL: - if (internal =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'name' attribute specified " - "with ")); - return NULL; - } - def->data.internal.name =3D g_steal_pointer(&internal); break; case VIR_DOMAIN_NET_TYPE_DIRECT: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577750; cv=none; d=zohomail.com; s=zohoarc; b=hoUdDWjFc8isrqzDOVQ5pJoGMKLxM0mG8oa6ySTtSNQl0i9yvP7Vt9VD8FalmAxX4DgwxGAycQS5gWymdIiqRRDbxATIkhy+0wmx4qz3wPwyOt++TO+uo/SiY6gyolxwN8Mlonpvzs3BAYPRG+yvzOyNuYBTE5PfnAHS77Plexg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577750; 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=2WvoOfH0qLoBLM1Zy6JnlQs6guM+3b9BKCIlkPGs0SY=; b=OBOrqeWJqYPOFomP+wwet4iTI+M5CFIql8rFPlz1tFGZrM8ShgAsvxO60EkL0Mawn8Y+Saxn64wzgcpIPGkialfwAawMo3mQ1RFOJMCvDwMspHRpUyU506ADqgd5kl7jS6htYW1aseiYwX+CZjCbKXqjG+yR4WhVXuvV968VE2s= 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 1663577750765215.88355288444257; Mon, 19 Sep 2022 01:55:50 -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-142-FWGYfY9MMVu6nNosRY1Agw-1; Mon, 19 Sep 2022 04:55:46 -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 90ADA2999B20; Mon, 19 Sep 2022 08:55: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 7E6101121314; Mon, 19 Sep 2022 08:55:44 +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 61B9D1946595; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 574B81946586 for ; Mon, 19 Sep 2022 08:55:42 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4C45C40C6EC3; Mon, 19 Sep 2022 08:55:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA71140C6EC2 for ; Mon, 19 Sep 2022 08:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577749; 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=2WvoOfH0qLoBLM1Zy6JnlQs6guM+3b9BKCIlkPGs0SY=; b=C4JoMq64CgpZtlbmedYF0nnFc3VG3EDVJBBBvVGesjxVsjd1s0VE30jMs2k7M+1cEJzIsK 2k1KCumGT2NwQSZV75u3JsT5/M7bCS2FeuM2TdWIluc7BooP/iikNkkqwZRM0zrYXxLEHb Qill68Ybl/Qg5vsih47Mm3JmHObl3aw= X-MC-Unique: FWGYfY9MMVu6nNosRY1Agw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_BRIDGE Date: Mon, 19 Sep 2022 10:55:05 +0200 Message-Id: <42373e9cffe3e2fd36ce03dbe65abd81409a3bb2.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577751144100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0c97be1766..431fd7a255 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8990,7 +8990,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virDomainChrSourceReconnectDef reconnect =3D {0}; int rv, val; g_autofree char *macaddr =3D NULL; - g_autofree char *bridge =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; g_autofree char *address =3D NULL; @@ -9083,9 +9082,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_BRIDGE: - if (source_node) { - bridge =3D virXMLPropString(source_node, "bridge"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.bridge.brname =3D virXMLPropStringRequired(source_= node, "bridge"))) + return NULL; break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -9334,13 +9335,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_BRIDGE: - if (bridge =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'bridge' attribute " - "specified with "= )); - return NULL; - } - def->data.bridge.brname =3D g_steal_pointer(&bridge); break; case VIR_DOMAIN_NET_TYPE_CLIENT: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577751; cv=none; d=zohomail.com; s=zohoarc; b=chC0tGipwv8UbEt61hMBi3xDoG9b8IK0+q9mVqcvEXWL+g6zg5piYybxVB5c5/7U1LAQ908kQ0lv5e8g/LHIS8kWQjnn4nP/zxhq6D4taRNXdVpWcpKdDVbv/QAddlrpqHWeKwZe93ocnoUENc3pGrc+7LUNHmFnLaP7zkBAnjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577751; 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=+PlrNl3owq9+AZ1RytMjRI6DNW78EPr687u6Z7FXiak=; b=JYj82yH5l4pj8jkyMdmWm0QnK4pm3+WPQSLVi26VyHap3sdlubHrSGpXPP0yxcgIGC3bWbbqp+hxMEijoyk0btVhkuuvdIc45ixMbiZ24JDjRoAPh6tlvyZVl8e+K5b/oiR70yWpPdTKLEpYgm7NNpPRUeA3SMlGJMkpoweL3O4= 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 1663577751503646.1573013779649; Mon, 19 Sep 2022 01:55:51 -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-397-q8rJQd_QMXGyiEOjmeA0_w-1; Mon, 19 Sep 2022 04:55:47 -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 4205A1C0CE77; Mon, 19 Sep 2022 08:55:45 +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 2AA8FC15BB9; Mon, 19 Sep 2022 08:55:45 +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 0C9E91946597; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64E3219465B3 for ; Mon, 19 Sep 2022 08:55:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 343C9414A809; Mon, 19 Sep 2022 08:55:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A437840C6EC3 for ; Mon, 19 Sep 2022 08:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577750; 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=+PlrNl3owq9+AZ1RytMjRI6DNW78EPr687u6Z7FXiak=; b=E3duO0H88jvvSp+LNNNmf3xREjrxT0U8V6SFP4dMn23pv1Q8k6YxP6CZ4vnaHJWbLzoFdm 5OLrzX5QhnDJYEaxCV/zSoaGNzhyU5k9SRJhlVw9aV5v9ja3z0AJC1ug0QPYr/1X+qbCJ+ bOSrZOlm5lfE31fQpgxrvsKK/oQBhq4= X-MC-Unique: q8rJQd_QMXGyiEOjmeA0_w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/37] conf: domain: Convert 'mode' field of the 'direct' type of virDomainNetDef to proper type Date: Mon, 19 Sep 2022 10:55:06 +0200 Message-Id: <4512ab645db155b215486aa9c288631e8e0df702.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577753119100003 Content-Type: text/plain; charset="utf-8" Use 'virNetDevMacVLanMode'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 3d13c7a3de..8fecf0566c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1130,7 +1130,7 @@ struct _virDomainNetDef { } internal; struct { char *linkdev; - int mode; /* enum virMacvtapMode from util/macvtap.h */ + virNetDevMacVLanMode mode; } direct; struct { virDomainHostdevDef def; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577753; cv=none; d=zohomail.com; s=zohoarc; b=Z9xvbFElCMScIh0frYPNFC329CU5Yi9nmquWmcO4eDxv5auwJkMwnfPyZbhRyoRD8bWBvaNNpLplpvw+YPkYxPIkZWou3mN03xbcnnR/KjY51nTVdpNKhf4NUbEjKqHf0vtv+8MdygB/gcYUMq3mF+JyrUs4A+7P5r5fnx6cy9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577753; 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=4ghmGmyp8rPAueQoxOyzKea45LoplBgrDWbdQdAzeCI=; b=eZ2P+PiCbN8lvmzb5JPSPwCj8vnKTE8JcyEShC+UzIncT71PQObIHX8+h6wJZgDUoMapnOW99lk0uvOqM1HGshpOdp1ldTIfuFzGej0xMEsZz/Naxz36ZLtlxvTjPvl0eCeIRdmoPwfHay9fg1a8qHhvDfyDeT+1D5aAYlzGF9g= 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 1663577753045728.5577104171045; Mon, 19 Sep 2022 01:55:53 -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-5-X4YtWhNZMjilVN_Qeiodpg-1; Mon, 19 Sep 2022 04:55:48 -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 1A42D3825780; Mon, 19 Sep 2022 08:55: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 D0B392086F60; Mon, 19 Sep 2022 08:55:45 +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 C1D351946595; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3202119465A4 for ; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2577640C6EC2; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 960C640C6EC3 for ; Mon, 19 Sep 2022 08:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577752; 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=4ghmGmyp8rPAueQoxOyzKea45LoplBgrDWbdQdAzeCI=; b=YoAwToECSFe6EjBsW1QQ4PUDf5TigIXPmUNucRSQJPt9cYGR3WA2Fqrj8fpgU6A2UPZ/3R FJ5KtpLOvPDLFOX3lSeIR7p2+SRw6AP07vIgV0LvsBDYe7l6N4fZsi0kVo1spDNm7cSsv4 Ye6ud0tgizC1bSUuJvS+wnWCa5Il2z4= X-MC-Unique: X4YtWhNZMjilVN_Qeiodpg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_DIRECT Date: Mon, 19 Sep 2022 10:55:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577753138100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 431fd7a255..77d3ef564e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8988,7 +8988,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) virDomainChrSourceReconnectDef reconnect =3D {0}; - int rv, val; + int rv; g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; @@ -8998,7 +8998,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *localport =3D NULL; g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; - g_autofree char *mode =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; g_autofree char *vhostuser_mode =3D NULL; @@ -9090,10 +9089,18 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_DIRECT: - if (source_node) { - dev =3D virXMLPropString(source_node, "dev"); - mode =3D virXMLPropString(source_node, "mode"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.direct.linkdev =3D virXMLPropStringRequired(source= _node, "dev"))) + return NULL; + + if (virXMLPropEnumDefault(source_node, "mode", + virNetDevMacVLanModeTypeFromString, + VIR_XML_PROP_NONE, + &def->data.direct.mode, + VIR_NETDEV_MACVLAN_MODE_VEPA) < 0) + return NULL; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: @@ -9394,28 +9401,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_INTERNAL: - break; - case VIR_DOMAIN_NET_TYPE_DIRECT: - if (dev =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'dev' attribute specified " - "with ")); - return NULL; - } - - if (mode !=3D NULL) { - if ((val =3D virNetDevMacVLanModeTypeFromString(mode)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Unknown mode has been specified")); - return NULL; - } - def->data.direct.mode =3D val; - } else { - def->data.direct.mode =3D VIR_NETDEV_MACVLAN_MODE_VEPA; - } - - def->data.direct.linkdev =3D g_steal_pointer(&dev); break; case VIR_DOMAIN_NET_TYPE_HOSTDEV: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577826; cv=none; d=zohomail.com; s=zohoarc; b=Ii0vyJLB1qJJVhL1FWlDp2zbSN8nfD1yqZniYx7u7OblJFv0TA4h+jxJ4apTWDwbr5B5ua2ieYUtHggjgZPpLY/g2WSpx2WTm1HT2shJSdWBA+yyMlPs8uEwXVR/J7KMEcxMYMn2Kc7S/q07cnZOqCwImhouN4t72pZuGJwPAyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577826; 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=i1W8uGO9yBpDd32RTHPNpO7CmrKpu+XS6OTnzwIH1vw=; b=iLFHAQctQH+WZIgf1y6BAvjpupYaE2d+5SssS9q/LUVa5IoOz9GrLI8B67nuV2LpEMTlN5/4rldUJzmmy4DYsXoPgONj04WF7lZ2yuF/5E4oIyJRI1GQhiLmX5owQWG75TjRg+ztoyMEiqIIJo7TUa7bFSY69IEp0vN7Th0Uhl4= 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 1663577826964866.4184529772549; Mon, 19 Sep 2022 01:57:06 -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-288-KpcMG4IoNHyx3kwg7GXDSw-1; Mon, 19 Sep 2022 04:55:48 -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 59A0829ABA0C; Mon, 19 Sep 2022 08:55: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 473F323177; Mon, 19 Sep 2022 08:55: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 3AA181946597; Mon, 19 Sep 2022 08:55:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 28BB119465A0 for ; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 12DA740C6EC4; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BF1B40C6EC2 for ; Mon, 19 Sep 2022 08:55:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577826; 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=i1W8uGO9yBpDd32RTHPNpO7CmrKpu+XS6OTnzwIH1vw=; b=HjeVkMgXbW8OunI1ibfAeplziQTIYIwQ1ffqVwMzoxTFNXqLnRulGrez9HjiSr5yXjE/ax rTHYXyrWONknD5VoTqqw7PqPuJVlREBMp0XKTGPggnDAa2nG/WZHVeg89JCfjxhz5lHarf lUOmIl5yKTUi81QrkDCjRNQMRuH8/mc= X-MC-Unique: KpcMG4IoNHyx3kwg7GXDSw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/37] virDomainNetDefParseXML: Extract network device model earlier Date: Mon, 19 Sep 2022 10:55:08 +0200 Message-Id: <360e2ff964c49b2c7c25510605b25e5d0eea5611.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577827755100008 Content-Type: text/plain; charset="utf-8" Move the code fetching the model of the net device before the main code parsing individual device types so that the data is available before the upcoming refactor. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 77d3ef564e..35843f6b72 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9019,6 +9019,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, &def->trustGuestRxFilters) < 0) return NULL; + if ((model =3D virXPathString("string(./model/@type)", ctxt)) && + virDomainNetSetModelString(def, model) < 0) + return NULL; + if ((source_node =3D virXPathNode("./source", ctxt))) { if (virDomainNetIPInfoParseXML(_("interface host IP"), source_node= , ctxt, &def->hostIP) < 0) return NULL; @@ -9202,7 +9206,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->script =3D virXPathString("string(./script/@path)", ctxt); def->downscript =3D virXPathString("string(./downscript/@path)", ctxt); def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); - model =3D virXPathString("string(./model/@type)", ctxt); if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { filter =3D virXMLPropString(filterref_node, "filter"); @@ -9258,10 +9261,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - if (model !=3D NULL && - virDomainNetSetModelString(def, model) < 0) - return NULL; - switch (def->type) { case VIR_DOMAIN_NET_TYPE_NETWORK: break; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577757; cv=none; d=zohomail.com; s=zohoarc; b=a42wwBNV6fTGD1EHXNy3WXxmuQzzKYxhtIL12ws6lXd+YaySNwly0fNJlYZ29SjTktuQOonuk2yBd6q4fyZvycxFslSiu3wwWrdHJPqSs3gchfVbAYChsrHTDpZ8pwBaxnBHyDk89YCkmRfiKSv9/3bFwAlrb6vuEM8MXAeyQXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577757; 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=iUBnV3As86BEAwbfYuvz6300JemED/HkZB5Oey6e3QM=; b=Pp0BZTftZAPRNHMYTjYM1iusAAV30wX5hLxOsiDvSF+IBgbQHH5oPpXetOxPqP1h8qlLIaYD28ZW2PJ+hr/vbjWV5Uii9TqaFDJj6bqpXufJbkjtJXI9A/2xBcrv8S7BssFmwln9uoQXdwBExWD/evPhgUPz6OaWdly01qY2LYE= 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 166357775758389.49511263231739; Mon, 19 Sep 2022 01:55:57 -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-73-NZfs3DMDOCaSLRWiqy8AJA-1; Mon, 19 Sep 2022 04:55:50 -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 A4CE7101245D; Mon, 19 Sep 2022 08:55: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 8F85A2086F61; Mon, 19 Sep 2022 08:55: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 7EF621946594; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0796619465B1 for ; Mon, 19 Sep 2022 08:55:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F11DA40C6EC4; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BC6E40C6EC3 for ; Mon, 19 Sep 2022 08:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577756; 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=iUBnV3As86BEAwbfYuvz6300JemED/HkZB5Oey6e3QM=; b=V+DVeWCdw1pDXp3pFB0i2rsTItNBbt0yo6PXvmE1y+wAsmrXXjpNcC8Wy4MZ+ZdImm4pzk Sr73PN52ph2jVpCq+9eW7Q1dVXr/iGQbAFTnNZLjfN6L23y+KyrTwW4/4Ga7qQsHvaenRa iOjPNZyjs+JZdZpSAwONBso6VgxLuKw= X-MC-Unique: NZfs3DMDOCaSLRWiqy8AJA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/37] conf: domain: Move 'virDomainChrSourceReconnectDefParseXML' Date: Mon, 19 Sep 2022 10:55:09 +0200 Message-Id: <3513bc43bb64a40bd47200eb0858823bdc249063.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577759140100003 Content-Type: text/plain; charset="utf-8" Move the function in place of its forward declaration. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 48 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 35843f6b72..dde34404f1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1481,7 +1481,27 @@ virDomainChrSourceDefFormat(virBuffer *buf, static int virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDef *def, xmlNodePtr node, - xmlXPathContextPtr ctxt); + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt) + xmlNodePtr cur; + + ctxt->node =3D node; + + if ((cur =3D virXPathNode("./reconnect", ctxt))) { + if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE, + &def->enabled) < 0) + return -1; + + if (def->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { + if (virXMLPropUInt(cur, "timeout", 10, VIR_XML_PROP_REQUIRED, + &def->timeout) < 0) + return -1; + } + } + + return 0; +} static int virDomainObjOnceInit(void) @@ -8777,32 +8797,6 @@ virDomainNetAppendIPAddress(virDomainNetDef *def, } -static int -virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDef *def, - xmlNodePtr node, - xmlXPathContextPtr ctxt) -{ - VIR_XPATH_NODE_AUTORESTORE(ctxt) - xmlNodePtr cur; - - ctxt->node =3D node; - - if ((cur =3D virXPathNode("./reconnect", ctxt))) { - if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE, - &def->enabled) < 0) - return -1; - - if (def->enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - if (virXMLPropUInt(cur, "timeout", 10, VIR_XML_PROP_REQUIRED, - &def->timeout) < 0) - return -1; - } - } - - return 0; -} - - static int virDomainNetTeamingInfoParseXML(xmlXPathContextPtr ctxt, virDomainNetTeamingInfo **teaming) --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577771; cv=none; d=zohomail.com; s=zohoarc; b=gAHztWfrMWjO7nSGH4NxcILE/WYUNC96AIcj2ysPYaXd7172amFhAWIcI4L4ADG+Mb0kN5W688Ods8heRvON1W7AFrHgYUpBFh2v1MTleJfvzdXNrrY0hXa47wm9kml3FZDcYbY76jEKBkLFPBsPMVgGdQApVPmf5af+iMXU5YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577771; 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=wEQw0Og1sMh9nrFqOQ5p05zfduuZ60dvprCMXSqyX/U=; b=QQ7O3iOqxVNi5GsYFG+bLncQlSCy7r79wfD3heqRYj7oNWVdL1KCv5zsc3h4HwGR/QIOD7Ulqk7gjh15dqwt7l3vDghfrt/ZXkdEJjyq5XsM2KX4kMspQKgt9onSWxHoG0EhF+Fq0nG1l/Ml2fOOXE/yBHGH93mJ+vpVzYfGYMs= 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 166357777111859.70030638823789; Mon, 19 Sep 2022 01:56:11 -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-553-WZm6fIVOPoeUZ-GMIF5LRA-1; Mon, 19 Sep 2022 04:55:51 -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 318AA81173A; Mon, 19 Sep 2022 08:55:48 +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 18CAC492B05; Mon, 19 Sep 2022 08:55:48 +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 0EEEA1946597; Mon, 19 Sep 2022 08:55:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0F5601946586 for ; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E9A2740C6EC4; Mon, 19 Sep 2022 08:55:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58D7640C6EC2 for ; Mon, 19 Sep 2022 08:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577770; 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=wEQw0Og1sMh9nrFqOQ5p05zfduuZ60dvprCMXSqyX/U=; b=bsqeR1fSMejjkHpE4kHMTDihvObau//fqT4qaZpzEw8H/DhPLSnt7EaQPddy0T+mjEZI/T jVkc951dTUa1KsA3ojIs+9QOJ3xYK6M7H6/zRuOeytyiomb2BsqyWDmXhcGzlbMjZm46ip 80M+jNJ6ok5pyrLvndu5stxD75O97T4= X-MC-Unique: WZm6fIVOPoeUZ-GMIF5LRA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VHOSTUSER Date: Mon, 19 Sep 2022 10:55:10 +0200 Message-Id: <74c8a5eb93c8974a753b11cfca13afcda5929be8.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577771506100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 130 +++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index dde34404f1..b41e1644a5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8964,6 +8964,23 @@ virDomainNetDefParseXMLRequireSource(virDomainNetDef= *def, } +typedef enum { + VIR_DOMAIN_NET_VHOSTUSER_MODE_NONE, + VIR_DOMAIN_NET_VHOSTUSER_MODE_CLIENT, + VIR_DOMAIN_NET_VHOSTUSER_MODE_SERVER, + + VIR_DOMAIN_NET_VHOSTUSER_MODE_LAST +} virDomainNetVhostuserMode; + +VIR_ENUM_DECL(virDomainNetVhostuserMode); +VIR_ENUM_IMPL(virDomainNetVhostuserMode, + VIR_DOMAIN_NET_VHOSTUSER_MODE_LAST, + "", + "client", + "server", +); + + static virDomainNetDef * virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr node, @@ -8981,7 +8998,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr mac_node =3D NULL; g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) - virDomainChrSourceReconnectDef reconnect =3D {0}; int rv; g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; @@ -8994,9 +9010,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *addrtype =3D NULL; - g_autofree char *vhostuser_mode =3D NULL; - g_autofree char *vhostuser_path =3D NULL; - g_autofree char *vhostuser_type =3D NULL; g_autofree char *tap =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; @@ -9123,14 +9136,55 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } break; - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (source_node) { - vhostuser_type =3D virXMLPropString(source_node, "type"); - vhostuser_path =3D virXMLPropString(source_node, "path"); - vhostuser_mode =3D virXMLPropString(source_node, "mode"); - if (virDomainChrSourceReconnectDefParseXML(&reconnect, source_= node, ctxt) < 0) - return NULL; + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: { + g_autofree char *vhostuser_type =3D NULL; + virDomainNetVhostuserMode vhostuser_mode; + + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(vhostuser_type =3D virXMLPropStringRequired(source_node, "ty= pe"))) + return NULL; + + if (STRNEQ_NULLABLE(vhostuser_type, "unix")) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Type=3D'%s' unsupported for "), + vhostuser_type); + return NULL; + } + + if (!(def->data.vhostuser =3D virDomainChrSourceDefNew(xmlopt))) + return NULL; + + def->data.vhostuser->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + + if (!(def->data.vhostuser->data.nix.path =3D virXMLPropStringRequi= red(source_node, "path"))) + return NULL; + + if (virXMLPropEnum(source_node, "mode", + virDomainNetVhostuserModeTypeFromString, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &vhostuser_mode) < 0) + return NULL; + + switch (vhostuser_mode) { + case VIR_DOMAIN_NET_VHOSTUSER_MODE_CLIENT: + def->data.vhostuser->data.nix.listen =3D false; + break; + + case VIR_DOMAIN_NET_VHOSTUSER_MODE_SERVER: + def->data.vhostuser->data.nix.listen =3D true; + break; + + case VIR_DOMAIN_NET_VHOSTUSER_MODE_NONE: + case VIR_DOMAIN_NET_VHOSTUSER_MODE_LAST: + break; } + + if (virDomainChrSourceReconnectDefParseXML(&def->data.vhostuser->d= ata.nix.reconnect, + source_node, ctxt) < 0) + return NULL; + } break; case VIR_DOMAIN_NET_TYPE_VDPA: @@ -9268,58 +9322,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - if (STRNEQ_NULLABLE(vhostuser_type, "unix")) { - if (vhostuser_type) - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Type=3D'%s' unsupported for" - " "), - vhostuser_type); - else - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("No 'type' attribute " - "specified for ")); - return NULL; - } - - if (vhostuser_path =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'path' attribute " - "specified with ")); - return NULL; - } - - if (vhostuser_mode =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'mode' attribute " - "specified with ")); - return NULL; - } - - if (!(def->data.vhostuser =3D virDomainChrSourceDefNew(xmlopt))) - return NULL; - - def->data.vhostuser->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - def->data.vhostuser->data.nix.path =3D g_steal_pointer(&vhostuser_= path); - - if (STREQ(vhostuser_mode, "server")) { - def->data.vhostuser->data.nix.listen =3D true; - if (reconnect.enabled =3D=3D VIR_TRISTATE_BOOL_YES) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'reconnect' attribute unsupported " - "'server' mode for ")); - return NULL; - } - } else if (STREQ(vhostuser_mode, "client")) { - def->data.vhostuser->data.nix.listen =3D false; - def->data.vhostuser->data.nix.reconnect =3D reconnect; - } else { + if (def->data.vhostuser->data.nix.listen && + def->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Wrong 'mode' attribute " - "specified with ")); + _("'reconnect' attribute unsupported 'server' m= ode for ")); return NULL; } break; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577756; cv=none; d=zohomail.com; s=zohoarc; b=Ymr163ET6bywcPdOsSwnKwpEEQLM9So7TdxIBQzxs3cCaix9I1d9Z9DkLBO3U0jSBPRXcBkj++Y8EnvgzwnRyHUYO1CtWCgrrZcMb5Z2wRgy1dnJUAucVg02pBteSI83VgTGajymdCcy419/Tt27B5a5xBqpK1lyMz3rFZx8z6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577756; 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=SYlntpndpODA08QKg5B/gkI6pmBwtZzmdSWCoN0hC8I=; b=kJOYkBiJaBChWSkRhyGUJUmlwm5vY31GWQe8ccumL5ddANsmp+YWn6LeYUC88xBCyCWMjBT4a1iZi7vKn3OyJ9dJsYm6H1Bo3Wmt20cWbBe/x5SXu9m2ZXOjHkzvQx0wqc+eB5OyLLBnKlnXF956djY8l6oiaXfLCTNMj6vKrxs= 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 1663577756876348.31186407630287; Mon, 19 Sep 2022 01:55:56 -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-529-Idb7wLAUOmupeOKellQGAA-1; Mon, 19 Sep 2022 04:55:52 -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 2908129ABA05; Mon, 19 Sep 2022 08:55: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 D70874A9254; Mon, 19 Sep 2022 08:55:49 +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 C14321946595; Mon, 19 Sep 2022 08:55:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DE53E19465A4 for ; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CED8140C6EC3; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FC4440C6EC2 for ; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577755; 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=SYlntpndpODA08QKg5B/gkI6pmBwtZzmdSWCoN0hC8I=; b=QySzIYdP1VGR3qpwNKrkGXzMiA9Nebt/s+ff2VaaO6f4oilP7xSyyaDDL85E63bLl7LwZG 4JGclhgO0DDHZrbnqFpEhPcIwUrwz/lwMYEJVGVuj4k95JDtZKSxeCmIIAAuEpMZ1Wleaz ZVJEkoa6ZkLHXTy6ZVyhXW/M0UraSmM= X-MC-Unique: Idb7wLAUOmupeOKellQGAA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_VDPA Date: Mon, 19 Sep 2022 10:55:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577757140100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b41e1644a5..c14f3f2910 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9188,9 +9188,11 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDPA: - if (source_node) { - dev =3D virXMLPropString(source_node, "dev"); - } + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (!(def->data.vdpa.devicepath =3D virXMLPropStringRequired(sourc= e_node, "dev"))) + return NULL; break; case VIR_DOMAIN_NET_TYPE_CLIENT: @@ -9331,15 +9333,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_VDPA: - if (dev =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'dev' attribute " - "specified with ")); - return NULL; - } - def->data.vdpa.devicepath =3D g_steal_pointer(&dev); - break; - case VIR_DOMAIN_NET_TYPE_BRIDGE: break; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577825; cv=none; d=zohomail.com; s=zohoarc; b=ZC8us/Dj9rh6wrlXNbzUivp0G8BRF7roJ8lxZ8lL3EDzs3xhsje8Fqj1bv7SkM6Gwyu6Q/puFPMHNWIDrTzzww+OcY8vGyVDKTqKkBIbvlQDD7rQoEHJPmhOwEc3yRJCOviuFJrg0vYeBO6hYKfgiOktk/2+e0Uhxt9WOkQMhN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577825; 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=BEPRM16Rqtkrrm9yF3bgqBP9K37lfZEkSw/fJtnafts=; b=Wf31kIEYW9KkIChM+/DVrIGEMwXnqX/IGKr0xS2MOff93QTWwTLhhW3nlGRixYdyG5rCSLOaCK3cOxHkVO7mTwg0VvJL//K3Gjq75xzH1+zlZt8JdGIn9NKKo0jbK081Dl20wSwFCEHFwUw6Z8ePTr/M9IP8AIcrzR65FyPRajI= 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 166357782556634.793993756387295; Mon, 19 Sep 2022 01:57: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-589-1PuIUbMzM4-w61n4raUNiA-1; Mon, 19 Sep 2022 04:55:52 -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 82BF6857D13; Mon, 19 Sep 2022 08:55: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 5993D18ECC; Mon, 19 Sep 2022 08:55: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 263891946A41; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C7A211946586 for ; Mon, 19 Sep 2022 08:55:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BD91C40C6EC2; Mon, 19 Sep 2022 08:55:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D39140C6EC3 for ; Mon, 19 Sep 2022 08:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577824; 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=BEPRM16Rqtkrrm9yF3bgqBP9K37lfZEkSw/fJtnafts=; b=RAA0FfdzqYuSM2FR1GeH7oPEGov24FGdcEitWxXpj/Tn9V28Ainl7XJByzkL4jJ80zidAC 6u3XvbHVkmyFek6X1kE5eAyzoHC4Qi3Jwvh+iqgDxEszL5uEN/5PMcL71TOF9MuY+ix49z MRTBp6if2bjSX/XvhybmyyikW1/sEF4= X-MC-Unique: 1PuIUbMzM4-w61n4raUNiA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/37] util: xml: Introduce VIR_XPATH_NODE_AUTORESTORE_NAME Date: Mon, 19 Sep 2022 10:55:12 +0200 Message-Id: <25d43d102413f393b68ed0e876f1aba3f661ed1e.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577825774100002 Content-Type: text/plain; charset="utf-8" VIR_XPATH_NODE_AUTORESTORE_NAME is a more generic version of the VIR_XPATH_NODE_AUTORESTORE macro used to save the 'node' inside a XPath context struct. The new macro allows specifying the name of the variable used to save the context so that it can be used multiple times inside a function's nested scopes. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virxml.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/util/virxml.h b/src/util/virxml.h index 3b00d20ea9..09a8d89f1e 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -379,6 +379,20 @@ virXPathContextNodeRestore(virXPathContextNodeSave *sa= ve); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSave, virXPathContextN= odeRestore); +/** + * VIR_XPATH_NODE_AUTORESTORE_NAME: + * @name: name of the temporary variable used to save @ctxt + * @ctxt: XML XPath context pointer + * + * This macro ensures that when the scope where it's used ends, @ctxt's cu= rrent + * node pointer is reset to the original value when this macro was used. T= he + * context is saved into a variable named @name; + */ +#define VIR_XPATH_NODE_AUTORESTORE_NAME(_name, _ctxt) \ + VIR_WARNINGS_NO_UNUSED_VARIABLE \ + g_auto(virXPathContextNodeSave) _name =3D { .ctxt =3D _ctxt,\ + .node =3D _ctxt->node}; \ + VIR_WARNINGS_RESET /** * VIR_XPATH_NODE_AUTORESTORE: * @ctxt: XML XPath context pointer @@ -387,10 +401,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSa= ve, virXPathContextNodeRes * node pointer is reset to the original value when this macro was used. */ #define VIR_XPATH_NODE_AUTORESTORE(_ctxt) \ - VIR_WARNINGS_NO_UNUSED_VARIABLE \ - g_auto(virXPathContextNodeSave) _ctxt ## CtxtSave =3D { .ctxt =3D _ctx= t,\ - .node =3D _ctxt-= >node}; \ - VIR_WARNINGS_RESET + VIR_XPATH_NODE_AUTORESTORE_NAME(_ctxt ## CtxtSave, _ctxt) G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext); --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577789; cv=none; d=zohomail.com; s=zohoarc; b=It1X69VQRhWPzfe+0SSR1p7E0/awflxrK7arnOfJSJ/JOpKOAreAnAzOP0zyR8S+zyCJw6Ww5kKSjavJryeTKXsbdK20E0lRYO+PRyypxYNrooCRUuRR4bcA1qaeTxFdTXjDEE6QtWFSDLgQWz3zgOtcpnhDwjvKHa8usRL5VCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577789; 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=2qUBpsCRp3FeI6IwdiZS/7iP2wRjcdcR42t4RjkgXmM=; b=ML6jGZ++N7kYJrVwCn2D14YwNqBoGv33Zu+2CuHYEAUeI4jKqw1p8wkT4OyPHm2GH3+C73QgPp6dBw416quI4pTYya3Gkf/j95HHH58t60RBMLNoYhRwFivN4R+Orfuh00vl/Icm+S0BoBmqy3SHC6rAP3ec3j10dSuPnokIFOk= 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 1663577789293796.3624048817493; Mon, 19 Sep 2022 01:56: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-583-LGhA5eJUOUuHF8aCjomA-A-1; Mon, 19 Sep 2022 04:55:53 -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 0A234882822; Mon, 19 Sep 2022 08:55: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 AB2F940C6EC5; Mon, 19 Sep 2022 08:55: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 9EFDE19465A3; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B11951946586 for ; Mon, 19 Sep 2022 08:55:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A563640C6EC3; Mon, 19 Sep 2022 08:55:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2533340C6EC2 for ; Mon, 19 Sep 2022 08:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577788; 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=2qUBpsCRp3FeI6IwdiZS/7iP2wRjcdcR42t4RjkgXmM=; b=ehyV6m4DjAEQ6kaZ5/FemG/No8/azjglUfWORohtwtlGbf1Z+aYM7PAxJsM37sPfkltlvk ElN4pEkGAnhx++pK+BD3B0wTVDnzUkxGu4xYgF1fMVh/FMVqSV50MjdZ1NQXwz0wNVF0D6 f0pOD+jM+UYssWq0f90jdb3sMjUIhzk= X-MC-Unique: LGhA5eJUOUuHF8aCjomA-A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_UDP/MCAST/SERVER/CLIENT Date: Mon, 19 Sep 2022 10:55:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577789674100001 Content-Type: text/plain; charset="utf-8" This also removes the confusing use of variables named 'tmpNode' and 'tmp_node' right next to each other. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 101 +++++++++++++---------------------------- 1 file changed, 31 insertions(+), 70 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c14f3f2910..cc28bc9684 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8994,7 +8994,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr filterref_node =3D NULL; xmlNodePtr vlan_node =3D NULL; xmlNodePtr bandwidth_node =3D NULL; - xmlNodePtr tmpNode; xmlNodePtr mac_node =3D NULL; g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) @@ -9002,10 +9001,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *managed_tap =3D NULL; - g_autofree char *address =3D NULL; - g_autofree char *port =3D NULL; - g_autofree char *localaddr =3D NULL; - g_autofree char *localport =3D NULL; g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; @@ -9199,18 +9194,38 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_MCAST: case VIR_DOMAIN_NET_TYPE_UDP: - if (source_node) { - address =3D virXMLPropString(source_node, "address"); - port =3D virXMLPropString(source_node, "port"); - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { - xmlNodePtr tmp_node =3D ctxt->node; - ctxt->node =3D source_node; - if ((tmpNode =3D virXPathNode("./local", ctxt))) { - localaddr =3D virXMLPropString(tmpNode, "address"); - localport =3D virXMLPropString(tmpNode, "port"); - } - ctxt->node =3D tmp_node; + if (virDomainNetDefParseXMLRequireSource(def, source_node) < 0) + return NULL; + + if (def->type !=3D VIR_DOMAIN_NET_TYPE_SERVER) { + if (!(def->data.socket.address =3D virXMLPropStringRequired(so= urce_node, "address"))) + return NULL; + } else { + def->data.socket.address =3D virXMLPropString(source_node, "ad= dress"); + } + + if (virXMLPropInt(source_node, "port", 10, VIR_XML_PROP_REQUIRED, + &def->data.socket.port, def->data.socket.port) <= 0) + return NULL; + + if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { + VIR_XPATH_NODE_AUTORESTORE_NAME(localCtxt, ctxt) + xmlNodePtr local_node; + + ctxt->node =3D source_node; + + if (!(local_node =3D virXPathNode("./local", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'' element missing for 'udp' sock= et interface")); + return NULL; } + + if (!(def->data.socket.localaddr =3D virXMLPropStringRequired(= local_node, "address"))) + return NULL; + + if (virXMLPropInt(local_node, "port", 10, VIR_XML_PROP_REQUIRE= D, + &def->data.socket.localport, def->data.socke= t.localport) < 0) + return NULL; } break; @@ -9334,64 +9349,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, case VIR_DOMAIN_NET_TYPE_VDPA: case VIR_DOMAIN_NET_TYPE_BRIDGE: - break; - case VIR_DOMAIN_NET_TYPE_CLIENT: case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_MCAST: case VIR_DOMAIN_NET_TYPE_UDP: - if (port =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'port' attribute " - "specified with socket interface")); - return NULL; - } - if (virStrToLong_i(port, NULL, 10, &def->data.socket.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse 'port' attribute " - "with socket interface")); - return NULL; - } - - if (address =3D=3D NULL) { - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_CLIENT || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_MCAST || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_UDP) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'address' attribute " - "specified with socket interface")); - return NULL; - } - } else { - def->data.socket.address =3D g_steal_pointer(&address); - } - - if (def->type !=3D VIR_DOMAIN_NET_TYPE_UDP) - break; - - if (localport =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'port' attribute " - "specified with socket interface")); - return NULL; - } - if (virStrToLong_i(localport, NULL, 10, &def->data.socket.localpor= t) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot parse 'port' attribute " - "with socket interface")); - return NULL; - } - - if (localaddr =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("No 'address' attribute " - "specified with socket interface")); - return NULL; - } else { - def->data.socket.localaddr =3D g_steal_pointer(&localaddr); - } - break; - case VIR_DOMAIN_NET_TYPE_INTERNAL: case VIR_DOMAIN_NET_TYPE_DIRECT: break; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577825; cv=none; d=zohomail.com; s=zohoarc; b=bGbVTAcb9/cAYa9YF/GA2rmyULt67z8oQbo6gHF8O2vQJ9H8WawzxtT32zzb3dBWQEmMxs7QwvZtHNU2xqqVb3z4GiXgsw+QlkKdiIqwjcSjDBEGjVGKARSBqgNe0P4pFEmiFYVmURWsYXlufhiVPSjZctGRatvsc9Ps+ioEX6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577825; 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=cBQsDtzN0v/8pCyU7OgUPp8GQ+i+JmZ6n1JJoYX5aSA=; b=VQAjHRakb6XymPtY7YJtlPw7EQgjNl1KItdE1p076x23dsysxsBde6eqIucauSedrJ7ptTOFearusUPt+yH0wmImRbiyQSvR2dgM8OWlpjbBR1xT0fpdlXl0TO+0/+tQixyH4LuQ9xqKG8uxdOWQ4C3mrcWw7ftxWJ9QiyR3Itc= 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 1663577825441657.8663134072642; Mon, 19 Sep 2022 01:57:05 -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-653-vomZcZxkMq6FzYxexOXH1A-1; Mon, 19 Sep 2022 04:55:55 -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 270653C10680; Mon, 19 Sep 2022 08:55:52 +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 108F940C6EC3; Mon, 19 Sep 2022 08:55:52 +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 003E41946594; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A226B19465A4 for ; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 94BF140C6EC4; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09D8E40C6EC2 for ; Mon, 19 Sep 2022 08:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577824; 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=cBQsDtzN0v/8pCyU7OgUPp8GQ+i+JmZ6n1JJoYX5aSA=; b=YxTtZo104fzwcwCc/CaPTywN3XgJd7C+GeoJNQOx3hQwCZJYUlFGCWLgg7lFWpoftC6Y63 QNXKUAdmwomFalJUQznaT5t/t8rdRox7Xkh6np2kfeFMJwmENHgiEUFSS8vZskCNEYiOk0 6zH900EwR8UiwiCtQazoByuJ7t5lj8U= X-MC-Unique: vomZcZxkMq6FzYxexOXH1A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/37] virDomainNetDefParseXML: Refactor parsing of data for VIR_DOMAIN_NET_TYPE_HOSTDEV Date: Mon, 19 Sep 2022 10:55:14 +0200 Message-Id: <14519371691b40a4901ae4e9fdbfdf682ba74c1a.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577825775100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 44 ++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cc28bc9684..3850684707 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8988,7 +8988,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, unsigned int flags) { g_autoptr(virDomainNetDef) def =3D NULL; - virDomainHostdevDef *hostdev; xmlNodePtr source_node =3D NULL; xmlNodePtr virtualport_node =3D NULL; xmlNodePtr filterref_node =3D NULL; @@ -9004,7 +9003,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; - g_autofree char *addrtype =3D NULL; g_autofree char *tap =3D NULL; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; @@ -9229,7 +9227,27 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } break; - case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: { + g_autofree char *addrtype =3D virXPathString("string(./source/addr= ess/@type)", ctxt); + + def->data.hostdev.def.parentnet =3D def; + def->data.hostdev.def.info =3D &def->info; + def->data.hostdev.def.mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; + + /* if not explicitly stated, source/vendor implies usb device */ + if (!addrtype && virXPathNode("./source/vendor", ctxt)) + addrtype =3D g_strdup("usb"); + + /* The helper function expects type to already be found and + * passed in as a string, since it is in a different place in + * NetDef vs HostdevDef. */ + if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, + &def->data.hostdev.def, + flags, xmlopt) < 0) + return NULL; + } + break; + case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_NULL: case VIR_DOMAIN_NET_TYPE_LAST: @@ -9355,27 +9373,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, case VIR_DOMAIN_NET_TYPE_UDP: case VIR_DOMAIN_NET_TYPE_INTERNAL: case VIR_DOMAIN_NET_TYPE_DIRECT: - break; - case VIR_DOMAIN_NET_TYPE_HOSTDEV: - hostdev =3D &def->data.hostdev.def; - hostdev->parentnet =3D def; - hostdev->info =3D &def->info; - /* The helper function expects type to already be found and - * passed in as a string, since it is in a different place in - * NetDef vs HostdevDef. - */ - addrtype =3D virXPathString("string(./source/address/@type)", ctxt= ); - /* if not explicitly stated, source/vendor implies usb device */ - if (!addrtype && virXPathNode("./source/vendor", ctxt)) - addrtype =3D g_strdup("usb"); - hostdev->mode =3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, - hostdev, flags, xmlopt) < 0)= { - return NULL; - } - break; - case VIR_DOMAIN_NET_TYPE_VDS: case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_USER: --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577826; cv=none; d=zohomail.com; s=zohoarc; b=awN1aeSW2zhjE9Pc37r8J/YERqWemXgDuNfimgZKMFyJYsHfIfczLVwyqx9R+xTX/bPzAE9Q/AVWG3/96D49n2nz7KY0O1FEonwKhZKZLG0i+o7BhBco+2bUKnU7gH79U9wxMBxtpXB3QoS2mdFiRl/HeHI0jX1ROypmfrc1qSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577826; 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=/n7Rdj8v+hi8QQGVZwQ5cMtNFCBWbEfkG9Ggn01BOTk=; b=neRB50M0hq/HrlF5lAFV+YFaOqNAcVUmi/DEDWsGshyKehdk9wkB8ETZarbCeZKqcYOXit1ZCzaKE56hgSJNadnB/QYDIM6pL2p/EIQTsOITIcS0nOrU3KG993a8SUXW0U240zN92pfNu0Vd8aELSrkplAfKWbtcXRysa2sTiSs= 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 1663577826537751.916822500287; Mon, 19 Sep 2022 01:57:06 -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-kGa-J_H8OWCGbO6-uAb4xQ-1; Mon, 19 Sep 2022 04:55:55 -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 9DFFE882838; Mon, 19 Sep 2022 08:55:52 +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 7C90B140EBF3; Mon, 19 Sep 2022 08:55:52 +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 4316419465B6; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 879A51946586 for ; Mon, 19 Sep 2022 08:55:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7CEC940C6EC2; Mon, 19 Sep 2022 08:55:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED34940C6EC4 for ; Mon, 19 Sep 2022 08:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577825; 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=/n7Rdj8v+hi8QQGVZwQ5cMtNFCBWbEfkG9Ggn01BOTk=; b=CsBwQcP2RwjIOcY9mXFeNGg6xnitbRUrbmJEIktPMUs6C6Eu9eOHTltEYlMi7km+x3dBjr bH+osC7OwSAfszgUauKkjwuBKuTmC1Seh6XV/m+Pj7dsASZx03tB5Bk8OYoleN0PNEKfKK T8GRg3TdgZvDVbFDmTxxevbjoGEktzo= X-MC-Unique: kGa-J_H8OWCGbO6-uAb4xQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/37] conf: domain: Move prue validation code from virDomainNetDefParseXML to virDomainNetDefValidate Date: Mon, 19 Sep 2022 10:55:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577827745100007 Content-Type: text/plain; charset="utf-8" The moved code is pure validation of semantics of the definition and not actual parsed values. Move it to the validation code. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 38 -------------------------------------- src/conf/domain_validate.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3850684707..648ce18a3f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9344,44 +9344,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - switch (def->type) { - case VIR_DOMAIN_NET_TYPE_NETWORK: - break; - - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - if (!virDomainNetIsVirtioModel(def)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Wrong or no 'type' attribute " - "specified with . " - "vhostuser requires the virtio-net* frontend"= )); - return NULL; - } - - if (def->data.vhostuser->data.nix.listen && - def->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'reconnect' attribute unsupported 'server' m= ode for ")); - return NULL; - } - break; - - case VIR_DOMAIN_NET_TYPE_VDPA: - case VIR_DOMAIN_NET_TYPE_BRIDGE: - case VIR_DOMAIN_NET_TYPE_CLIENT: - case VIR_DOMAIN_NET_TYPE_SERVER: - case VIR_DOMAIN_NET_TYPE_MCAST: - case VIR_DOMAIN_NET_TYPE_UDP: - case VIR_DOMAIN_NET_TYPE_INTERNAL: - case VIR_DOMAIN_NET_TYPE_DIRECT: - case VIR_DOMAIN_NET_TYPE_HOSTDEV: - case VIR_DOMAIN_NET_TYPE_VDS: - case VIR_DOMAIN_NET_TYPE_ETHERNET: - case VIR_DOMAIN_NET_TYPE_USER: - case VIR_DOMAIN_NET_TYPE_NULL: - case VIR_DOMAIN_NET_TYPE_LAST: - break; - } - if (virDomainNetIPInfoParseXML(_("guest interface"), node, ctxt, &def->guestIP) < 0) return NULL; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 6ecf6d1c11..81f6d5dbd5 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2134,6 +2134,40 @@ virDomainNetDefValidate(const virDomainNetDef *net) return -1; } + switch (net->type) { + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + if (!virDomainNetIsVirtioModel(net)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Wrong or no 'type' attribute specifi= ed with . vhostuser requires the virtio-net*= frontend")); + return -1; + } + + if (net->data.vhostuser->data.nix.listen && + net->data.vhostuser->data.nix.reconnect.enabled =3D=3D VIR_TRI= STATE_BOOL_YES) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'reconnect' attribute unsupported 'server' m= ode for ")); + return -1; + } + break; + + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_BRIDGE: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_VDS: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_NULL: + case VIR_DOMAIN_NET_TYPE_LAST: + break; + } + return 0; } --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577834; cv=none; d=zohomail.com; s=zohoarc; b=bPNq9sKAeaYHVG8EMqNvb+26CAWbezRMzi9oe27TixIGC6cD6571tSY/Dqhcry8frHk8F3kwNOKwpb35KtNy9lrA8dwpa5XclVI4WvbqKRuNLOZMd+r3E9LnbOKSD62aeWz4vePSk/FyM3KLqEUx069WlIyEHxrmZGzw9enedwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577834; 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=VcF5iXh+bqOSzim0Br63mCz+dLpc/qo5QZ0FQTLDDzs=; b=UHOeF7A/2wYpkd3rHsNRivNsGDFPgzm5sxpSXgcm4iJwpr1fc16JwukBTdYmRZ0gXXsE8povSCzGYvxEXjLYMgDi87VepjNnCGq2N6ZI1qR0miBxSbg/+k8jFt9C8LlAC7EO5PHH03kAshCFGpntXVskrP8QJOGVJSvG+4h/3/0= 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 1663577834358722.3230197617352; Mon, 19 Sep 2022 01:57:14 -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-659-7HfhJls4P4CFelekQxFqVg-1; Mon, 19 Sep 2022 04:55:56 -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 BAB37185A7AC; Mon, 19 Sep 2022 08:55: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 A514740C2064; Mon, 19 Sep 2022 08:55: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 5FEBD1946594; Mon, 19 Sep 2022 08:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AB9441946594 for ; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9D83740C6EC4; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5A5540C6EC2 for ; Mon, 19 Sep 2022 08:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577833; 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=VcF5iXh+bqOSzim0Br63mCz+dLpc/qo5QZ0FQTLDDzs=; b=WPbglROmTOewgjQSFfWKedKISmBgJbg1JQvWojwiTDZrhpKqGyZ2ZC2jaqCtOnsT6XVS2f lWsOjyjTDc8fpld5Wv7lV+s6bb76TmKD2F0+zVdggbjikd+P0txqJvbWxB12g1bF84yEe0 gmNDQnzvuJUa076qTmWyjo2gUPkW2gg= X-MC-Unique: 7HfhJls4P4CFelekQxFqVg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/37] virDomainNetDefParseXML: Refactor parsing of Date: Mon, 19 Sep 2022 10:55:16 +0200 Message-Id: <057857af1a35430bda62962722c94f46df41e901.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577835782100005 Content-Type: text/plain; charset="utf-8" Base whether virtualport is supported for a given interface on a new variable named 'virtualport_flags' which also configures the parser for the virtualports subelement and fill it in the appropriate interface type branches. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 648ce18a3f..bee415b9d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9004,6 +9004,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *tap =3D NULL; + unsigned int virtualport_flags =3D 0; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def =3D virDomainNetDefNew(xmlopt))) @@ -9053,6 +9054,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, flags, xmlopt) < 0)) return NULL; } + + virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS; break; case VIR_DOMAIN_NET_TYPE_VDS: @@ -9090,6 +9093,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if (!(def->data.bridge.brname =3D virXMLPropStringRequired(source_= node, "bridge"))) return NULL; + + virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS | + VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | + VIR_VPORT_XML_REQUIRE_TYPE; break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -9105,6 +9112,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, &def->data.direct.mode, VIR_NETDEV_MACVLAN_MODE_VEPA) < 0) return NULL; + + virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS | + VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | + VIR_VPORT_XML_REQUIRE_TYPE; break; case VIR_DOMAIN_NET_TYPE_ETHERNET: @@ -9245,6 +9256,10 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, &def->data.hostdev.def, flags, xmlopt) < 0) return NULL; + + virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS | + VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | + VIR_VPORT_XML_REQUIRE_TYPE; } break; @@ -9255,28 +9270,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } if ((virtualport_node =3D virXPathNode("./virtualport", ctxt))) { - if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (!(def->virtPortProfile - =3D virNetDevVPortProfileParse(virtualport_node, - VIR_VPORT_XML_GENERATE_MISS= ING_DEFAULTS))) { - return NULL; - } - } else if (def->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_DIRECT || - def->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) { - if (!(def->virtPortProfile - =3D virNetDevVPortProfileParse(virtualport_node, VIR_VPO= RT_XML_GENERATE_MISSING_DEFAULTS| - VIR_VPORT_XML_REQUIRE_ALL_A= TTRIBUTES| - VIR_VPORT_XML_REQUIRE_TYPE)= )) { - return NULL; - } - } else { + if (virtualport_flags =3D=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _(" element unsupported for" - " "), - virDomainNetTypeToString(def->type)); + _(" element unsupported for "), + virDomainNetTypeToString(def->type)); return NULL; } + + if (!(def->virtPortProfile =3D virNetDevVPortProfileParse(virtualp= ort_node, + virtualpor= t_flags))) + return NULL; } def->ifname =3D virXPathString("string(./target/@dev)", ctxt); --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577889; cv=none; d=zohomail.com; s=zohoarc; b=IpQYFVCQFxzBJ8e8RQgaUfNYaHBnnCbfVvY6brfEwa+0wLDNl6Kxo4xDrEbZthtgP4dajw7VY3TcrUw5cvkfGuuCBdEVJWXpNi1dHYE8wGxfXAq+C77BDufcFl/rEw1fZcCrPnHgWESGdxX8HFU485yfB84taq/Vhw8EQdEMJio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577889; 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=xvPVPUXXj0ySYo90JhebKEnFrYFlofvscM/grnWsmdI=; b=MlDrJW6HQXKZmGQ6rkdLRPx4fpFEcmVPwjjgvBLmeTXoaut1nBrT0nSifoxO0ALM4YeD6ZuFvV7nY28Md5of2T/I2OdAruyAmV31Je6AZ02fdIWPVuHiW2dn9+sc2LfMvxBFdNjiBYR5cJUNHsrhhMmYb7JUYgnL7S4MfPSLBGI= 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 1663577889615567.2140667582352; Mon, 19 Sep 2022 01:58:09 -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-609-e40gjJKEMRGbGZWgSxp-Qw-1; Mon, 19 Sep 2022 04:55:57 -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 C8DB029ABA0B; Mon, 19 Sep 2022 08:55: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 B560F40C6EC2; Mon, 19 Sep 2022 08:55: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 AB43B1946595; Mon, 19 Sep 2022 08:55:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9330A19465B6 for ; Mon, 19 Sep 2022 08:55:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8833F40C6EC3; Mon, 19 Sep 2022 08:55:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0360240C6EC2 for ; Mon, 19 Sep 2022 08:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577887; 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=xvPVPUXXj0ySYo90JhebKEnFrYFlofvscM/grnWsmdI=; b=C+hKGa8fQwHEWDYuDBnHYCbg0hejVpIm3WtBGtn/QRp4fUI6OKwFeY7Ku6gkhaSHPQtQ37 9qDK7eti5Gk17n1c/UheqWochxk9g7EbSgf7ed6uM3ZNWuD1u06I5oPfj0T/L1NDu+4K6X 5Uh3euvBwcZ7wmZfiUq16XZXhNhuMIY= X-MC-Unique: e40gjJKEMRGbGZWgSxp-Qw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/37] virDomainNetDef: Use virTristateBool for 'managed_tap' instead of int Date: Mon, 19 Sep 2022 10:55:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577890126100001 Content-Type: text/plain; charset="utf-8" Convert the strut member to proper type. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8fecf0566c..352b88eae5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1152,7 +1152,7 @@ struct _virDomainNetDef { char *downscript; char *domain_name; /* backend domain name */ char *ifname; /* interface name on the host () */ - int managed_tap; /* enum virTristateBool - ABSENT =3D=3D YES */ + virTristateBool managed_tap; virNetDevIPInfo hostIP; char *ifname_guest_actual; char *ifname_guest; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577835; cv=none; d=zohomail.com; s=zohoarc; b=ezCXH9H7uJji9E+9tI2hGFdObq1aJjTXaQ2z0//NW77z+E8Lk3HpfY7XSLG19aeSHijcTkvSNr+5O072ZOOe8lavr/5o96tm2CteQOEVhE8VPaKqbIBXogWqJkO0fA1DyNt8iehsR9Lvbcucza7/4rYLCV/vI5QTL2xoGrLJ9kI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577835; 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=j9z5TrM0lMRjgOeiSqMRT4qV0/rW5i2CtCe3FbGJt/w=; b=Q/UkSitEIHcwureSE6J+lgVfgmOmEX3wvVkzIldkNpOd4/wTvINfhQNqL41IrRue8Ia/eorrEqCz5AyQ38vVFbGFe1StODDIUyo/HBSMDCK6TVznnjyl4g3mANGs1F16pWwYLa0ahL+cTt1QOXRWxtoWcQJtYq3gT0SkuuBpxRY= 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 1663577835103450.85195684028736; Mon, 19 Sep 2022 01:57:15 -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-460-wkOJgHv4OVa1JcQNth_6Eg-1; Mon, 19 Sep 2022 04:55:57 -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 2297029ABA25; Mon, 19 Sep 2022 08:55: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 08C9D414A809; Mon, 19 Sep 2022 08:55: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 EDBFB1946597; Mon, 19 Sep 2022 08:55:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 800731946594 for ; Mon, 19 Sep 2022 08:55:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7665F40C6EC4; Mon, 19 Sep 2022 08:55:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E913740C6EC2 for ; Mon, 19 Sep 2022 08:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577834; 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=j9z5TrM0lMRjgOeiSqMRT4qV0/rW5i2CtCe3FbGJt/w=; b=CuQmmnzMjtlSmiu2pUo3jVz00/u/tbduKGd4yk5Tk0GI3uZCYgNV0lTlPi1a04ObeqltMk lCESQCLZeGTbVrZouFrhsOBO+8ctZ6IWpiR3BuHQIAyCZVBtW7x+wAqNzJR2lWw1laVeXL c75TobIdetLDMhEyUqF8mqT3YBaW4mA= X-MC-Unique: wkOJgHv4OVa1JcQNth_6Eg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/37] virDomainNetDefParseXML: Refactor parsing of subelement Date: Mon, 19 Sep 2022 10:55:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577835796100006 Content-Type: text/plain; charset="utf-8" Specifically rework of parsing of the 'managed' attribute simplifies the code greatly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bee415b9d5..a3f604ec7b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8994,12 +8994,12 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr vlan_node =3D NULL; xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr mac_node =3D NULL; + xmlNodePtr target_node =3D NULL; g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) int rv; g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; - g_autofree char *managed_tap =3D NULL; g_autofree char *model =3D NULL; g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; @@ -9282,8 +9282,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - def->ifname =3D virXPathString("string(./target/@dev)", ctxt); - managed_tap =3D virXPathString("string(./target/@managed)", ctxt); + if ((target_node =3D virXPathNode("./target", ctxt))) { + def->ifname =3D virXMLPropString(target_node, "dev"); + + if (virXMLPropTristateBool(target_node, "managed", VIR_XML_PROP_NO= NE, + &def->managed_tap) < 0) + return NULL; + } def->ifname_guest =3D virXPathString("string(./guest/@dev)", ctxt); def->ifname_guest_actual =3D virXPathString("string(./guest/@actual)",= ctxt); @@ -9351,17 +9356,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, ctxt, &def->guestIP) < 0) return NULL; - if (managed_tap) { - bool state =3D false; - if (virStringParseYesNo(managed_tap, &state) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid 'managed' value '%s'"), - managed_tap); - return NULL; - } - def->managed_tap =3D virTristateBoolFromBool(state); - } - if (def->managed_tap !=3D VIR_TRISTATE_BOOL_NO && def->ifname && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && (STRPREFIX(def->ifname, VIR_NET_GENERATED_VNET_PREFIX) || --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577832; cv=none; d=zohomail.com; s=zohoarc; b=I0NG+nNh1t4gYJEFOri7Eso+BgfWyqYjxb5zeIp4FGRnfnH4mZq7CN+ERkFE7jLhm6ODXkvw08M/vKmVsu/k9Zp6GZPPuCDQD9azmv89DJcB0ODjR4UQElARDJMNIBanXhS3xQpy3LzXiEy+CE/rv4QL61i+kCYT/36flXj07kU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577832; 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=Fid+mDQS5QbQbxi0k/dbtWF56sQPkARR4PLyGix3bgY=; b=Q0FeeltW1+UKHJjmqqZKO22sjl4FRmG72fr0Q+D6xyiBi5MdD0exvSw7mz6U/Bx+k09r+UkqGoH0C2bZcQTdpYi3Mq5yZcIjBLuusNAhAUzTzBswJB8mnMcIIPaVlA96KZtDytJNPybF2d4lYdW8wj+CYLU3rcL2V1mDNU5ycUY= 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 1663577832425329.2446739380921; Mon, 19 Sep 2022 01:57: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-642-YyjkRKc1PQOhqlQa3sjM1Q-1; Mon, 19 Sep 2022 04:55:59 -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 69E6E100DEA6; Mon, 19 Sep 2022 08:55: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 5655C1121314; Mon, 19 Sep 2022 08:55: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 46A1F1946594; Mon, 19 Sep 2022 08:55:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 86B7F19465A2 for ; Mon, 19 Sep 2022 08:55:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 779A040C6EC6; Mon, 19 Sep 2022 08:55:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD57D40C6EC5 for ; Mon, 19 Sep 2022 08:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577831; 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=Fid+mDQS5QbQbxi0k/dbtWF56sQPkARR4PLyGix3bgY=; b=YlHwHuG3xh4qZJGOdwOjIcnKECApVYeNax5YIhoRMb4DQHhHcUFCrRaROTHTxgDEep8cMU EMRD/vNb3LUO0FVaMSya3U1pLFbUUmZz2pC4PlPCTEnKG5vcPCbNcC/G00kBMbExUU/ppK TkV4/ShdeSXWwXWBkX1H4O0OrzBeddg= X-MC-Unique: YyjkRKc1PQOhqlQa3sjM1Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/37] virDomainNetDefParseXML: Refactor parsing of Date: Mon, 19 Sep 2022 10:55:19 +0200 Message-Id: <49f375a87b06f8c1756dd1362328111887b5d089.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577833822100002 Content-Type: text/plain; charset="utf-8" Parse the element only when the network type requires it and assign it directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 45 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3f604ec7b..c680d2bcc7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8990,21 +8990,19 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, g_autoptr(virDomainNetDef) def =3D NULL; xmlNodePtr source_node =3D NULL; xmlNodePtr virtualport_node =3D NULL; - xmlNodePtr filterref_node =3D NULL; xmlNodePtr vlan_node =3D NULL; xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr mac_node =3D NULL; xmlNodePtr target_node =3D NULL; - g_autoptr(GHashTable) filterparams =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) int rv; g_autofree char *macaddr =3D NULL; g_autofree char *dev =3D NULL; g_autofree char *model =3D NULL; - g_autofree char *filter =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *tap =3D NULL; unsigned int virtualport_flags =3D 0; + bool parse_filterref =3D false; const char *prefix =3D xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def =3D virDomainNetDefNew(xmlopt))) @@ -9056,6 +9054,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS; + parse_filterref =3D true; break; case VIR_DOMAIN_NET_TYPE_VDS: @@ -9097,6 +9096,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, virtualport_flags =3D VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS | VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | VIR_VPORT_XML_REQUIRE_TYPE; + parse_filterref =3D true; break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -9138,6 +9138,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } } + parse_filterref =3D true; break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: { @@ -9298,9 +9299,13 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, def->downscript =3D virXPathString("string(./downscript/@path)", ctxt); def->domain_name =3D virXPathString("string(./backenddomain/@name)", c= txt); - if ((filterref_node =3D virXPathNode("./filterref", ctxt))) { - filter =3D virXMLPropString(filterref_node, "filter"); - filterparams =3D virNWFilterParseParamAttributes(filterref_node); + if (parse_filterref) { + xmlNodePtr filterref_node =3D virXPathNode("./filterref", ctxt); + + if (filterref_node) { + def->filter =3D virXMLPropString(filterref_node, "filter"); + def->filterparams =3D virNWFilterParseParamAttributes(filterre= f_node); + } } if ((bandwidth_node =3D virXPathNode("./bandwidth", ctxt)) && @@ -9387,34 +9392,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, } } - if (filter !=3D NULL) { - switch (def->type) { - case VIR_DOMAIN_NET_TYPE_ETHERNET: - case VIR_DOMAIN_NET_TYPE_NETWORK: - case VIR_DOMAIN_NET_TYPE_BRIDGE: - def->filter =3D g_steal_pointer(&filter); - def->filterparams =3D g_steal_pointer(&filterparams); - break; - case VIR_DOMAIN_NET_TYPE_USER: - case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - case VIR_DOMAIN_NET_TYPE_SERVER: - case VIR_DOMAIN_NET_TYPE_CLIENT: - case VIR_DOMAIN_NET_TYPE_MCAST: - case VIR_DOMAIN_NET_TYPE_INTERNAL: - case VIR_DOMAIN_NET_TYPE_DIRECT: - case VIR_DOMAIN_NET_TYPE_HOSTDEV: - case VIR_DOMAIN_NET_TYPE_UDP: - case VIR_DOMAIN_NET_TYPE_NULL: - case VIR_DOMAIN_NET_TYPE_VDS: - case VIR_DOMAIN_NET_TYPE_VDPA: - break; - case VIR_DOMAIN_NET_TYPE_LAST: - default: - virReportEnumRangeError(virDomainNetType, def->type); - return NULL; - } - } - if (virDomainNetTeamingInfoParseXML(ctxt, &def->teaming) < 0) return NULL; --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577764; cv=none; d=zohomail.com; s=zohoarc; b=alKump87h1B79MLXnFzUj14cLtDr0xak7H3aUacH0RJq0d0Y3ygZiRe2YMnd85fTQ3ikYP7LPUfIkfMgLhvgvOoMlb6iWkOeeyh23gLsjIkuM7YzB0jEIPB/x/RjHUIZJ/drxITz8ymEs17uIwpDW3k5DZz4U+Mz1+a3snzm+Tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577764; 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=gfJFCRcQ+CQz0LGmyx5sIO5G6L2/6gRqrLioBZWF8Q4=; b=b/8QnAeWInl/omTEWAQBK0lR3truOs2bSEAXqist9/PQ+jPHG/s5wnY1ANFD6lTg7U7gMqRh0YrqhePAOShk75YUSBTpEUEMD5M2p4q3vMYj+Ez6uyMaxStBE9IRG7CVqps04yhSxOz8cdNeCeHrtWPg+oL3+UdYL7lTqrkYqSU= 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 1663577764077350.9311097615589; Mon, 19 Sep 2022 01:56: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-122-kCQbczB1O_2QZnS9BV_cCg-1; Mon, 19 Sep 2022 04:55:59 -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 CE21C857D17; Mon, 19 Sep 2022 08:55: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 B0D77C15BA8; Mon, 19 Sep 2022 08:55: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 900CD19465B3; Mon, 19 Sep 2022 08:55:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6459C1946586 for ; Mon, 19 Sep 2022 08:55:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5902240C6EC3; Mon, 19 Sep 2022 08:55:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C561440C6EC2 for ; Mon, 19 Sep 2022 08:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577762; 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=gfJFCRcQ+CQz0LGmyx5sIO5G6L2/6gRqrLioBZWF8Q4=; b=gl8GWiH1QJfqjf7/uuXM98NiOUVzTOPBsJmzlTztoUwkz6O7lDproOn8YiG5wvQp2oUqpO GwQwKZkOXPOprOVcj6zWMwQoqpAhEXG7XDq8QUQ07GAdt2JaTIWNsikbbxWRjoBMMQFsdX jqrRQz+QzWrNFPPTh+M/tjt03IX0DZ4= X-MC-Unique: kCQbczB1O_2QZnS9BV_cCg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/37] virDomainNetDefParseXML: Don't overload 'node' variable when parsing Date: Mon, 19 Sep 2022 10:55:20 +0200 Message-Id: <7b5941792ee708b5a76f99ad8bdd0e278d71f8f0.1663577578.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577765470100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c680d2bcc7..2a266ac6c9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8994,6 +8994,7 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr bandwidth_node =3D NULL; xmlNodePtr mac_node =3D NULL; xmlNodePtr target_node =3D NULL; + xmlNodePtr coalesce_node =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) int rv; g_autofree char *macaddr =3D NULL; @@ -9410,9 +9411,8 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, return NULL; } - node =3D virXPathNode("./coalesce", ctxt); - if (node) { - if (virDomainNetDefCoalesceParseXML(node, ctxt, &def->coalesce) < = 0) + if ((coalesce_node =3D virXPathNode("./coalesce", ctxt))) { + if (virDomainNetDefCoalesceParseXML(coalesce_node, ctxt, &def->coa= lesce) < 0) return NULL; } --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577838; cv=none; d=zohomail.com; s=zohoarc; b=Uv4N/iCsRbNSuoKju/cLGL4X3N5Xnt2WP0DMHBe/D3DWy6DdSiDeMtC+Um95h6dJSoAVzK3Uw4/sqStpLNe4Z4G5uZE2qFB2CaZHHDwOXwV8PjfihEhFWcwnLxnxIEsGgHs5TKpoUgCvyH9SZmixKxPZ8zeH6Pfnc15s4RuHXAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577838; 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=GrgZxdJBaHCX3pSK7dDFiv2u8XDhAhPil9Y28IMvTTY=; b=fTwyuu0hpKXakwXsJ8Erk76Fs3KFXknwckIvRsvsk51mT/o31nr1nY2kwgFNV/AssOCjUtshf5OVTLNjNob5E+3LsLhWaO6isrme0H4B6RLjslgqK0wCCNnWcgFTfZS2y4ZFhde6dLbI16C+OSM0Q3uV9cRCyXcKzT7/Mee07B0= 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 1663577838174499.6477856580967; Mon, 19 Sep 2022 01:57: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-175-iTuQti_vOeqkI7PU8JoHPA-1; Mon, 19 Sep 2022 04:56:01 -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 0B84986C150; Mon, 19 Sep 2022 08:55: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 EE5712166B26; Mon, 19 Sep 2022 08:55: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 DF9161946594; Mon, 19 Sep 2022 08:55:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 632A719465A4 for ; Mon, 19 Sep 2022 08:55:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5841740C6EC3; Mon, 19 Sep 2022 08:55:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0C1340C6EC2 for ; Mon, 19 Sep 2022 08:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577837; 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=GrgZxdJBaHCX3pSK7dDFiv2u8XDhAhPil9Y28IMvTTY=; b=Cx0uKx7j1gU8wMZ8uX2Hov17xUGJ17mmZLsgqupEccTGWZio34MiapOdV7TO8PPbGxOvJ9 iPQu16Jdg3KRPqACDna9eoELS7h6dJj+02BeAc7tcOmFZpIjJlbj9MfIyE1K4xlbMz28Qd Bd9OR5w2FGbk+/IaMxPPD9PiwBw9JP8= X-MC-Unique: iTuQti_vOeqkI7PU8JoHPA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 36/37] virDomainNetDefParseXML: Parse attributes of only when present Date: Mon, 19 Sep 2022 10:55:21 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577839966100001 Content-Type: text/plain; charset="utf-8" Access the 'mac_node' variable only when it was filled. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2a266ac6c9..d3755547c7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9321,37 +9321,37 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, if ((tap =3D virXPathString("string(./backend/@tap)", ctxt))) def->backend.tap =3D virFileSanitizePath(tap); - mac_node =3D virXPathNode("./mac", ctxt); + if ((mac_node =3D virXPathNode("./mac", ctxt))) { + if ((macaddr =3D virXMLPropString(mac_node, "address"))) { + if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unable to parse mac address '%s'"), + (const char *)macaddr); + return NULL; + } + if (virMacAddrIsMulticast(&def->mac)) { + virReportError(VIR_ERR_XML_ERROR, + _("expected unicast mac address, found mult= icast '%s'"), + (const char *)macaddr); + return NULL; + } + } - if ((macaddr =3D virXMLPropString(mac_node, "address"))) { - if (virMacAddrParse((const char *)macaddr, &def->mac) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unable to parse mac address '%s'"), - (const char *)macaddr); + if (virXMLPropEnum(mac_node, "type", + virDomainNetMacTypeTypeFromString, + VIR_XML_PROP_NONZERO, &def->mac_type) < 0) return NULL; - } - if (virMacAddrIsMulticast(&def->mac)) { - virReportError(VIR_ERR_XML_ERROR, - _("expected unicast mac address, found multicas= t '%s'"), - (const char *)macaddr); + + if (virXMLPropTristateBool(mac_node, "check", VIR_XML_PROP_NONE, + &def->mac_check) < 0) return NULL; - } - } else { + } + + if (!macaddr) { virDomainNetGenerateMAC(xmlopt, &def->mac); def->mac_generated =3D true; } - if (virXMLPropEnum(mac_node, "type", - virDomainNetMacTypeTypeFromString, - VIR_XML_PROP_NONZERO, - &def->mac_type) < 0) - return NULL; - - if (virXMLPropTristateBool(mac_node, "check", - VIR_XML_PROP_NONE, - &def->mac_check) < 0) - return NULL; - if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, &def->info, flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0)= { --=20 2.37.1 From nobody Fri May 17 23:30:01 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=1663577884; cv=none; d=zohomail.com; s=zohoarc; b=Q7IzoDeJApZoZ3eZ+IDNXUskHUKY1xZScrfstwk+HyTGJ3A8K1u/Knevb1aTQLHPUJ+zcBcqKawwpKdJlFRzEmsCiV+hLWNZZtxB3CTk3Qy9unm/BjQCP5PSxh9kU282vXRgIMW04XRxCS+6horoGRl+R67Iv/QMOwOy1Qw+4LM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663577884; 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=vZ40JzE/s6m5Kh5ddPNuh7KGR79fgY3S6lEYGyee5ts=; b=ShBOhaBtd/4h/D2U+kpW7dSaDZT9GydIEgdbyluALaoh89sPKO57iGj949k+sCNx1zBXN2QBBH4p/dEEPHqwWDMg7cdW5qxf1+cAhEBbaezmZCnGFTPGhla+C20auCFCGxzgsAAq3X06BZqc7CltN0toAmt7MlP/QabddZmrzwo= 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 1663577884008546.9095057541938; Mon, 19 Sep 2022 01:58: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-284-j0OfNiM3OYePl2Vs4YMWEg-1; Mon, 19 Sep 2022 04:56:03 -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 523A9185A794; Mon, 19 Sep 2022 08:56: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 3C1D740C2064; Mon, 19 Sep 2022 08:56: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 2CCD91946594; Mon, 19 Sep 2022 08:56:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B1B911946586 for ; Mon, 19 Sep 2022 08:55:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A727940C6EC2; Mon, 19 Sep 2022 08:55:58 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC970414A81B for ; Mon, 19 Sep 2022 08:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663577881; 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=vZ40JzE/s6m5Kh5ddPNuh7KGR79fgY3S6lEYGyee5ts=; b=Mi15YyyQ+Z+qJBojJILPDMUIPI3woI5y5hMVgwC1jiAY4Kxzu8dJXDZ9Nh2E/xpjTg5Itm xe1+ySq0sS+WwESyQW/II/qQGpg6cOX48mV8TomK+hlHwSVASRniKOoJfnzatOt9/QHPK5 Al44CkpaZjv0ElclefDbqoxJf3xvd9k= X-MC-Unique: j0OfNiM3OYePl2Vs4YMWEg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 37/37] virDomainNetDefParseXML: Drop prehistoric error workaround Date: Mon, 19 Sep 2022 10:55:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1663577886044100001 Content-Type: text/plain; charset="utf-8" Apart from it being a long time ago the 'openvz' driver is also rarely used. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Laine Stump --- src/conf/domain_conf.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d3755547c7..b7be1bae06 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8998,7 +8998,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, VIR_XPATH_NODE_AUTORESTORE(ctxt) int rv; g_autofree char *macaddr =3D NULL; - g_autofree char *dev =3D NULL; g_autofree char *model =3D NULL; g_autofree char *linkstate =3D NULL; g_autofree char *tap =3D NULL; @@ -9120,25 +9119,6 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt, break; case VIR_DOMAIN_NET_TYPE_ETHERNET: - /* This clause is only necessary because from 2010 to 2016 it was - * possible (but never documented) to configure the name of the - * guest-side interface of an openvz domain with . - * That was blatant misuse of , so was likely (hopefully) - * never used, but just in case there was somebody using it, we - * need to generate an error. If the openvz driver is ever - * deprecated, this clause can be removed from here. - */ - if (source_node) { - if ((dev =3D virXMLPropString(source_node, "dev"))) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid attempt to set " - "device name with . " - "Use (for host-side)= " - "or (for guest-side) = instead."), - dev, dev, dev); - return NULL; - } - } parse_filterref =3D true; break; --=20 2.37.1