From nobody Sat May 18 19:12:56 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=1675351174; cv=none; d=zohomail.com; s=zohoarc; b=HHd1WNt/ksr1M/Y6tJkSJFTcZnToD9+CZq+cCyxpJh3qea7ySt5yvQwV+RaWoAisYbdQY9B7+8U/15W+1VkYWbqIHbzoG71efw//PRHEYYyiz5eNN6Rs1kDHT6bmFr4IM75NBB1NDMqpA2k/QYJwlCNtEOPjNWgHjSD9B9l79u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351174; 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=eif6VDleJEsDezBmS8dgU2OdIFwmAnN6ycwOGGIiAVs=; b=Yl8L2ff6k1B+nWKtHhnKPTA4e8yiZ86D9udSpdzCR+yCErBJnF23zJkDKKgey8jRyR9Tyjic603tKWKXtH1OXH3Va7wLJj9zcuLC+cAODsuMV26xXlC8thZ6hCeIKwFS7OGWgcP7+tX6240HDmQxVJQmWQL9tG9gjOB84ylEblY= 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 1675351174958226.4301337262366; Thu, 2 Feb 2023 07:19:34 -0800 (PST) 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-435-ujkOQrMqOPyYBrEzRi0yIA-1; Thu, 02 Feb 2023 10:19:30 -0500 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 3C974281724D; Thu, 2 Feb 2023 15:19:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C0EF404BEC0; Thu, 2 Feb 2023 15:19:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1332A1946A43; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 17B9F19465BD for ; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 07CA22026D68; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76A322026D4B for ; Thu, 2 Feb 2023 15:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351174; 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=eif6VDleJEsDezBmS8dgU2OdIFwmAnN6ycwOGGIiAVs=; b=NmojTFjlwMpgAxh7I189aBC6jzAUxvpSn7REh8lOB1iRDqVm3D11yLfLW89kayqTsHPxQO ZLFSpa4Ud3yz0l/OAzrZuGvQwu51tkItAyCnD7k0G5+YOUp4R/EUAshusRUtRPl4nzMEOt Ts5519hCrH7h7iKbVzCmROHJ5GgxcRk= X-MC-Unique: ujkOQrMqOPyYBrEzRi0yIA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/7] virPCIDeviceAddressParseXML: Use virXMLNodeGetSubelement to find 'zpci' Date: Thu, 2 Feb 2023 16:18:04 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351176330100001 Content-Type: text/plain; charset="utf-8" Use the helper designed to find the subelement. A slight semantic difference after this patch is that the first element will be considered instead of the last, but only one is expected in a valid XML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/device_conf.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 762efe5f0b..a116e39c75 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -199,8 +199,7 @@ int virPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddress *addr) { - xmlNodePtr cur; - xmlNodePtr zpci =3D NULL; + xmlNodePtr zpci; memset(addr, 0, sizeof(*addr)); @@ -227,18 +226,11 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(a= ddr, true)) return -1; - cur =3D node->children; - while (cur) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "zpci")) { - zpci =3D cur; - } - cur =3D cur->next; + if ((zpci =3D virXMLNodeGetSubelement(node, "zpci"))) { + if (virZPCIDeviceAddressParseXML(zpci, addr) < 0) + return -1; } - if (zpci && virZPCIDeviceAddressParseXML(zpci, addr) < 0) - return -1; - return 0; } --=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351207; cv=none; d=zohomail.com; s=zohoarc; b=UmuINmAIwmDlrrhVUxCowAGn6ytVC+Fz6aBVOS4iQKofutDovQbeeKqUeIeL5ZzNHdjHSdjXunxtHkV4rXMZ+1NqAWPAUi4dW5RAwCWpVw2zTSB+Igdf00uLf9SwCs+tKYGEqZDITwmzowKk6Vr2Cot6mLAwW3OEgYA1CRm3Ht0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351207; 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=7n8k5y1otzQ1WHF7GYkqB3v6NhHj4dS/u2Txe+sWAyc=; b=W4BE3dtEnjqh7gULd+68cKV6+rUq2n64gXi9VmFCfNVB8bFA2lE9/n5eMdC5mNlvDqePT3/2MRLz8BwDpMJGeNQa6v48C87kC7HrcVTrhRWEvMZMyFxiYhGJG/G4CBLVXas3EmKALTxjxyK7vi7tqrMnAchb9c/+OTdW2eddLEA= 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 1675351207762240.7996681342065; Thu, 2 Feb 2023 07:20:07 -0800 (PST) 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-44-9g41TS2-NBK8bG2xS2WzrQ-1; Thu, 02 Feb 2023 10:19:29 -0500 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 5A0DE80A0AE; Thu, 2 Feb 2023 15:19:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42C24404BEC2; Thu, 2 Feb 2023 15:19:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4B92F1946A5E; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 05E3A19465BD for ; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EA7022026D4B; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 640EA2026D76 for ; Thu, 2 Feb 2023 15:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351206; 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=7n8k5y1otzQ1WHF7GYkqB3v6NhHj4dS/u2Txe+sWAyc=; b=M+HGt8nRI29qmYGEaxbHEBCvTeQ1hJEPr41T5xXcy+BfKwFhLA9QZ2DHS4d1tkKjSCy5ub 8gnBpSQ5skL4CsR/A+60Y5goyQ+L8deiIFx2fJWfkXcOeRcmxhL+8pouHueUn/MyurU1Va B3UHvWH/yiobf51q1/BqnE0qXE8o94g= X-MC-Unique: 9g41TS2-NBK8bG2xS2WzrQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/7] virNetDevVPortProfileParse: Use virXMLNodeGetSubelement to find '' Date: Thu, 2 Feb 2023 16:18:05 +0100 Message-Id: <81998161e2a9646b6809f54ce583ec33a2a2468f.1675350966.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351208566100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/netdev_vport_profile_conf.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index cdde7efcd9..26f379248f 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -36,7 +36,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int = flags) g_autofree char *virtPortProfileID =3D NULL; g_autofree char *virtPortInterfaceID =3D NULL; g_autofree virNetDevVPortProfile *virtPort =3D NULL; - xmlNodePtr cur =3D node->children; + xmlNodePtr parameters; virtPort =3D g_new0(virNetDevVPortProfile, 1); @@ -54,17 +54,13 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned in= t flags) return NULL; } - while (cur !=3D NULL) { - if (virXMLNodeNameEqual(cur, "parameters")) { - virtPortManagerID =3D virXMLPropString(cur, "managerid"); - virtPortTypeID =3D virXMLPropString(cur, "typeid"); - virtPortTypeIDVersion =3D virXMLPropString(cur, "typeidversion= "); - virtPortInstanceID =3D virXMLPropString(cur, "instanceid"); - virtPortProfileID =3D virXMLPropString(cur, "profileid"); - virtPortInterfaceID =3D virXMLPropString(cur, "interfaceid"); - break; - } - cur =3D cur->next; + if ((parameters =3D virXMLNodeGetSubelement(node, "parameters"))) { + virtPortManagerID =3D virXMLPropString(parameters, "managerid"); + virtPortTypeID =3D virXMLPropString(parameters, "typeid"); + virtPortTypeIDVersion =3D virXMLPropString(parameters, "typeidvers= ion"); + virtPortInstanceID =3D virXMLPropString(parameters, "instanceid"); + virtPortProfileID =3D virXMLPropString(parameters, "profileid"); + virtPortInterfaceID =3D virXMLPropString(parameters, "interfaceid"= ); } if (virtPortManagerID) { --=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351212; cv=none; d=zohomail.com; s=zohoarc; b=kQsZQ+d+2Jwg7xZxyvxbm+fsLlkeFFOg3+xo8lkmHF7nTF+99fEtk1TasEMHUcnWVoL9bE6TLq6rjXALDmJKKtd+zsjtBwcEIcuvmr1co5aQ4SUYGTUTZJ45+T3whZIa1t4/Xs0GOlu7k6zbl1oqL5dM7ivZXtsvmb6HDcb9rM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351212; 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=gwCgxI4trM6K0hKVJDk1PADiHEWhTKN7SKSXMSHBugg=; b=f1djWtMQJvbtWx/Y1xMvpo+xovcXN5Tsp+KDpgP3Rr3kzky4NcKZay7SosHLE6R/bk2hE6vdn3F36Se2lkOjdPCCyVeVztWLo8GN8arFAd/WhthSl5p6Vs4vetH81PU5MSnw8FWCHhL3XNa4Vlnec9ewHOkxHEnvLo4i90K7sqg= 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 1675351212748242.02526559060016; Thu, 2 Feb 2023 07:20:12 -0800 (PST) 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-581-0rSRJ3QpP-2c29bzEDwCvA-1; Thu, 02 Feb 2023 10:19:30 -0500 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 9467980557B; Thu, 2 Feb 2023 15:19:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C35244002; Thu, 2 Feb 2023 15:19:10 +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 B97761947345; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DA97B1946A5A for ; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D061B2026D68; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B3182026D4B for ; Thu, 2 Feb 2023 15:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351211; 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=gwCgxI4trM6K0hKVJDk1PADiHEWhTKN7SKSXMSHBugg=; b=eXXNtNyuCo7e5IGgd8HlETwjefNA9hwP321OAjqCF0i0461mq3AIAVjCqzVblKXrIRcKN+ D19Djgic6jRifeqMkHBOBe4j4YYmqEbTmesc9N+msr0Bszsxq0YFau2KuxSo2C574JyCzo Qh0z6nDSqsVqxTPrPdCIISJfTCzzfoU= X-MC-Unique: 0rSRJ3QpP-2c29bzEDwCvA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] virNetworkDHCPRangeDefParseXML: Use virXMLNodeGetSubelement to find 'lease' Date: Thu, 2 Feb 2023 16:18:06 +0100 Message-Id: <731168e70ff9675b1e15cea3f47088063954a8ff.1675350966.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351214568100001 Content-Type: text/plain; charset="utf-8" This also prevents a potential memleak when multiple elements would be present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/network_conf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index b98ae6aa3f..e33925f857 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -453,7 +453,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName, virNetworkDHCPRangeDef *range) { virSocketAddrRange *addr =3D &range->addr; - xmlNodePtr cur =3D node->children; + xmlNodePtr lease; g_autofree char *start =3D NULL; g_autofree char *end =3D NULL; @@ -480,15 +480,9 @@ virNetworkDHCPRangeDefParseXML(const char *networkName, virNetworkIPDefPrefix(ipdef)) < 0) return -1; - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "lease")) { - - if (virNetworkDHCPLeaseTimeDefParseXML(&range->lease, cur) < 0) - return -1; - } - cur =3D cur->next; - } + if ((lease =3D virXMLNodeGetSubelement(node, "lease")) && + virNetworkDHCPLeaseTimeDefParseXML(&range->lease, lease) < 0) + return -1; return 0; } --=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351209; cv=none; d=zohomail.com; s=zohoarc; b=YhFV4QTZWyolXlIANEnwd2LiZfqP4bSSJRI8w3zHr56RN4UN5vO0uR7ZdZJef0JDG9ni+Zr4MRWJkpJm1elH5kLT/8sQ5ZayjZy1KrTFgrDNxgLXAOrY3KgNMMp7gTtzCOce7j4kv3OYVQxwKYpQh9kDIOFuUfsM2nJsOgkEjrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351209; 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=t5x0MgMf4J9uaGDxAOk7MkSOl0K0eJohHZYqGF2WWcY=; b=ADzpOQfO66DtXs+zUmbwTXScmVYb5CIgdGiYzjoNFIGYLQWdTFhywHl8t9jH5qBTOb3YkKrHZIEqUUwoN982B7Oe3dc+UF97aEaHX4o7ai8JBGcl0dPMqlVCT+U03XtZiHb8Dnhxen1ObcVRfOkrsekzSqi7JaLHMv7btWzUu8k= 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 1675351209759164.06427056534153; Thu, 2 Feb 2023 07:20:09 -0800 (PST) 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-540-3S8kgFXpNs2yqIZJodrB9Q-1; Thu, 02 Feb 2023 10:19:29 -0500 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 D901C862FE1; Thu, 2 Feb 2023 15:19:08 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1F23404BEC0; Thu, 2 Feb 2023 15:19:08 +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 83AF31946A74; Thu, 2 Feb 2023 15:18:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E48AF1946A71 for ; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BB0FB2026D68; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 398ED2026D4B for ; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351208; 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=t5x0MgMf4J9uaGDxAOk7MkSOl0K0eJohHZYqGF2WWcY=; b=WKjwAVxpgBARseg/C8tupydkkpwOuuIdR+gl6lNVAvXSTHA1f4idroJ47o+yKRcP0qxb1x Rwvv2QeRj6B1nY05e4ZzkZDsylUYQlTOkRYKv3jWa32EnxsX+b1NhWywj+I3EFcJP3UNcv Z9Dsy4kU7k4vJVFRTHfQgsn6SVxY2JQ= X-MC-Unique: 3S8kgFXpNs2yqIZJodrB9Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/7] virNetworkDHCPHostDefParseXML: Use virXMLNodeGetSubelement to find 'lease' Date: Thu, 2 Feb 2023 16:18:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351210557100005 Content-Type: text/plain; charset="utf-8" This also prevents a potential memleak when multiple elements would be present. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/network_conf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index e33925f857..5d1f0e5203 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -501,7 +501,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName, g_autofree char *id =3D NULL; virMacAddr addr; virSocketAddr inaddr; - xmlNodePtr cur =3D node->children; + xmlNodePtr lease; mac =3D virXMLPropString(node, "mac"); if (mac !=3D NULL) { @@ -593,15 +593,9 @@ virNetworkDHCPHostDefParseXML(const char *networkName, } } - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE && - virXMLNodeNameEqual(cur, "lease")) { - - if (virNetworkDHCPLeaseTimeDefParseXML(&host->lease, cur) < 0) - return -1; - } - cur =3D cur->next; - } + if ((lease =3D virXMLNodeGetSubelement(node, "lease")) && + virNetworkDHCPLeaseTimeDefParseXML(&host->lease, lease) < 0) + return -1; host->mac =3D g_steal_pointer(&mac); host->id =3D g_steal_pointer(&id); --=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351208; cv=none; d=zohomail.com; s=zohoarc; b=hjz//bv8ln8YojR0HPfRHNQ+X9PNQ/C15+Wip6PVgcMljoZ6J5Qg7C9UTDNCIMp3JHgDyYIVD2H0nbR95Y5AzqJzUcLUd0GHR6zGUmrat9ZisbAKW3+p+FNb6xPOipKrK4TnszpDUJJctKQnqbQhQ0Hnx6BPBDEMGF3STjdMu0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351208; 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=Gqsy8ue74tIF61fVh0SpqcantroKe5JUU2O/eQxPhlU=; b=ZDVjSd8BApvFJpqNb+uD/tX3sHgcMKWPNMie4oMlwcULrymdGjMIvr73xHiRIQ78d+mhLJwGQCVnA35p2n7JYnaD87JgAZGzPcou/MwBXxp588pTG3USPfZzilzqWl2uRs/mU2IxOToghCai5KW/5L9aGm9p5WAvTxcQGMGbUmI= 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 1675351208595296.5560077702113; Thu, 2 Feb 2023 07:20:08 -0800 (PST) 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-3-kRLiecfROxWOMWvlJZ94cA-1; Thu, 02 Feb 2023 10:19:30 -0500 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 EC19F800DA7; Thu, 2 Feb 2023 15:19:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6E6751FF; Thu, 2 Feb 2023 15:19:11 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 019201947356; Thu, 2 Feb 2023 15:18:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 07EEF1947345 for ; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F045B2026D2A; Thu, 2 Feb 2023 15:18:16 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4F82026D68 for ; Thu, 2 Feb 2023 15:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351207; 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=Gqsy8ue74tIF61fVh0SpqcantroKe5JUU2O/eQxPhlU=; b=iURLtYZsXpeDK8NHZQx7IuXH78UTKph6UvV3/qXCjsEeQkXbXmH/MkUZIo5GorONHBgroH 641JEeQ0tmiJh2NajV0GVSuEJOWlNbRrBUYrdKDSZc9wIvnyZ4vtfxf69GRnQeYegDUDnc IcphQUqAhn3OgzZ8aQaf7swliE6AmpI= X-MC-Unique: kRLiecfROxWOMWvlJZ94cA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/7] virBitmapIsBitSet: Allow NULL bitmap Date: Thu, 2 Feb 2023 16:18:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351210563100006 Content-Type: text/plain; charset="utf-8" The virBitmapIsBitSet API is a permissive one which returns false when the bit is not set or is out of range. We can do the same if the bitmap is NULL to aid certain situations when this can happen, but we don't want to add extra checks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virbitmap.c | 4 ++-- src/util/virbitmap.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 5b9204cbd7..bdcbd0aece 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -216,7 +216,7 @@ virBitmapIsSet(virBitmap *bitmap, size_t b) /** * virBitmapIsBitSet: - * @bitmap: Pointer to bitmap + * @bitmap: Pointer to bitmap (May be NULL) * @b: bit position to get * * Get setting of bit position @b in @bitmap. @@ -228,7 +228,7 @@ bool virBitmapIsBitSet(virBitmap *bitmap, size_t b) { - if (bitmap->nbits <=3D b) + if (!bitmap || bitmap->nbits <=3D b) return false; return virBitmapIsSet(bitmap, b); diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index e2314904b0..dbd88c9bb5 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -61,7 +61,7 @@ void virBitmapClearBitExpand(virBitmap *bitmap, size_t b) * Get bit @b in @bitmap. Returns false if b is out of range. */ bool virBitmapIsBitSet(virBitmap *bitmap, size_t b) - ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; + G_GNUC_WARN_UNUSED_RESULT; /* * Get setting of bit position @b in @bitmap and store in @result */ --=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351205; cv=none; d=zohomail.com; s=zohoarc; b=kd8GNdw1F6uAhCjji2pXhPzR6YkiZyf5FYxJtM6LLOm/hssbZBciyBkfuOS3Q5cbOE6ODk8le7NflELbc6EgfHbMecrTyWNd3uMrP3PIBKqI6MPkRKhlkJzZiWCEbJP5Hf+hC+DZDo4r8heAGGHyR2RDvfimoUQipWe8Ja8cTzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351205; 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=Q9QK5REeH66Sa+76eRkb+R9DgdkX1+AvuoiCOaq2fcA=; b=Ffics8bJDfNtoF8Fxaw7cJ0EPGoHxEpgsHtb4HW9TLLXptut6pXsJNnEdm0CSBm4d56my2e0JYUrJhJmK7lKIqpDt5mcE8Q0ytRRucfB3nNHNsfXR9d0Hq75Q0RTv4KfNgJVAZdYU9zf2F4GZZt4ccZ5JICRrZJFke6C+Z7JgLI= 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 1675351205858477.5994673805154; Thu, 2 Feb 2023 07:20:05 -0800 (PST) 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-108-_mR8SKVQOTCP3Z2yVSOp2A-1; Thu, 02 Feb 2023 10:19:30 -0500 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 2C9963814962; Thu, 2 Feb 2023 15:19:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 154A3492C3E; Thu, 2 Feb 2023 15:19:13 +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 537EF1947365; Thu, 2 Feb 2023 15:18:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A47DA1947345 for ; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9580B2026D4B; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A3CC2026D68 for ; Thu, 2 Feb 2023 15:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351204; 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=Q9QK5REeH66Sa+76eRkb+R9DgdkX1+AvuoiCOaq2fcA=; b=eJ62IGr7MSQFdM+v0xPj5xxkKeMu96tQPH5+PgbLjFfo0rLMYc3B4nxWUKc20pTa9XcjW6 ffct6lady4s2zu3SANT6UjNEzKYuYX2lDhJlah7Q4HuVHzBRbAJxmyD5SetMAlJc92dOqy 6igsuLVJJOy5g1oqDYZZ8hZgF6aFang= X-MC-Unique: _mR8SKVQOTCP3Z2yVSOp2A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/7] qemustatusxml2xmltest: Add test data for testing '' of PCI hostdev Date: Thu, 2 Feb 2023 16:18:09 +0100 Message-Id: <55163f4bc453123af5af70fe08ae942c33d64f33.1675350966.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351206531100001 Content-Type: text/plain; charset="utf-8" The XML element captures private data of a PCI device needed to restore it after a VM is started. Unfortunately at the point when it was added we didn't yet have the existing private data infrastructure. Since the element is parsed only in cases similar to the status XML we need to test it there. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tests/qemustatusxml2xmldata/modern-in.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index f5beab722b..cdab1d7178 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -483,6 +483,18 @@
+ + + +
+ + + + + + +
+
--=20 2.39.1 From nobody Sat May 18 19:12:56 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=1675351176; cv=none; d=zohomail.com; s=zohoarc; b=Fxt9cQDZUY0S++tXRUUBREFexi8V/ZddIdtUP6FHyef86iAyLGbzM18byMSz7KZGEKfIBzA/CwFqh3jlz2iO4vBgeqP1jnh44ieM61qDiEpjkdfMzPNmwM3u7PTuTUA/Qk4mpuq8OvCVnc2YkO8WHRwYcmYsI8T0+Ko00jCym+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675351176; 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=SOIRCMaXIgvLNIogWXGIMAgdCS41IsrLmEcI4BW9SgA=; b=X+lgU4u/5n8MfIwhy5r81yM+TWIAnMcm02pKQfO7sIBpEkGS5zpeUSuHP3MgPFGcj9l7Qu2bmDrQ8nJ43WLloyEGpY/nKpo7Nltdyl3iob3lH+xKBgIAS4ZFcGPDdOnDopT+sSOMwNKV8PLVLSBStTzlBQXVCjRJ08BDCQzY9sM= 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 1675351176630866.8167760236989; Thu, 2 Feb 2023 07:19:36 -0800 (PST) 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-495-BVMJU81WMF-VeH_hJBa7_g-1; Thu, 02 Feb 2023 10:19:31 -0500 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 55E898058A5; Thu, 2 Feb 2023 15:19:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40D81404BEC2; Thu, 2 Feb 2023 15:19:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 36317194737A; Thu, 2 Feb 2023 15:18:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A1DD21947364 for ; Thu, 2 Feb 2023 15:18:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 92A0A2026D68; Thu, 2 Feb 2023 15:18:18 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB7FA2026D4B for ; Thu, 2 Feb 2023 15:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675351175; 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=SOIRCMaXIgvLNIogWXGIMAgdCS41IsrLmEcI4BW9SgA=; b=EaTRw3P69YV3UA1e644dlvIdtcRY4M/AiO9n13DiMjeUwBA/MlX4QMFpGznstwlnV+uZ/H 4bl/XzkKn5F8WbB3NqIDMZgHx0g7jwa00hzDHaRGB+zsWssNgzdy73dQqcFU1p5Mpegzlx WaOEO/OxxQt1P0DwKRvsV06+4u9Yvls= X-MC-Unique: BVMJU81WMF-VeH_hJBa7_g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 7/7] conf: Store 'origstates' of PCI hostdevs in a bitmap Date: Thu, 2 Feb 2023 16:18:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675351178110100003 Content-Type: text/plain; charset="utf-8" Refactor the code to use a bitmap with an enum to avoid ugly XML parser. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/conf/domain_conf.c | 97 ++++++++++++++++++------------------- src/conf/domain_conf.h | 31 ++++-------- src/conf/virconftypes.h | 2 - src/hypervisor/virhostdev.c | 25 ++++++---- 4 files changed, 72 insertions(+), 83 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6e33a4472f..b21efeacf9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1061,6 +1061,14 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, "iscsi", ); + +VIR_ENUM_IMPL(virDomainHostdevPCIOrigstate, + VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_LAST, + "unbind", + "removeslot", + "reprobe", +); + VIR_ENUM_IMPL(virDomainHostdevSubsysUSBGuestReset, VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST, "default", @@ -3365,8 +3373,10 @@ void virDomainHostdevDefClear(virDomainHostdevDef *d= ef) case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: VIR_FREE(def->source.subsys.u.scsi_host.wwpn); break; - case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: + virBitmapFree(def->source.subsys.u.pci.origstates); + break; + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: break; @@ -5731,41 +5741,6 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, return 0; } -/* The internal XML for host PCI device's original states: - * - * - * - * - * - * - */ -static int -virDomainHostdevSubsysPCIOrigStatesDefParseXML(xmlNodePtr node, - virDomainHostdevOrigStates = *def) -{ - xmlNodePtr cur; - cur =3D node->children; - - while (cur !=3D NULL) { - if (cur->type =3D=3D XML_ELEMENT_NODE) { - if (virXMLNodeNameEqual(cur, "unbind")) { - def->states.pci.unbind_from_stub =3D true; - } else if (virXMLNodeNameEqual(cur, "removeslot")) { - def->states.pci.remove_slot =3D true; - } else if (virXMLNodeNameEqual(cur, "reprobe")) { - def->states.pci.reprobe =3D true; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported element '%s' of 'origstates'= "), - cur->name); - return -1; - } - } - cur =3D cur->next; - } - - return 0; -} static int virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, @@ -5774,7 +5749,6 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, unsigned int flags) { xmlNodePtr address =3D NULL; - xmlNodePtr origstates =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) ctxt->node =3D node; @@ -5788,10 +5762,35 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr nod= e, virPCIDeviceAddressParseXML(address, &def->source.subsys.u.pci.add= r) < 0) return -1; - if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && - (origstates =3D virXPathNode("./origstates", ctxt)) && - virDomainHostdevSubsysPCIOrigStatesDefParseXML(origstates, &def->o= rigstates) < 0) - return -1; + if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES)) { + virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; + g_autofree xmlNodePtr *nodes =3D NULL; + ssize_t nnodes; + size_t i; + + if ((nnodes =3D virXPathNodeSet("./origstates/*", ctxt, &nodes)) <= 0) + return -1; + + if (nnodes > 0) { + if (!pcisrc->origstates) + pcisrc->origstates =3D virBitmapNew(VIR_DOMAIN_HOSTDEV_PCI= _ORIGSTATE_LAST); + else + virBitmapClearAll(pcisrc->origstates); + + for (i =3D 0; i < nnodes; i++) { + int state; + + if ((state =3D virDomainHostdevPCIOrigstateTypeFromString(= (const char *) nodes[i]->name)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported element '%s' of 'origsta= tes'"), + (const char *) nodes[i]->name); + return -1; + } + + virBitmapSetBitExpand(pcisrc->origstates, state); + } + } + } return 0; } @@ -23154,7 +23153,6 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, { g_auto(virBuffer) sourceAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) sourceChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); - g_auto(virBuffer) origstatesChildBuf =3D VIR_BUFFER_INIT_CHILD(&source= ChildBuf); virDomainHostdevSubsysPCI *pcisrc =3D &def->source.subsys.u.pci; if (def->writeFiltering !=3D VIR_TRISTATE_BOOL_ABSENT) @@ -23176,15 +23174,14 @@ virDomainHostdevDefFormatSubsysPCI(virBuffer *buf, virPCIDeviceAddressFormat(&sourceChildBuf, pcisrc->addr, includeTypeIn= Addr); - if ((flags & VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES)) { - if (def->origstates.states.pci.unbind_from_stub) - virBufferAddLit(&origstatesChildBuf, "\n"); - - if (def->origstates.states.pci.remove_slot) - virBufferAddLit(&origstatesChildBuf, "\n"); + if (pcisrc->origstates && + (flags & VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES)) { + g_auto(virBuffer) origstatesChildBuf =3D VIR_BUFFER_INIT_CHILD(&so= urceChildBuf); + ssize_t n =3D -1; - if (def->origstates.states.pci.reprobe) - virBufferAddLit(&origstatesChildBuf, "\n"); + while ((n =3D virBitmapNextSetBit(pcisrc->origstates, n)) >=3D 0) + virBufferAsprintf(&origstatesChildBuf, "<%s/>\n", + virDomainHostdevPCIOrigstateTypeToString(n)); virXMLFormatElement(&sourceChildBuf, "origstates", NULL, &origstat= esChildBuf); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1a80399c9c..0bec072478 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -167,28 +167,14 @@ typedef enum { } virDomainHyperVMode; VIR_ENUM_DECL(virDomainHyperVMode); -struct _virDomainHostdevOrigStates { - union { - struct { - /* Does the device need to unbind from stub when - * reattaching to host? - */ - bool unbind_from_stub; - - /* Does it need to use remove_slot when reattaching - * the device to host? - */ - bool remove_slot; +typedef enum { + VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_UNBIND =3D 0, /* device needs to unbi= nd from stub when reattaching */ + VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_REMOVESLOT, /* use remove_slot when r= eattaching */ + VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_REPROBE, /* reprobe driver for device= when reattaching */ - /* Does it need to reprobe driver for the device when - * reattaching to host? - */ - bool reprobe; - } pci; - - /* Perhaps 'usb' in future */ - } states; -}; + VIR_DOMAIN_HOSTDEV_PCI_ORIGSTATE_LAST +} virDomainHostdevPCIOrigstate; +VIR_ENUM_DECL(virDomainHostdevPCIOrigstate); struct _virDomainLeaseDef { char *lockspace; @@ -262,6 +248,8 @@ struct _virDomainHostdevSubsysUSB { struct _virDomainHostdevSubsysPCI { virPCIDeviceAddress addr; /* host address */ virDomainHostdevSubsysPCIBackendType backend; + + virBitmap *origstates; }; struct _virDomainHostdevSubsysSCSIHost { @@ -394,7 +382,6 @@ struct _virDomainHostdevDef { virDomainHostdevSubsys subsys; virDomainHostdevCaps caps; } source; - virDomainHostdevOrigStates origstates; virDomainNetTeamingInfo *teaming; virDomainDeviceInfo *info; /* Guest address */ }; diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h index d03d1d132e..e07f967814 100644 --- a/src/conf/virconftypes.h +++ b/src/conf/virconftypes.h @@ -116,8 +116,6 @@ typedef struct _virDomainHostdevCaps virDomainHostdevCa= ps; typedef struct _virDomainHostdevDef virDomainHostdevDef; -typedef struct _virDomainHostdevOrigStates virDomainHostdevOrigStates; - typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys; typedef struct _virDomainHostdevSubsysMediatedDev virDomainHostdevSubsysMe= diatedDev; diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index c0ce867596..bc5a20d691 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -873,12 +873,18 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mg= r, if (actual) { VIR_DEBUG("Saving network configuration of PCI device %s", virPCIDeviceGetName(actual)); - hostdev->origstates.states.pci.unbind_from_stub =3D - virPCIDeviceGetUnbindFromStub(actual); - hostdev->origstates.states.pci.remove_slot =3D - virPCIDeviceGetRemoveSlot(actual); - hostdev->origstates.states.pci.reprobe =3D - virPCIDeviceGetReprobe(actual); + + if (!pcisrc->origstates) + pcisrc->origstates =3D virBitmapNew(VIR_DOMAIN_HOSTDEV_PCI= _ORIGSTATE_LAST); + else + virBitmapClearAll(pcisrc->origstates); + + if (virPCIDeviceGetUnbindFromStub(actual)) + virBitmapSetBitExpand(pcisrc->origstates, VIR_DOMAIN_HOSTD= EV_PCI_ORIGSTATE_UNBIND); + if (virPCIDeviceGetRemoveSlot(actual)) + virBitmapSetBitExpand(pcisrc->origstates, VIR_DOMAIN_HOSTD= EV_PCI_ORIGSTATE_REMOVESLOT); + if (virPCIDeviceGetReprobe(actual)) + virBitmapSetBitExpand(pcisrc->origstates, VIR_DOMAIN_HOSTD= EV_PCI_ORIGSTATE_REPROBE); } } @@ -1132,6 +1138,7 @@ virHostdevUpdateActivePCIDevices(virHostdevManager *m= gr, for (i =3D 0; i < nhostdevs; i++) { const virDomainHostdevDef *hostdev =3D hostdevs[i]; g_autoptr(virPCIDevice) actual =3D NULL; + virBitmap *orig =3D hostdev->source.subsys.u.pci.origstates; if (virHostdevGetPCIHostDevice(hostdev, &actual) < 0) goto cleanup; @@ -1143,9 +1150,9 @@ virHostdevUpdateActivePCIDevices(virHostdevManager *m= gr, goto cleanup; /* Setup the original states for the PCI device */ - virPCIDeviceSetUnbindFromStub(actual, hostdev->origstates.states.p= ci.unbind_from_stub); - virPCIDeviceSetRemoveSlot(actual, hostdev->origstates.states.pci.r= emove_slot); - virPCIDeviceSetReprobe(actual, hostdev->origstates.states.pci.repr= obe); + virPCIDeviceSetUnbindFromStub(actual, virBitmapIsBitSet(orig, VIR_= DOMAIN_HOSTDEV_PCI_ORIGSTATE_UNBIND)); + virPCIDeviceSetRemoveSlot(actual, virBitmapIsBitSet(orig, VIR_DOMA= IN_HOSTDEV_PCI_ORIGSTATE_REMOVESLOT)); + virPCIDeviceSetReprobe(actual, virBitmapIsBitSet(orig, VIR_DOMAIN_= HOSTDEV_PCI_ORIGSTATE_REPROBE)); if (virPCIDeviceListAdd(mgr->activePCIHostdevs, actual) < 0) goto cleanup; --=20 2.39.1