From nobody Fri Oct 18 04:32:54 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756220; cv=none; d=zohomail.com; s=zohoarc; b=jDjZQS+ini3WrjAl+DBV7CS80k74PSifGBuIXouUty3Hj2iyEptFcAbSNG2nPuTvGdKEf5Mf4BC5kYuasy1Hj7CJd2PRKH0FUW58VxtwVy0AB+EruYb3INaIWR8zXyYTGAU1n9gPyjcOlOENjkGbQtC0KJ77O/L6m3wQmIqlP1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756220; h=Content-Type:Content-Transfer-Encoding:Cc: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=sIjgi7BF8OfRnEIxfnkzHNX33v9oEKbliuHTvTTbTmw=; b=Gau1AJtpeeUncwdmMywRUIxOa3FxsC/riaahsg/+cXGGqlNrO07u/dgsYXYuvRAfGhCgTOZkqyDQ+6b5w9ms9ZvAHlhYQs+8Ee40CgR/nuI/wkAlHI5n0U+A0Jd/W12KFH+Aqwhi3SuO6v40cjyprTOM7onZLvKR8TddPMKkGfM= 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=fail 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 1693756220108995.3823299750292; Sun, 3 Sep 2023 08:50:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-zcJqSDpSOYap1BpmkjpDtQ-1; Sun, 03 Sep 2023 11:50:14 -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 6C30110264FB; Sun, 3 Sep 2023 15:50:12 +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 4FA4E40C105A; Sun, 3 Sep 2023 15:50:12 +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 1738F1946A69; Sun, 3 Sep 2023 15:50:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BC7341946597 for ; Sun, 3 Sep 2023 15:50:10 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AE73D1460FFB; Sun, 3 Sep 2023 15:50:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A74771460FFA for ; Sun, 3 Sep 2023 15:50:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C6843C02532 for ; Sun, 3 Sep 2023 15:50:10 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-Nw-eNBdMNremJDL2osv16w-1; Sun, 03 Sep 2023 11:50:08 -0400 Received: from fews02-sea.riseup.net (fews02-sea-pn.riseup.net [10.0.1.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx0.riseup.net (Postfix) with ESMTPS id 4Rdx6l6lZ1z9tGn for ; Sun, 3 Sep 2023 15:50:07 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6k5t40zFpfK; Sun, 3 Sep 2023 15:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756219; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=sIjgi7BF8OfRnEIxfnkzHNX33v9oEKbliuHTvTTbTmw=; b=bFfh1SmEhLl/c1RUWhf4aUV8okFU4fGj/bkrjecVUTx5F7+4yfH7rYVCs+hcdQx/tFq7FS ZU5ZGR5j8bBvcfoN0yD+B7SJ3z/UTYqG9T7cwoaM7SsdFp3cClRsbGwKxuCJEMIKfknIlP H4CGg7iiwoK+ZEfOO7Vl0IKKZCSP7TM= X-MC-Unique: zcJqSDpSOYap1BpmkjpDtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Nw-eNBdMNremJDL2osv16w-1 X-Riseup-User-ID: 3CA73B66496886127654AE1D3D49817F41BDE1BC2D78D17B8B92F19DE7648AE9 From: K Shiva Kiran To: libvir-list@redhat.com Subject: [PATCH 02/16] conf: Add parser logic for nwfilter metadata fields Date: Sun, 3 Sep 2023 21:19:03 +0530 Message-ID: <20230903155034.211476-3-shiva_kr@riseup.net> In-Reply-To: <20230903155034.211476-1-shiva_kr@riseup.net> References: <20230903155034.211476-1-shiva_kr@riseup.net> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: , Cc: K Shiva Kiran 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: riseup.net Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693756222031100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran --- src/conf/nwfilter_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/nwfilter_conf.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 35f6efbbe2..d03f78af4d 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -327,6 +327,10 @@ virNWFilterDefFree(virNWFilterDef *def) g_free(def->filterEntries); g_free(def->chainsuffix); =20 + g_free(def->title); + g_free(def->description); + xmlFreeNode(def->metadata); + g_free(def); } =20 @@ -2516,6 +2520,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) virNWFilterEntry *entry; int chain_priority; const char *name_prefix; + xmlNodePtr metadataNode =3D NULL; =20 ret =3D g_new0(virNWFilterDef, 1); =20 @@ -2582,6 +2587,23 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) } } =20 + /* Extract short description of filter (title) */ + ret->title =3D virXPathString("string(./title[1])", ctxt); + if (ret->title && strchr(ret->title, '\n')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Network filter title can't contain newlines")); + return NULL; + } + + /* Extract documentation if present */ + ret->description =3D virXPathString("string(./description[1])", ctxt); + + /* Extract custom metadata */ + if ((metadataNode =3D virXPathNode("./metadata[1]", ctxt)) !=3D NULL) { + ret->metadata =3D xmlCopyNode(metadataNode, 1); + virXMLNodeSanitizeNamespaces(ret->metadata); + } + curr =3D curr->children; =20 while (curr !=3D NULL) { @@ -2873,6 +2895,14 @@ virNWFilterDefFormat(const virNWFilterDef *def) virUUIDFormat(def->uuid, uuid); virBufferAsprintf(&buf, "%s\n", uuid); =20 + virBufferEscapeString(&buf, "%s\n", def->title); + + virBufferEscapeString(&buf, "%s\n", + def->description); + + if (virXMLFormatMetadata(&buf, def->metadata) < 0) + return NULL; + for (i =3D 0; i < def->nentries; i++) { if (virNWFilterEntryFormat(&buf, def->filterEntries[i]) < 0) return NULL; diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 22c2fb51f0..34de6eab3d 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -517,6 +517,11 @@ struct _virNWFilterDef { =20 size_t nentries; virNWFilterEntry **filterEntries; + + /* User-defined metadata */ + char* title; + char* description; + xmlNodePtr metadata; }; =20 =20 --=20 2.42.0