From nobody Sun May 12 05:00:18 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=1693756219; cv=none; d=zohomail.com; s=zohoarc; b=meCX6rYZ89ml7ubMtHNPweiAePDvw8eaQ9wGz5KCMcOleZq1I6EOhYIsufRWn4Ror5rpt57XAd0kNJJkVSkTluM0JBdHwVOSh6wuXgt3fjFnGQpKuNTPfBcseaWigrg1x/lu85eCbUzp/ZppbjitNYVvj18sX6txu9f7/v3ccOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756219; 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=SPDT+DVFMP7MC8Rsdc9pvzHoysiVSIiM4zNfSkAgt44=; b=XGPYgpX61cRyi2PQ3iDosiExxa7YJBuFmIB1KJtsUM3bpRvvSBUiRNTKIlHV64/0pEHTiWBhxwE+BlPwSF8PA8tkPIVr4EqQ3lcrNmij+Ix+XFg/BWiCCdEwsoSL9+0JafEJ5dcRnWU3U213heXsp1yZ1VCXZEx2g92jilPQ2rk= 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 1693756219212600.8736544009424; Sun, 3 Sep 2023 08:50:19 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-116-4hXMVtYuMoahC8sBFXkgfA-1; Sun, 03 Sep 2023 11:50:14 -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 D7AAF29AA3BD; Sun, 3 Sep 2023 15:50: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 C38DA1208F6D; Sun, 3 Sep 2023 15:50: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 AEADB19465A8; Sun, 3 Sep 2023 15:50:11 +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 CF7451946588 for ; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9BCC2400E13F; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9366A40C6CCC for ; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.120]) (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 5A69D3806714 for ; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-vp2l7VgjO5CdIZ-yj0TLcQ-1; Sun, 03 Sep 2023 11:50:07 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6k2PfWzDr2k for ; Sun, 3 Sep 2023 15:50:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6j1X9xzFqL8; Sun, 3 Sep 2023 15:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756218; 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=SPDT+DVFMP7MC8Rsdc9pvzHoysiVSIiM4zNfSkAgt44=; b=P8nhTDgaYZAnDF7qdqVXakIJByEWBaVjocy4UTy0YLH82SXyb8zLY+f00iK10uzStS1UHA j2q8/A+alq0Rkgbpy6tLuJxTUnI+/H/QC7QLCLDRXpqQ9V2FDtMsuuzYw3geOFycWcfXj6 sqt6dnAcG0+C9ozceri+eeR27oUTZ5Q= X-MC-Unique: 4hXMVtYuMoahC8sBFXkgfA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: vp2l7VgjO5CdIZ-yj0TLcQ-1 X-Riseup-User-ID: 6695A9E9BDF6FA53ECF8FF318AA432A43A0A116159ECAC0BF7EB5CF13B05C80D From: K Shiva Kiran To: libvir-list@redhat.com Subject: [PATCH 01/16] xml: Add , <description> and <metadata> to nwfilter xml schema Date: Sun, 3 Sep 2023 21:19:02 +0530 Message-ID: <20230903155034.211476-2-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.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1693756221254100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- docs/formatnwfilter.rst | 31 +++++++++++++++++++++++++++++++ src/conf/schemas/nwfilter.rng | 9 +++++++++ 2 files changed, 40 insertions(+) diff --git a/docs/formatnwfilter.rst b/docs/formatnwfilter.rst index 434da5b1fd..766d7e85f5 100644 --- a/docs/formatnwfilter.rst +++ b/docs/formatnwfilter.rst @@ -419,6 +419,37 @@ better organized for more efficient processing by the = firewall subsystem of the underlying host. Currently the system only supports the chains ``root, ipv4, ipv6, arp and rarp``. =20 +General Metadata +~~~~~~~~~~~~~~~~ + +:: + + <filter name=3D'clean-traffic' filter=3D'arp'> + <uuid>6ef53069-ba34-94a0-d33d-17751b9b8cb1</uuid> + <title>A short description - title - of the filter + Some human readable description + + .. + .. + + ... + + +``title`` + The optional element ``title`` provides space for a short description o= f the + filter. The title should not contain any newlines. :since:`Since 9.8.0`= . +``description`` + The content of the ``description`` element provides a human readable + description of the filter. This data is not used by libvirt in any + way, it can contain any information the user wants. :since:`Since 9.8.0` +``metadata`` + The ``metadata`` node can be used by applications to store custom metad= ata in + the form of XML nodes/trees. Applications must use custom namespaces on= their + XML nodes/trees, with only one top-level element per namespace (if the + application needs structure, they should have sub-elements to their nam= espace + element). :since:`Since 9.8.0` + + References to other filters ~~~~~~~~~~~~~~~~~~~~~~~~~~~ =20 diff --git a/src/conf/schemas/nwfilter.rng b/src/conf/schemas/nwfilter.rng index 262bd551e3..c56bbac732 100644 --- a/src/conf/schemas/nwfilter.rng +++ b/src/conf/schemas/nwfilter.rng @@ -14,6 +14,15 @@ + + + + + + + + + --=20 2.42.0 From nobody Sun May 12 05:00:18 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 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756219; cv=none; d=zohomail.com; s=zohoarc; b=W/DLKQaCo5g1qsW6j7+/G3nw5TuVow4hsn54VPw9ImXjTMAidCURmvDs2Hz34JxrXlVWe8kM7fMSjfxlruPuAdtviGZR8lu6VLr9rLN91H5o3v0s+rryYC3XgQhuQIIeW0zLNj6K9nXm4tqD6NM7fSMqEyGBMhpNk23+b9uxSaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756219; 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=1K/SCmo8G9MPe6/qY2PISm0edz6+DI1tyXzRvvvpLFQ=; b=Bq3b8i4SFMI/DW734YPpY1KVJnpE3Mi789504Hacm0yGZZ7eTB3fvvi7HSVPDzo8lETCU9bwBUZ1tuRzBvWS2e83oV04nbkFSgTpB6W0rIoYnNJIWpGtElri/amxrQ+0cNSWLSgAsod9M/Lr3TOzTfwd8gzARCvWfPbMzzhxO84= 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=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.129.124]) by mx.zohomail.com with SMTPS id 1693756219733250.51148278973494; Sun, 3 Sep 2023 08:50:19 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-381-hTXlIbeVMWubuhRuEvRUlw-1; Sun, 03 Sep 2023 11:50:16 -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 85B103C0EADC; Sun, 3 Sep 2023 15:50: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 74291200BA73; Sun, 3 Sep 2023 15:50: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 551EE1946597; Sun, 3 Sep 2023 15:50:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A1CF81946597 for ; Sun, 3 Sep 2023 15:50:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8358740C84A7; Sun, 3 Sep 2023 15:50:12 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C49C40561C3 for ; Sun, 3 Sep 2023 15:50:12 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 429F8925FC8 for ; Sun, 3 Sep 2023 15:50:12 +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-15-Qtyl0oWKP3Os00_IB29uYA-1; Sun, 03 Sep 2023 11:50:10 -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 4Rdx6n42Ckz9tGn for ; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6m37WLzFpfK; Sun, 3 Sep 2023 15:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756218; 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=1K/SCmo8G9MPe6/qY2PISm0edz6+DI1tyXzRvvvpLFQ=; b=Lf3MnemJyRUDJBl094lNBgXAey0DXdQ0ITu+Eli8O5k0lJwYOFHDpU+j5JCPmw9+Ig6erB Un4W4vG42cc4W/VhYsWJ74UqTmj1mtyi5CAV6Nv+lOjW91F28irVTjekibaozkSTQEKN6u tsHU1CxNTc5x154AwC18N/gWrKnTN8s= X-MC-Unique: hTXlIbeVMWubuhRuEvRUlw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Qtyl0oWKP3Os00_IB29uYA-1 X-Riseup-User-ID: CB502E9C133A010DF0B003683C2873992F30ABF64DE0C270CAA67316D3958802 From: K Shiva Kiran To: libvir-list@redhat.com Subject: [PATCH 03/16] nwfilter: Add enum to operate on user defined metadata Date: Sun, 3 Sep 2023 21:19:04 +0530 Message-ID: <20230903155034.211476-4-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.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: K Shiva Kiran 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: riseup.net Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693756221244100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Adds enum `virNWFilterMetadataType` to choose between ``, `<description>` or `<metadata>`. Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- include/libvirt/libvirt-nwfilter.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-n= wfilter.h index 33b842b464..a9930a1e66 100644 --- a/include/libvirt/libvirt-nwfilter.h +++ b/include/libvirt/libvirt-nwfilter.h @@ -159,4 +159,18 @@ int virNWFilterBindingDelete(virNW= FilterBindingPtr binding); int virNWFilterBindingRef(virNWFilterBindingPtr bindin= g); int virNWFilterBindingFree(virNWFilterBindingPtr bindi= ng); =20 +/** + * virNWFilterMetadataType: + * + * Since: 9.8.0 + */ +typedef enum { + VIR_NWFILTER_METADATA_DESCRIPTION =3D 0, /* Operate on <description> (= Since: 9.8.0) */ + VIR_NWFILTER_METADATA_TITLE =3D 1, /* Operate on <title> (Since:= 9.8.0) */ + VIR_NWFILTER_METADATA_ELEMENT =3D 2, /* Operate on <metadata> (Sin= ce: 9.8.0) */ + +# ifdef VIR_ENUM_SENTINELS + VIR_NWFILTER_METADATA_LAST /* (Since: 9.8.0) */ +# endif +} virNWFilterMetadataType; #endif /* LIBVIRT_NWFILTER_H */ --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756226; cv=none; d=zohomail.com; s=zohoarc; b=ZR3jSbXSERwYgPOUpx4NuTBTj6EpVJuW+zqviRb+bANOurB+8IaNqKeXFANc8GoLJrVIkbCP8gXrVvNztzbvFIQ8QgWYchiEgTbv2WwXM7ky9li+pyGxKp5PkJFZjDqkm6sKvXV4qUr4JKrINC6db04qMyVPt4B7p1hhoAIFbxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756226; 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=4FRdWLWyXkPe99Hr+nmXb+Id6HP+iKmJG5nQ1DCqalw=; b=fFvJ8oTFN/Of7auIuCPPSjVUY2aQoWHjP7+JHaZoxhk0Lk3ab520jEAKR1tcE4TsizPUn9omsciKqbk4/2946jUUJMaUZUQEqVSUVnrX0JXK+VKiGvqMFmHeNpRD4kqKvDOeOI1DC6t8OM+oXszGPEssY+UpueEOmYss5MTqYt0= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756225971225.9166005822425; Sun, 3 Sep 2023 08:50:25 -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-443-mmbweWqiOHuOeTzaacQ4jA-1; Sun, 03 Sep 2023 11:50:18 -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 4E6C093A9A3; Sun, 3 Sep 2023 15:50:16 +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 3845A200BA73; Sun, 3 Sep 2023 15:50:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0C2B219465B7; Sun, 3 Sep 2023 15:50:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 893801946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 79A1F21EE561; Sun, 3 Sep 2023 15:50:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71B8321EE560 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-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 55A44925FDD for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:15 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-icfxgmyDOqKTqSpNNKfdSg-1; Sun, 03 Sep 2023 11:50:12 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6q1ZvHzDr1l for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6p0SqSzFpfK; Sun, 3 Sep 2023 15:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756224; 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=4FRdWLWyXkPe99Hr+nmXb+Id6HP+iKmJG5nQ1DCqalw=; b=Oz6Wl+bOzjZTmGgHnKqsZkgmk/08Q3CtTEs6fcI6be5pdfjS620IJ9Tu6HNPNzHSYYxRTG MOoI6kyn+amXDRXqcAgg1D/eMEun5z62WJuncyvzTaZqf3G87pHZGkM5OLAsgNWO7NwNfU oydfect2Ob49UZF3TaLZkP0+fomyJ9g= X-MC-Unique: mmbweWqiOHuOeTzaacQ4jA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: icfxgmyDOqKTqSpNNKfdSg-1 X-Riseup-User-ID: E6146B9A6F000617D00B3DED8B6C90AFDEBBA2F7E92AFF56404181C87E7E588A From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 04/16] nwfilter: Add error code and message for missing metadata Date: Sun, 3 Sep 2023 21:19:05 +0530 Message-ID: <20230903155034.211476-5-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.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1693756227377100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- include/libvirt/virterror.h | 1 + src/util/virerror.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 224eddc9e4..ffb47a3242 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -349,6 +349,7 @@ typedef enum { VIR_ERR_CHECKPOINT_INCONSISTENT =3D 109, /* checkpoint can't be used (= Since: 6.10.0) */ VIR_ERR_MULTIPLE_DOMAINS =3D 110, /* more than one matching domain= found (Since: 7.1.0) */ VIR_ERR_NO_NETWORK_METADATA =3D 111, /* Network metadata is not prese= nt (Since: 9.7.0) */ + VIR_ERR_NO_NWFILTER_METADATA =3D 112, /* NWFilter metadata is not pre= sent (Since: 9.8.0) */ =20 # ifdef VIR_ENUM_SENTINELS VIR_ERR_NUMBER_LAST /* (Since: 5.0.0) */ diff --git a/src/util/virerror.c b/src/util/virerror.c index 227a182417..a1d0d73e5d 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1290,6 +1290,9 @@ static const virErrorMsgTuple virErrorMsgStrings[] = =3D { [VIR_ERR_NO_NETWORK_METADATA] =3D { N_("metadata not found"), N_("metadata not found: %1$s") }, + [VIR_ERR_NO_NWFILTER_METADATA] =3D { + N_("metadata not found"), + N_("metadata not found: %1$s") }, }; =20 G_STATIC_ASSERT(G_N_ELEMENTS(virErrorMsgStrings) =3D=3D VIR_ERR_NUMBER_LAS= T); --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756226; cv=none; d=zohomail.com; s=zohoarc; b=Xrt4/DDxFM1sNg+Q6Yif+EGSoZVWcI0msqAifN6mI93aRlX/Qw2dxcOukaEdR+/Vyj3k+YNCju+UhQZudCjEJHKMlxQpDWJN16/+10CUeRF9oouvmtnh1+F6+ZzCNE+qjFBQlWzb6XjvExlG82D/H5NtCAa4qku25qn4/CCjuA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756226; 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=OpHq3pRtrYN+p1zI7VsBis4WyEIDST4V0rvMA7lO7uk=; b=PT4Oucyxcq9rjYwZ6DIPPMgJimfPHgquMo1xxi74X+dtMMPQhV+K9DC8FSp+uh4LktuNg1V+xbce4YnvRas3G8wR2Z5UEDnhNU88k8htKaOjA+b7j5VpuYsnevD6+qXFFRjjmw2RHlloxqluxFI/Vq/S1i01iz4tEWbq1VaxaHM= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756226238164.11765634721394; Sun, 3 Sep 2023 08:50:26 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-425-AEXebbJMMF6TUa9CLo9H5w-1; Sun, 03 Sep 2023 11:50:20 -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 87CAD29AA3BF; Sun, 3 Sep 2023 15:50:18 +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 74C1640C6CCC; Sun, 3 Sep 2023 15:50:18 +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 51FD51946597; Sun, 3 Sep 2023 15:50:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 52E191946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 346D4493112; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C25B493110 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-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 0F5C9925FE4 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-PZgoN_h5Mb-zeRcOAQkNoA-1; Sun, 03 Sep 2023 11:50:13 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6r6G44zDr3J for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6q50dMzFpfK; Sun, 3 Sep 2023 15:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756225; 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=OpHq3pRtrYN+p1zI7VsBis4WyEIDST4V0rvMA7lO7uk=; b=XkYJZCe0ZpmS3k9ZhvNBlraPNY92dCs/2ye3CQ0GZBKW1cV5GuaGTfFALlYFSetpPVtT/z FbPwo3SmPAJeoPmY2BuqYwjU1oVN2EkWYwsDkK+NeqhxI8YQS7AgAOYQR+LFaeoZI9N/1W CToUvsBDqA1UYtFuYb2au6kOxYn/VrM= X-MC-Unique: AEXebbJMMF6TUa9CLo9H5w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: PZgoN_h5Mb-zeRcOAQkNoA-1 X-Riseup-User-ID: 2E1513883CFFC6C028E0077C6A5F38C080933DB3189660A9CC032B088968EEE5 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 05/16] nwfilter: Introduce public API to modify user metadata Date: Sun, 3 Sep 2023 21:19:06 +0530 Message-ID: <20230903155034.211476-6-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.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> 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: 1693756227379100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduces `virNWFilterSetMetadata()` to modify user defined metadata fields, i.e `<title>`, `<description>` and `<metadata>` Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- include/libvirt/libvirt-nwfilter.h | 8 +++ src/driver-nwfilter.h | 9 ++++ src/libvirt-nwfilter.c | 87 ++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++ 4 files changed, 109 insertions(+) diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-n= wfilter.h index a9930a1e66..ecab779665 100644 --- a/include/libvirt/libvirt-nwfilter.h +++ b/include/libvirt/libvirt-nwfilter.h @@ -173,4 +173,12 @@ typedef enum { VIR_NWFILTER_METADATA_LAST /* (Since: 9.8.0) */ # endif } virNWFilterMetadataType; + +int virNWFilterSetMetadata(virNWFilterPtr nwfilter, + int type, + const char *metadata, + const char *key, + const char *uri, + unsigned int flags); + #endif /* LIBVIRT_NWFILTER_H */ diff --git a/src/driver-nwfilter.h b/src/driver-nwfilter.h index 1ec591ece9..3426781fa0 100644 --- a/src/driver-nwfilter.h +++ b/src/driver-nwfilter.h @@ -86,6 +86,14 @@ typedef int typedef int (*virDrvNWFilterBindingFree)(virNWFilterBindingPtr binding); =20 +typedef int +(*virDrvNWFilterSetMetadata)(virNWFilterPtr nwfilter, + int type, + const char *metadata, + const char *key, + const char *uri, + unsigned int flags); + =20 typedef struct _virNWFilterDriver virNWFilterDriver; =20 @@ -111,4 +119,5 @@ struct _virNWFilterDriver { virDrvNWFilterBindingCreateXML nwfilterBindingCreateXML; virDrvNWFilterBindingDelete nwfilterBindingDelete; virDrvNWFilterBindingGetXMLDesc nwfilterBindingGetXMLDesc; + virDrvNWFilterSetMetadata nwfilterSetMetadata; }; diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c index ff82cc3b7f..0a0fbdd195 100644 --- a/src/libvirt-nwfilter.c +++ b/src/libvirt-nwfilter.c @@ -920,3 +920,90 @@ virNWFilterBindingRef(virNWFilterBindingPtr binding) virObjectRef(binding); return 0; } + + +/** + * virNWFilterSetMetadata: + * @nwfilter: a network filter object + * @type: type of metadata, from virNWFilterMetadataType + * @metadata: new metadata text + * @key: XML namespace key, or NULL + * @uri: XML namespace URI, or NULL + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Sets the appropriate nwfilter element given by @type to the + * value of @metadata. + * For options VIR_NWFILTER_METADATA_TITLE and VIR_NWFILTER_METADATA_DESCR= IPTION + * @key and @uri are irrelevant and must be set to NULL. + * + * For type VIR_NWFILTER_METADATA_ELEMENT @metadata must be a well-formed + * XML belonging to namespace defined by @uri with local name @key. + * + * Passing NULL for @metadata says to remove that element from the + * network filter XML (passing the empty string leaves the element present= ). + * + * The resulting metadata will be present in virNWFilterGetXMLDesc(), + * as well as quick access through virNWFilterGetMetadata(). + * + * Returns 0 on success, -1 in case of failure. + * + * Since: 9.8.0 + */ +int +virNWFilterSetMetadata(virNWFilterPtr nwfilter, + int type, + const char *metadata, + const char *key, + const char *uri, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DEBUG("nwfilter=3D%p, type=3D%d, metadata=3D'%s', key=3D'%s', uri= =3D'%s', flags=3D0x%x", + nwfilter, type, NULLSTR(metadata), NULLSTR(key), NULLSTR(uri= ), + flags); + + virResetLastError(); + + virCheckNWFilterReturn(nwfilter, -1); + conn =3D nwfilter->conn; + + virCheckReadOnlyGoto(conn->flags, error); + + switch (type) { + case VIR_NWFILTER_METADATA_TITLE: + if (metadata && strchr(metadata, '\n')) { + virReportInvalidArg(metadata, "%s", + _("metadata title can't contain newlines")= ); + goto error; + } + G_GNUC_FALLTHROUGH; + case VIR_NWFILTER_METADATA_DESCRIPTION: + virCheckNullArgGoto(uri, error); + virCheckNullArgGoto(key, error); + break; + case VIR_NWFILTER_METADATA_ELEMENT: + virCheckNonNullArgGoto(uri, error); + if (metadata) + virCheckNonNullArgGoto(key, error); + break; + default: + /* For future expansion */ + break; + } + + if (conn->nwfilterDriver->nwfilterSetMetadata) { + int ret; + ret =3D conn->nwfilterDriver->nwfilterSetMetadata(nwfilter, type, = metadata, key, uri, + flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(nwfilter->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index bd1e916d2a..4e3b17b475 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -938,4 +938,9 @@ LIBVIRT_9.7.0 { virNetworkSetMetadata; } LIBVIRT_9.0.0; =20 +LIBVIRT_9.8.0 { + global: + virNWFilterSetMetadata; +} LIBVIRT_9.7.0; + # .... define new API here using predicted next version number .... --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756229; cv=none; d=zohomail.com; s=zohoarc; b=mNCD9vf8gNk0cU+mASQrHTs7nTJJRVKXDIdpuL8gwOkJfcvAzpUn4ARVpA4h0UITwdV2CHGXLHMBjKw7/Ohqb4Am5/MgcLVovf/M/tvCb08JF9rUFpf2swCMk0SGdtEQsCk8v+7TFGxjrltNv6arbi/lYa4bBUNu2sjHqdcNn0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756229; 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=YtWFwwncE74g/tjEV+wBJZZwBplqwIm/Nlweq8gOhBo=; b=RjrOybwrRMyNc4eOgomJJNG3MDyUjsiW80SivvjmiXHv4qRlkZ1bGzZ2EeeOlhFrC9D0UOTAigNcczykb+PpOCpQPkV6CVdhhoT+3OXbDdMOuwGkbxT6ir7KXgw3YcWpxlT6sJYRwT2hhC8m/R/oZ79riJzXJ3VsIDbl9o1zceU= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 169375622993624.274376380618946; Sun, 3 Sep 2023 08:50: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-453-up9tX9mxMqe_bnE0IhTsVw-1; Sun, 03 Sep 2023 11:50:22 -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 1EF838F99FB; Sun, 3 Sep 2023 15:50:19 +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 04792400F26A; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8C30D1946A6B; Sun, 3 Sep 2023 15:50:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 744A21946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 647FAD4781D; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CC71D4781B for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 3D4EA104086E for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-MjG5UkG7N-2qeWKd-rKFzQ-1; Sun, 03 Sep 2023 11:50:15 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6t3knKzDr2N for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6s2S6JzFpfK; Sun, 3 Sep 2023 15:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756228; 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=YtWFwwncE74g/tjEV+wBJZZwBplqwIm/Nlweq8gOhBo=; b=UHwg0Jq2n91BjfP1sJt2Fsl0rBMm/Gr3f0WaXrekxEJlHhUwMtsN+5OidhWPBO3cjWLCys TvpnNPig8nmUBU3y9PN+k4aroOmhRgBIHv/SPp5o0+SpFMi+z5Qo9mdTuTdzOl+TRO2eDo SQJ5J0hYe/rnutL+MwCvpEUhiPLEZwM= X-MC-Unique: up9tX9mxMqe_bnE0IhTsVw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: MjG5UkG7N-2qeWKd-rKFzQ-1 X-Riseup-User-ID: 9C42280D8B5402C431CE4EBC0216086E27D117CF4CCF6B04D06178B8C61AFB44 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 06/16] nwfilter: Introduce public API to retrieve user-defined metadata Date: Sun, 3 Sep 2023 21:19:07 +0530 Message-ID: <20230903155034.211476-7-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.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> 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: 1693756230910100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduces `virNWFilterGetMetadata()` to retrieve user defined metadata fields, i.e `<title>`, `<description>` and `<metadata>` Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- include/libvirt/libvirt-nwfilter.h | 5 +++ src/driver-nwfilter.h | 6 +++ src/libvirt-nwfilter.c | 67 ++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 79 insertions(+) diff --git a/include/libvirt/libvirt-nwfilter.h b/include/libvirt/libvirt-n= wfilter.h index ecab779665..2eed685300 100644 --- a/include/libvirt/libvirt-nwfilter.h +++ b/include/libvirt/libvirt-nwfilter.h @@ -181,4 +181,9 @@ int virNWFilterSetMetadata(virNWFil= terPtr nwfilter, const char *uri, unsigned int flags); =20 +char * virNWFilterGetMetadata(virNWFilterPtr nwfilter, + int type, + const char *uri, + unsigned int flags); + #endif /* LIBVIRT_NWFILTER_H */ diff --git a/src/driver-nwfilter.h b/src/driver-nwfilter.h index 3426781fa0..8d38dbd23c 100644 --- a/src/driver-nwfilter.h +++ b/src/driver-nwfilter.h @@ -94,6 +94,11 @@ typedef int const char *uri, unsigned int flags); =20 +typedef char * +(*virDrvNWFilterGetMetadata)(virNWFilterPtr nwfilter, + int type, + const char *uri, + unsigned int flags); =20 typedef struct _virNWFilterDriver virNWFilterDriver; =20 @@ -120,4 +125,5 @@ struct _virNWFilterDriver { virDrvNWFilterBindingDelete nwfilterBindingDelete; virDrvNWFilterBindingGetXMLDesc nwfilterBindingGetXMLDesc; virDrvNWFilterSetMetadata nwfilterSetMetadata; + virDrvNWFilterGetMetadata nwfilterGetMetadata; }; diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c index 0a0fbdd195..2340d87c4b 100644 --- a/src/libvirt-nwfilter.c +++ b/src/libvirt-nwfilter.c @@ -1007,3 +1007,70 @@ virNWFilterSetMetadata(virNWFilterPtr nwfilter, virDispatchError(nwfilter->conn); return -1; } + + +/** + * virNWFilterGetMetadata: + * @nwfilter: a network filter object + * @type: type of metadata, from virNWFilterMetadataType + * @uri: XML namespace identifier + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Retrieves the appropriate network filter element given by @type. + * If VIR_NWFILTER_METADATA_ELEMENT is requested parameter @uri + * must be set to the name of the namespace the requested elements + * belong to, otherwise must be NULL. + * + * If an element of the network filter XML is not present, the resulting + * error will be VIR_ERR_NO_NWFILTER_METADATA. This method forms + * a shortcut for seeing information from virNWFilterSetMetadata() + * without having to go through virNWFilterGetXMLDesc(). + * + * Returns the metadata string on success (caller must free), + * or NULL in case of failure. + * + * Since: 9.8.0 + */ +char * +virNWFilterGetMetadata(virNWFilterPtr nwfilter, + int type, + const char *uri, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DEBUG("nwfilter=3D%p, type=3D%d, uri=3D'%s', flags=3D0x%x", + nwfilter, type, NULLSTR(uri), flags); + + virResetLastError(); + + virCheckNWFilterReturn(nwfilter, NULL); + + switch (type) { + case VIR_NWFILTER_METADATA_TITLE: + case VIR_NWFILTER_METADATA_DESCRIPTION: + virCheckNullArgGoto(uri, error); + break; + case VIR_NWFILTER_METADATA_ELEMENT: + virCheckNonNullArgGoto(uri, error); + break; + default: + /* For future expansion */ + break; + } + + conn =3D nwfilter->conn; + + if (conn->nwfilterDriver->nwfilterGetMetadata) { + char *ret; + if (!(ret =3D conn->nwfilterDriver->nwfilterGetMetadata(nwfilter, = type, uri, flags))) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(nwfilter->conn); + return NULL; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 4e3b17b475..81cd9afc93 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -940,6 +940,7 @@ LIBVIRT_9.7.0 { =20 LIBVIRT_9.8.0 { global: + virNWFilterGetMetadata; virNWFilterSetMetadata; } LIBVIRT_9.7.0; =20 --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756231; cv=none; d=zohomail.com; s=zohoarc; b=cgFCPWpv2CBc4RGnaDUFfwRJxDoT4DCWsM0qd0EHZj3gfaqbH5ZuSQovEQOV1Ecl5x6GS6qshQ3qzeu+VhJMzWp+s9djeLtS+Iu5TJc2qP94RAFkn5gZkX7M1FtMN8UR4k9JHuavYEhFr/7hZYnTa22a8fNh6B4N7gInNlSI2xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756231; 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=VAI0qh+iPo/HoZSMsLHTtsdU/14TW7cOkohFr5ghENU=; b=TzspAjkGHco93AFAuRqoveRE0CQjuQzjsJ9885htqV5+LCG1UlTkAi54r6ARexgn7XWjQTd8GQhgioW4ybLEDB/Dq0C3ZBoGhNoWTmW7MzzkhUMBLJcHCYDUm0ftvPzrF9j3bHSt57t4LlTQW9Di0kgwCQEPPyviOAkilNip+5c= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 169375623126430.69228211064467; Sun, 3 Sep 2023 08:50:31 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-4yhjylzqO1SUoB8DOfka-w-1; Sun, 03 Sep 2023 11:50:23 -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 EBF59800193; Sun, 3 Sep 2023 15:50:20 +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 D99171460FFA; Sun, 3 Sep 2023 15:50:20 +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 98FD11946597; Sun, 3 Sep 2023 15:50:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6564419465B7 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 51315200DA3D; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4941820283F1 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 2A4618F99FD for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:19 +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-183-or5B6gWuPu25V17U5D8Ljg-1; Sun, 03 Sep 2023 11:50:17 -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 4Rdx6w11HQz9tDs for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:16 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6v040BzFpfK; Sun, 3 Sep 2023 15:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756230; 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=VAI0qh+iPo/HoZSMsLHTtsdU/14TW7cOkohFr5ghENU=; b=NYTU4OXJp8mGCiaXyYGOWyom8pbGyQdfQVjuiwikIslQ/QCnXQADoNg+xBKqDpCGzAUSjK ogOkqj8kkekdaqFucwxpLXCIuXt1UYjzoj27jHSe9b1Dy7ueJBsQNSjFj5+p9Nkcno5A/O gHVbLEnNy332wjKiuUygIsMf1nHnE1U= X-MC-Unique: 4yhjylzqO1SUoB8DOfka-w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: or5B6gWuPu25V17U5D8Ljg-1 X-Riseup-User-ID: DC6FC9361EB4053BCA0D80758FA08694F091C207BFB7D95AF79C6A4BFB5AF54E From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 07/16] nwfilter: Implement RPC Date: Sun, 3 Sep 2023 21:19:08 +0530 Message-ID: <20230903155034.211476-8-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.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1693756233412100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- src/remote/remote_driver.c | 2 ++ src/remote/remote_protocol.x | 34 +++++++++++++++++++++++++++++++++- src/remote_protocol-structs | 19 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index b81c9bc611..8f140ef864 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8278,6 +8278,8 @@ static virNWFilterDriver nwfilter_driver =3D { .nwfilterBindingCreateXML =3D remoteNWFilterBindingCreateXML, /* 4.5.0= */ .nwfilterBindingDelete =3D remoteNWFilterBindingDelete, /* 4.5.0 */ .nwfilterBindingGetXMLDesc =3D remoteNWFilterBindingGetXMLDesc, /* 4.5= .0 */ + .nwfilterSetMetadata =3D remoteNWFilterSetMetadata, /* 9.8.0 */ + .nwfilterGetMetadata =3D remoteNWFilterGetMetadata, /* 9.8.0 */ }; =20 static virConnectDriver connect_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 7ff059e393..1a4a77a35f 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1684,6 +1684,25 @@ struct remote_nwfilter_get_xml_desc_ret { remote_nonnull_string xml; }; =20 +struct remote_nwfilter_set_metadata_args { + remote_nonnull_nwfilter nwfilter; + int type; + remote_string metadata; + remote_string key; + remote_string uri; + unsigned int flags; +}; + +struct remote_nwfilter_get_metadata_args { + remote_nonnull_nwfilter nwfilter; + int type; + remote_string uri; + unsigned int flags; +}; + +struct remote_nwfilter_get_metadata_ret { + remote_nonnull_string metadata; +}; =20 /* Interface calls: */ =20 @@ -7008,5 +7027,18 @@ enum remote_procedure { * @generate: both * @acl: network:read */ - REMOTE_PROC_NETWORK_GET_METADATA =3D 445 + REMOTE_PROC_NETWORK_GET_METADATA =3D 445, + + /** + * @generate: both + * @acl: nwfilter:write + * @acl: nwfilter:save + */ + REMOTE_PROC_NWFILTER_SET_METADATA =3D 446, + + /** + * @generate: both + * @acl: nwfilter:read + */ + REMOTE_PROC_NWFILTER_GET_METADATA =3D 447 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c07e0af1e6..c3172e3f06 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1220,6 +1220,23 @@ struct remote_nwfilter_get_xml_desc_args { struct remote_nwfilter_get_xml_desc_ret { remote_nonnull_string xml; }; +struct remote_nwfilter_set_metadata_args { + remote_nonnull_nwfilter nwfilter; + int type; + remote_string metadata; + remote_string key; + remote_string uri; + u_int flags; +}; +struct remote_nwfilter_get_metadata_args { + remote_nonnull_nwfilter nwfilter; + int type; + remote_string uri; + u_int flags; +}; +struct remote_nwfilter_get_metadata_ret { + remote_nonnull_string metadata; +}; struct remote_connect_num_of_interfaces_ret { int num; }; @@ -3736,4 +3753,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, REMOTE_PROC_NETWORK_SET_METADATA =3D 444, REMOTE_PROC_NETWORK_GET_METADATA =3D 445, + REMOTE_PROC_NWFILTER_SET_METADATA =3D 446, + REMOTE_PROC_NWFILTER_GET_METADATA =3D 447, }; --=20 2.42.0 From nobody Sun May 12 05:00:18 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; 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 Return-Path: <libvir-list-bounces@redhat.com> 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 1693756234146724.9970512576014; Sun, 3 Sep 2023 08:50:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470-17XjOvxkPvOpApVMdG0k3w-1; Sun, 03 Sep 2023 11:50:26 -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 E71A1800C78; Sun, 3 Sep 2023 15:50:23 +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 D37761460FFB; Sun, 3 Sep 2023 15:50:23 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C3CAC1946597; Sun, 3 Sep 2023 15:50:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 42F3419465BC for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 33411568FF; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B41AC77D9 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 012011C0CCA6 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-IHWcD5cNNSeGz7fUbk449g-1; Sun, 03 Sep 2023 11:50:18 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6x5cldzDr3J for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6w4TzSzFpfK; Sun, 3 Sep 2023 15:50:16 +0000 (UTC) X-MC-Unique: 17XjOvxkPvOpApVMdG0k3w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: IHWcD5cNNSeGz7fUbk449g-1 X-Riseup-User-ID: F9345D6760850BE7ACBDC2F7B0FCAE7A425BED7DA6F0F7D75E8AC0CB731DB541 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 08/16] virsh: Add helper method to retrieve xml from NWFilter def Date: Sun, 3 Sep 2023 21:19:09 +0530 Message-ID: <20230903155034.211476-9-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.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: riseup.net Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1693756235651100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- tools/virsh-util.c | 25 +++++++++++++++++++++++++ tools/virsh-util.h | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/tools/virsh-util.c b/tools/virsh-util.c index fb6327613a..c3af770c29 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -423,6 +423,31 @@ virshNetworkGetXMLFromNet(vshControl *ctl, } =20 =20 +int +virshNWFilterGetXMLFromNWFilter(vshControl *ctl, + virNWFilterPtr nwfilter, + unsigned int flags, + xmlDocPtr *xml, + xmlXPathContextPtr *ctxt) +{ + g_autofree char *desc =3D NULL; + + if (!(desc =3D virNWFilterGetXMLDesc(nwfilter, flags))) { + vshError(ctl, _("Failed to get nwfilter description xml")); + return -1; + } + + *xml =3D virXMLParseStringCtxt(desc, _("(nwfilter_definition)"), ctxt); + + if (!(*xml)) { + vshError(ctl, _("Failed to parse nwfilter description xml")); + return -1; + } + + return 0; +} + + int virshDomainGetXML(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-util.h b/tools/virsh-util.h index 2386847072..4cad3d7eb9 100644 --- a/tools/virsh-util.h +++ b/tools/virsh-util.h @@ -152,6 +152,15 @@ virshNetworkGetXMLFromNet(vshControl *ctl, ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) G_GNUC_WARN_UNUSED_RESULT; =20 +int +virshNWFilterGetXMLFromNWFilter(vshControl *ctl, + virNWFilterPtr nwfilter, + unsigned int flags, + xmlDocPtr *xml, + xmlXPathContextPtr *ctxt) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4) + ATTRIBUTE_NONNULL(5) G_GNUC_WARN_UNUSED_RESULT; + int virshDomainGetXML(vshControl *ctl, const vshCmd *cmd, --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756233; cv=none; d=zohomail.com; s=zohoarc; b=GmOKqKt2DPJynGK62OOpw/wR+wqKgNFx4a52vRc6X5k3n+KcIt2su0uCbIPf4w8GxapXqU4Tfe0n2TscYTTtgbMeNilY5E6EkH3xWUh3Te8UZx9MEoFsoYcavrlTBdvIh2GTwnk5v0B+fABI5VGq+cz0D55NYpi39dKrk+yWBQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756233; 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=LnB5mxsZEL6D7s3lxWP215S3oZ01UN2+ttH8ZNRmnKI=; b=X32V+q5Gu7eSBG8UEDiAjhBHF4Mm5j/zoi8jOJtSwK1p0jjTC6f71dZuChxdlMubuLkP00obRamGyUQILNTv3teBYjvj0OdMwi6Lt+pBdL2Prk8wS7v8nuLBE8iRwYRTXh9aAgWbTkE4tJLiurNWxWZ2P+V3lkJLMCnxxw6Txs4= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756233107274.780719251935; Sun, 3 Sep 2023 08:50: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-515-TtaT5QgBMj6r-hk2G6IAew-1; Sun, 03 Sep 2023 11:50:27 -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 BBDC9897F66; Sun, 3 Sep 2023 15:50:25 +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 9F50621EE560; Sun, 3 Sep 2023 15:50: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 5E0FF1946A46; Sun, 3 Sep 2023 15:50:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 94F111946597 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 69A914043CED; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6200240C206F for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.81]) (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 466773811F35 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117--5eIf75NOuCfgjvngZJfLw-1; Sun, 03 Sep 2023 11:50:21 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx6z2pCKzDrCZ for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6y1pVwzFpfK; Sun, 3 Sep 2023 15:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756232; 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=LnB5mxsZEL6D7s3lxWP215S3oZ01UN2+ttH8ZNRmnKI=; b=CNzFAVYTdaMKBxEGGlz5o3MoxSaTCjY+rY/h5zcLhMcWGwerbTfpsTsuhaYMRizee9jz3V 4B40NorrVYwlBTH3LGHPBldaNGOz7KD26iwZRFCfj7V/pdrTxc++M1RuMjjiQoOF5tkp+Q 3l528Jgj4cPk2mDy8GBrEpjF4YEhC7Y= X-MC-Unique: TtaT5QgBMj6r-hk2G6IAew-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: -5eIf75NOuCfgjvngZJfLw-1 X-Riseup-User-ID: BA55BC3A7CCB1EF14FD4128BBC58210F537DAC43A7F9DA9AEEEDD61A5AC7419E From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 09/16] virsh: Add new command `nwfilter-desc` Date: Sun, 3 Sep 2023 21:19:10 +0530 Message-ID: <20230903155034.211476-10-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.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1693756233438100002 Content-Type: text/plain; charset="utf-8"; x-default="true" This command can be used to view/modify the `<title>` and `<description>` fields of the NWFilter object. Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- tools/virsh-nwfilter.c | 209 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 92b2b7b3bc..615d126def 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -26,6 +26,7 @@ #include "viralloc.h" #include "virfile.h" #include "vsh-table.h" +#include "virxml.h" =20 virNWFilterPtr virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, @@ -345,6 +346,53 @@ virshNWFilterListCollect(vshControl *ctl, return list; } =20 +/* extract description or title from nwfilter xml */ +static char * +virshGetNWFilterDescription(vshControl *ctl, virNWFilterPtr nwfilter, + bool title, unsigned int flags, + unsigned int queryflags) +{ + char *desc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; + int type; + + if (title) + type =3D VIR_NWFILTER_METADATA_TITLE; + else + type =3D VIR_NWFILTER_METADATA_DESCRIPTION; + + if ((desc =3D virNWFilterGetMetadata(nwfilter, type, NULL, flags))) { + return desc; + } else { + int errCode =3D virGetLastErrorCode(); + + if (errCode =3D=3D VIR_ERR_NO_NWFILTER_METADATA) { + desc =3D g_strdup(""); + vshResetLibvirtError(); + return desc; + } + + if (errCode !=3D VIR_ERR_NO_SUPPORT) + return desc; + } + + /* fall back to xml */ + if (virshNWFilterGetXMLFromNWFilter(ctl, nwfilter, queryflags, &doc, &= ctxt) < 0) + return NULL; + + if (title) + desc =3D virXPathString("string(./title[1])", ctxt); + else + desc =3D virXPathString("string(./description[1])", ctxt); + + if (!desc) + desc =3D g_strdup(""); + + return desc; +} + + /* * "nwfilter-list" command */ @@ -768,6 +816,161 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd = *cmd G_GNUC_UNUSED) } =20 =20 +/* + * "nwfilter-desc" command + */ +static const vshCmdInfo info_nwfilter_desc[] =3D { + {.name =3D "help", + .data =3D N_("show or set network filter's description or title") + }, + {.name =3D "desc", + .data =3D N_("Allows setting or modifying the description or title of= a network filter.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_nwfilter_desc[] =3D { + {.name =3D "nwfilter", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("network filter name or uuid"), + .completer =3D virshNWFilterNameCompleter, + }, + {.name =3D "title", + .type =3D VSH_OT_BOOL, + .help =3D N_("modify/get the title instead of description") + }, + {.name =3D "edit", + .type =3D VSH_OT_BOOL, + .help =3D N_("open an editor to modify the description") + }, + {.name =3D "remove", + .type =3D VSH_OT_BOOL, + .help =3D N_("remove the element") + }, + {.name =3D "new-desc", + .type =3D VSH_OT_ARGV, + .help =3D N_("message") + }, + {.name =3D NULL} +}; + +static bool +cmdNWFilterDesc(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshNWFilter) nwfilter =3D NULL; + bool title =3D vshCommandOptBool(cmd, "title"); + bool edit =3D vshCommandOptBool(cmd, "edit"); + bool remove =3D vshCommandOptBool(cmd, "remove"); + int type; + g_autofree char *descArg =3D NULL; + const vshCmdOpt *opt =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + unsigned int flags =3D 0; + unsigned int queryflags =3D 0; + + VSH_EXCLUSIVE_OPTIONS("remove", "edit"); + + if (!(nwfilter =3D virshCommandOptNWFilter(ctl, cmd, NULL))) + return false; + + if (title) + type =3D VIR_NWFILTER_METADATA_TITLE; + else + type =3D VIR_NWFILTER_METADATA_DESCRIPTION; + + + while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) + virBufferAsprintf(&buf, "%s ", opt->data); + + virBufferTrim(&buf, " "); + + descArg =3D virBufferContentAndReset(&buf); + + if (remove) { + + if (descArg) { + vshPrintExtra(ctl, "unexpected data: \'%s\'", descArg); + return false; + } + + if (virNWFilterSetMetadata(nwfilter, type, "", NULL, NULL, flags) = < 0) + goto error; + + vshPrintExtra(ctl, "%s removed successfully", title ? "Title" : "D= escription"); + + } else if (edit || descArg) { + + g_autofree char *descNWFilter =3D NULL; + g_autofree char *descNew =3D NULL; + + if (!(descNWFilter =3D virshGetNWFilterDescription(ctl, nwfilter, + title, flags, que= ryflags))) + return false; + + if (!descArg) + descArg =3D g_strdup(descNWFilter); + + if (edit) { + g_autoptr(vshTempFile) tmp =3D NULL; + g_autofree char *desc_edited =3D NULL; + char *tmpstr; + + /* Create and open a temporary file. */ + if (!(tmp =3D vshEditWriteToTempFile(ctl, descArg))) + return false; + + /* Start the editor. */ + if (vshEditFile(ctl, tmp) =3D=3D -1) + return false; + + /* Read back the edited file. */ + if (!(desc_edited =3D vshEditReadBackFile(ctl, tmp))) + return false; + + /* strip a possible newline at the end */ + if (title && + (tmpstr =3D strrchr(desc_edited, '\n')) && + *(tmpstr+1) =3D=3D '\0') + *tmpstr =3D '\0'; + + /* Check whether XML has changed */ + if (STREQ(descNWFilter, desc_edited)) { + vshPrintExtra(ctl, "Network filter %s has not changed", ti= tle ? "title" : "description"); + return true; + } + + descNew =3D g_steal_pointer(&desc_edited); + + } else { + descNew =3D g_steal_pointer(&descArg); + } + + if (virNWFilterSetMetadata(nwfilter, type, descNew, NULL, NULL, fl= ags) < 0) + goto error; + + vshPrintExtra(ctl, "Network filter %s updated successfully", title= ? "title" : "description"); + + } else { + g_autofree char *desc =3D virshGetNWFilterDescription(ctl, nwfilte= r, title, flags, queryflags); + if (!desc) + return false; + + if (strlen(desc) > 0) { + vshPrint(ctl, "%s", desc); + } else { + vshPrintExtra(ctl, _("No %1$s for network filter: %2$s"), titl= e ? "title" : "description", virNWFilterGetName(nwfilter)); + } + } + + return true; + + error: + vshError(ctl, "Failed to set %s for network filter", title ? "titl= e" : "description"); + return false; +} + + const vshCmdDef nwfilterCmds[] =3D { {.name =3D "nwfilter-define", .handler =3D cmdNWFilterDefine, @@ -823,5 +1026,11 @@ const vshCmdDef nwfilterCmds[] =3D { .info =3D info_nwfilter_binding_list, .flags =3D 0 }, + {.name =3D "nwfilter-desc", + .handler =3D cmdNWFilterDesc, + .opts =3D opts_nwfilter_desc, + .info =3D info_nwfilter_desc, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756233; cv=none; d=zohomail.com; s=zohoarc; b=Sm3dEvcWjoASXi7kwgZGZxI1eMioHlXxkhHTWQImrw8CcxCRYlhySwLHHK1PFJH0i3+jN/fRwkI+8YoFKSsfoboGNO/YSC0fMGiflkfbWpqXhYomsxHpGN8qfbPcfv2frHQt9MnR6kndL414xu/Q5W+x5IU1RnnKMWPsGNqfpv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756233; 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=q+pqkj++kHrpqXDPCXNm4TehdACxTaK/D4nOhp4JeYI=; b=SPUDmwLNPbP11EJtkS6Rya8Rt+OO+b0gjWioY8x6R9RJZMZ7p2JzfUfGbuC1wHaMkzhgEbyisVrShOTXNi2BnS8wyngxqcikupkPvA7CscheMnP3/gHa4k3Okr45RFrIf3JPW1svsKl0YNiojmvS1YxWY9nFocwt+WwDaSHv1No= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756233733774.4581495056797; Sun, 3 Sep 2023 08:50: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-543-ymOWHce5O_ySrz7Xb-HaiQ-1; Sun, 03 Sep 2023 11:50:27 -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 309FA93A9A3; Sun, 3 Sep 2023 15:50:25 +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 1A8F71182EB; Sun, 3 Sep 2023 15:50: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 09CC31946A6A; Sun, 3 Sep 2023 15:50:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E24B81946A42 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D4BC3493112; Sun, 3 Sep 2023 15:50:23 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD13A493110 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:23 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 B0D21800962 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:23 +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-311-MAXqbYq2ORSXyGOGij6_dQ-1; Sun, 03 Sep 2023 11:50:21 -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 4Rdx7105H6z9tDs for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx6z686QzFpfK; Sun, 3 Sep 2023 15:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756232; 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=q+pqkj++kHrpqXDPCXNm4TehdACxTaK/D4nOhp4JeYI=; b=RknGYZdFBRvuadgUznnEiSS1yrHU9hAHypmvwUCTMA6NPc+YBAns/jCPSa0frjZJMRjzib hPTdKGlDMDi2l8WJPh7vJTeslIA20N40tRkil+/IYbqHWt8dpV7McqKvSzoJ5qkfK0lQ0d kKwJ96+PIOGeL6LYT/0dNQJ0Q95fPMc= X-MC-Unique: ymOWHce5O_ySrz7Xb-HaiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: MAXqbYq2ORSXyGOGij6_dQ-1 X-Riseup-User-ID: 4B20FD95DAD131828F4A1E06561D61C720CAD67A69C8AAF679BF3D0A59C77802 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 10/16] virsh: Add new command `nwfilter-metadata` Date: Sun, 3 Sep 2023 21:19:11 +0530 Message-ID: <20230903155034.211476-11-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.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1693756235441100005 Content-Type: text/plain; charset="utf-8"; x-default="true" With the new command `nwfilter-metadata`, users will be able to view and modify the `<metadata>` field of the Network Filter XML. Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- tools/virsh-nwfilter.c | 142 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 615d126def..801a52746e 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -971,6 +971,142 @@ cmdNWFilterDesc(vshControl *ctl, const vshCmd *cmd) } =20 =20 +/* + * "nwfilter-metadata" command + */ +static const vshCmdInfo info_nwfilter_metadata[] =3D { + {.name =3D "help", + .data =3D N_("show or set network filter's custom XML metadata") + }, + {.name =3D "desc", + .data =3D N_("Shows or modifies the XML metadata of a network filter.= ") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_nwfilter_metadata[] =3D { + {.name =3D "nwfilter", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("network filter name or uuid"), + .completer =3D virshNWFilterNameCompleter, + }, + {.name =3D "uri", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("URI of the namespace") + }, + {.name =3D "edit", + .type =3D VSH_OT_BOOL, + .help =3D N_("use an editor to change the metadata") + }, + {.name =3D "key", + .type =3D VSH_OT_STRING, + .help =3D N_("key to be used as a namespace identifier"), + }, + {.name =3D "set", + .type =3D VSH_OT_STRING, + .completer =3D virshCompleteEmpty, + .help =3D N_("new metadata to set"), + }, + {.name =3D "remove", + .type =3D VSH_OT_BOOL, + .help =3D N_("remove the metadata corresponding to an uri") + }, + {.name =3D NULL} +}; + +/* helper to add new metadata using the --edit option */ +static char * +virshNWFilterGetEditMetadata(vshControl *ctl G_GNUC_UNUSED, + virNWFilterPtr nwfilter, + const char *uri, + unsigned int flags) +{ + char *ret; + + if (!(ret =3D virNWFilterGetMetadata(nwfilter, VIR_NWFILTER_METADATA_E= LEMENT, + uri, flags))) { + vshResetLibvirtError(); + ret =3D g_strdup("\n"); + } + + return ret; +} + +static bool +cmdNWFilterMetadata(vshControl *ctl, const vshCmd *cmd) +{ + g_autoptr(virshNWFilter) nwfilter =3D NULL; + bool edit =3D vshCommandOptBool(cmd, "edit"); + bool rem =3D vshCommandOptBool(cmd, "remove"); + const char *set =3D NULL; + const char *uri =3D NULL; + const char *key =3D NULL; + unsigned int flags =3D 0; + bool ret =3D false; + + VSH_EXCLUSIVE_OPTIONS("edit", "set"); + VSH_EXCLUSIVE_OPTIONS("remove", "set"); + VSH_EXCLUSIVE_OPTIONS("remove", "edit"); + + if (!(nwfilter =3D virshCommandOptNWFilter(ctl, cmd, NULL))) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 || + vshCommandOptStringReq(ctl, cmd, "key", &key) < 0 || + vshCommandOptStringReq(ctl, cmd, "set", &set) < 0) + return false; + + if ((set || edit) && !key) { + vshError(ctl, "%s", + _("namespace key is required when modifying metadata")); + return false; + } + + if (set || rem) { + if (virNWFilterSetMetadata(nwfilter, VIR_NWFILTER_METADATA_ELEMENT, + set, key, uri, flags)) + return false; + + if (rem) + vshPrintExtra(ctl, "%s\n", _("Metadata removed")); + else + vshPrintExtra(ctl, "%s\n", _("Metadata modified")); + } else if (edit) { +#define EDIT_GET_XML \ + virshNWFilterGetEditMetadata(ctl, nwfilter, uri, flags) +#define EDIT_NOT_CHANGED \ + do { \ + vshPrintExtra(ctl, "%s", _("Metadata not changed")); \ + ret =3D true; \ + goto edit_cleanup; \ + } while (0) + +#define EDIT_DEFINE \ + (virNWFilterSetMetadata(nwfilter, VIR_NWFILTER_METADATA_ELEMENT, d= oc_edited, \ + key, uri, flags) =3D=3D 0) +#include "virsh-edit.c" + + vshPrintExtra(ctl, "%s\n", _("Metadata modified")); + } else { + g_autofree char *data =3D NULL; + + /* get */ + if (!(data =3D virNWFilterGetMetadata(nwfilter, VIR_NWFILTER_METAD= ATA_ELEMENT, + uri, flags))) + return false; + + vshPrint(ctl, "%s\n", data); + } + + ret =3D true; + + cleanup: + return ret; +} + + const vshCmdDef nwfilterCmds[] =3D { {.name =3D "nwfilter-define", .handler =3D cmdNWFilterDefine, @@ -1032,5 +1168,11 @@ const vshCmdDef nwfilterCmds[] =3D { .info =3D info_nwfilter_desc, .flags =3D 0 }, + {.name =3D "nwfilter-metadata", + .handler =3D cmdNWFilterMetadata, + .opts =3D opts_nwfilter_metadata, + .info =3D info_nwfilter_metadata, + .flags =3D 0 + }, {.name =3D NULL} }; --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756235; cv=none; d=zohomail.com; s=zohoarc; b=i8+2prSRuZLBTnPPEX4d5iSHN/HMcAKXEX+BFJhx+FE2mOtCYqU3vDlZORjSWqu6jz/p7CjxKGpxUhTDf6DEQ6A44ehBKTFuMKHrDMp0XUMxcUYPaBZ9FO9X5X/CTIIbargSmqq9giNQ+42Weyk3XMcx3OavinsNpAf1A3YWtrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756235; 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=D88ocPpg7arlMn0qJ3nKHug42yQB9E6UZaWK6h4DJc0=; b=eTVLojF7pS9WtFxfbpbF03FIY4E6sy4iEM9Ys+NBP+j0sPYWxGKClIvfCOzfZllFqXzqseT/M0sQwVU691QEX/d5idglXGm9HyyB5h+bcgQ/BrnLQ8Zkcj50aXhcLhEKq1Ib7JJc4RbVUhCaDWEDcp8DU/zVpmN3CwMWtcRy4A4= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756235792587.4431265271261; Sun, 3 Sep 2023 08:50:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-550-VhUQIBTjOh6pdpFNiepp4w-1; Sun, 03 Sep 2023 11:50:31 -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 1E63E1C29799; Sun, 3 Sep 2023 15:50:28 +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 C94021460FFA; Sun, 3 Sep 2023 15:50: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 AB8121946597; Sun, 3 Sep 2023 15:50: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 2641A1946597 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 16263412F2CF; Sun, 3 Sep 2023 15:50:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0EA97412F2CE for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:26 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 E840F91C4E4 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:25 +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-516-TyQshtjAPKO7WxfKLdRQ_g-1; Sun, 03 Sep 2023 11:50:23 -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 4Rdx724Xkvz9tGn for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx713RXyzFpfK; Sun, 3 Sep 2023 15:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756234; 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=D88ocPpg7arlMn0qJ3nKHug42yQB9E6UZaWK6h4DJc0=; b=MNMLLQbb3kJKktYby95Sh6jqY9Z3Nzxkw+GxOA7UzYnkQxnMPtWrFhwV8wr/5OOTnpM8DG OYgwy24blYom0fAB2VoDd0GdihoiSTnp1hm4eQ0gNigjUO1qqXTTTSAGX4+XncaWgkjCnS iwaIurV4C2xrCu4r7ny/AZP7B44fp4U= X-MC-Unique: VhUQIBTjOh6pdpFNiepp4w-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: TyQshtjAPKO7WxfKLdRQ_g-1 X-Riseup-User-ID: 34212439E151A3B9DE6C7DB63C7C2D82A959D9280EFC341E7A32269F5A635FDA From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 11/16] virsh: Add option --title for nwfilter-list Date: Sun, 3 Sep 2023 21:19:12 +0530 Message-ID: <20230903155034.211476-12-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.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1693756237705100011 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- tools/virsh-nwfilter.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 801a52746e..ca803865bf 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -407,6 +407,10 @@ static const vshCmdInfo info_nwfilter_list[] =3D { }; =20 static const vshCmdOptDef opts_nwfilter_list[] =3D { + {.name =3D "title", + .type =3D VSH_OT_BOOL, + .help =3D N_("show network filter title") + }, {.name =3D NULL} }; =20 @@ -416,13 +420,18 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_= GNUC_UNUSED) size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; bool ret =3D false; + bool optTitle =3D vshCommandOptBool(cmd, "title"); struct virshNWFilterList *list =3D NULL; g_autoptr(vshTable) table =3D NULL; =20 if (!(list =3D virshNWFilterListCollect(ctl, 0))) return false; =20 - table =3D vshTableNew(_("UUID"), _("Name"), NULL); + if (optTitle) + table =3D vshTableNew(_("UUID"), _("Name"), _("Title"), NULL); + else + table =3D vshTableNew(_("UUID"), _("Name"), NULL); + if (!table) goto cleanup; =20 @@ -430,11 +439,26 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_= GNUC_UNUSED) virNWFilterPtr nwfilter =3D list->filters[i]; =20 virNWFilterGetUUIDString(nwfilter, uuid); - if (vshTableRowAppend(table, - uuid, - virNWFilterGetName(nwfilter), - NULL) < 0) - goto cleanup; + + if (optTitle) { + g_autofree char *title =3D NULL; + if (!(title =3D virshGetNWFilterDescription(ctl, nwfilter, tru= e, 0, 0))) + goto cleanup; + + if (vshTableRowAppend(table, + uuid, + virNWFilterGetName(nwfilter), + title, + NULL) < 0) + goto cleanup; + + } else { + if (vshTableRowAppend(table, + uuid, + virNWFilterGetName(nwfilter), + NULL) < 0) + goto cleanup; + } } =20 vshTablePrintToStdout(table, ctl); --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756235; cv=none; d=zohomail.com; s=zohoarc; b=jE+G8Xx+W/CAT8i6KhvhgIorJeuIRtyrWVq+QH9zWE+MaXJixaXjCR6Px7aRpp4AacaOBylYw10YidTLO/KYjhFhK71n2ek1noPC5qGG/V9NtR2ECpKesPnSL8LETFZWuYV5G6c9J5YeX8287ZD6pGWzGst3Ec9BI2s2r06OYwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756235; 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=6bTztl8Ghr2oKlYH63oZtB26lf0OgW/fqtMNg7uTLo8=; b=HE0Bu1JT1OX9vqKuxC7nRDfSXccsEybjLlPZVYmWPjik7eomHaIuNpSCQRFGUm2JbwB/guYntceKfpGoLpmUtGQfEKqriTduVhdvWHnCiiA01RyeoJ3+7MhHkdJM8PMcx/P49B4h3pYUwlPFV79M+GFxkIXLVci8rLFXQmW9vJE= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756235308244.21293480823124; Sun, 3 Sep 2023 08:50:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-554-AjHiDxOHN-Wk6ioXEOTfKA-1; Sun, 03 Sep 2023 11:50:31 -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 2E37E38149A1; Sun, 3 Sep 2023 15:50:29 +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 1897E40C6CCC; Sun, 3 Sep 2023 15:50: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 EB31819465B7; Sun, 3 Sep 2023 15:50:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A6F71946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7D225525720; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 751EE493114 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.81]) (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 56EBD101A54E for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-YmjlQRR1MVeeLpvLMeEUGg-1; Sun, 03 Sep 2023 11:50:25 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx741vBfzDrDX for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx730sFSzFpfK; Sun, 3 Sep 2023 15:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756234; 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=6bTztl8Ghr2oKlYH63oZtB26lf0OgW/fqtMNg7uTLo8=; b=Mcr2bj2ecU/E+7kCwBEMsnHExQaB0GER9rBE6TaRzg1FgFghUWeMd6+9Lvoq1NT0W3ZmHw AzKZyciHMjuEOyAt4H0KD456H9rah/lLJY/aTl6Oj/t6zARzrfGyOAsWNT6zUOybpqxR+A HSinFD3GazildJJ+lQakRjMLIbt/MnY= X-MC-Unique: AjHiDxOHN-Wk6ioXEOTfKA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: YmjlQRR1MVeeLpvLMeEUGg-1 X-Riseup-User-ID: 335B7ADAA91855B4938D08911B8642A1C08ECA4B52C71A3FFE8AAE7AB9DAC64B From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 12/16] docs: Document nwfilter metadata related commands Date: Sun, 3 Sep 2023 21:19:13 +0530 Message-ID: <20230903155034.211476-13-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.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> 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: 1693756237547100009 Content-Type: text/plain; charset="utf-8"; x-default="true" Documents the commands `nwfilter-desc`, `nwfilter-metadata` and the new `--title` option of `nwfilter-list`. Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- docs/manpages/virsh.rst | 98 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 91e1d5de37..c81927d290 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -8082,10 +8082,53 @@ nwfilter-list =20 :: =20 - nwfilter-list + nwfilter-list [--title] =20 List all of the available network filters. =20 +If *--title* is specified, then the short network filter description +(title) is printed in an extra column. + + +nwfilter-desc +------------- + +**Syntax:** + +:: + + nwfilter-desc [--nwfilter] nwfilter-name + [--title] [--edit] [--remove] + [--new-desc new-value] + +Show or modify description and title of a network filter. + +These values are user fields that allow storing arbitrary textual data to +allow easy identification of network filters. +Title should be short, although it's not enforced. +(See also ``nwfilter-metadata`` that works with XML based network filter m= etadata.) + +- *--title* + + Specifies to operate on the title field instead of description. + +- *--edit* + + Opens an editor with the current title or description. + Modifications to the contents will be saved back. + Alternatively, the new contents can be provided via the *--new-desc* opt= ion. + +- *--remove* + + Removes the title or description field. + +- *--new-desc* + + Stores the provided title/description string. + +If neither of *--edit* or *--new-desc* are specified, the title or descrip= tion +is displayed instead of being modified. + =20 nwfilter-dumpxml ---------------- @@ -8133,6 +8176,59 @@ The editor used can be supplied by the ``$VISUAL`` o= r ``$EDITOR`` environment variables, and defaults to ``vi``. =20 =20 +nwfilter-metadata +----------------- + +**Syntax:** + +:: + + nwfilter-metadata [--nwfilter] nwfilter-name [--uri] uri + [--edit] [[--key] nskey] [--set new-metadata-xml] + [--remove] + +Show or modify custom XML metadata of a network filter. + +The metadata is a user defined XML that allows storing arbitrary XML data +in the network filter definition. +Multiple separate custom metadata pieces can be stored in the +network filter XML. The pieces are identified by a private XML namespace +provided via the *uri* argument. +(See also ``nwfilter-desc`` that works with textual metadata of +a network filter, such as title and description.) + +- *--uri* + + Specifies the URI for the private namespace. + +- *--edit* + + Opens an editor with the metadata identified by the *uri* argument. + Modifications to the contents will be saved back. + Alternatively, the new contents can be provided via the *--set* argument. + +- *--key* + + Specifies the namespace key to be used. + +- *--set* + + Validates and stores the provided metadata string. + + **Note:** When setting metadata via *--edit* or *--set* the *--key* arg= ument + must be specified and is used to prefix the custom elements to bind them + to the private namespace. + +If neither of *--edit* and *--set* are specified the XML metadata correspo= nding +to the *uri* namespace is displayed instead of being modified. + +- *--remove* + + Specifies that the metadata element specified by the *--uri* argument sh= ould + be removed rather than updated. + + + NWFILTER BINDING COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756242; cv=none; d=zohomail.com; s=zohoarc; b=Xl7BKmetAYrOffrQqmTAbs/Y3o3ImHeiWOYzg+X6izfqW24KRjNMbxrD/AEPYjoicvw/goCRfBOTB2mzW7hhKRjZZQpkvOWqOIw0XL9r8imzWJybrW7duRDludLs6w8nw5D9hPR7TSLRVriL+d8BfZz9ttq/mpKAFGbjXwKyNhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756242; 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=RARgnmRlyonItmx5SLYx1h2J0YNpSH43imlrEbTRJvg=; b=jEjpZJaswxjqANk5FpEqOf69Lf8u+Zomr6L2SqMgvvqwkUgTzBuZU837D/ur8RoaZNSxX0ID1oL9EdvCluhn4mzkqEb4zRmaCk64qc7O0tl9xc3wZVO9ZEGqY0fMoGVUJnGicmfgTMsrY8SLHzv3O7T3pKo0JUKO83wM70UgfRQ= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756242402392.57447831478385; Sun, 3 Sep 2023 08:50:42 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-564-6DwjGnPYPTWHihDXfuryfA-1; Sun, 03 Sep 2023 11:50:34 -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 6424329AA3BD; Sun, 3 Sep 2023 15:50:32 +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 5013D493114; Sun, 3 Sep 2023 15:50: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 3A44919465A8; Sun, 3 Sep 2023 15:50:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DFBC81946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF602D4781D; Sun, 3 Sep 2023 15:50:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7C72D4781B for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.81]) (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 A857993A9B9 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:28 +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-627--TgLilgcMeKSaOWo3LTxuQ-1; Sun, 03 Sep 2023 11:50:26 -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 4Rdx756PPtz9tDs for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx745LTKzFpfK; Sun, 3 Sep 2023 15:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756241; 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=RARgnmRlyonItmx5SLYx1h2J0YNpSH43imlrEbTRJvg=; b=AEwFAFOfcOeDftatBs9WUpQVY8ZavZe9gOUA+WtF3ciFapQwaUJ+z4tF5yLSn8JL6kBnO/ RmIEUsCxF9HS0im4VmeoFHHcwf6R7s32Er6kQQEfx6rg2XGZtz/bjI+/B6ZAV1aUYkn7hL stDqu/Rj0MOK7ttYBgBPw/grEMPAEbw= X-MC-Unique: 6DwjGnPYPTWHihDXfuryfA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: -TgLilgcMeKSaOWo3LTxuQ-1 X-Riseup-User-ID: C51FD96565163545462218EA80B00DE03F590CF9644D604EDFEBC3AD9546C218 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 13/16] virnwfilterobj: Add virNWFilterObjGetMetadata() Date: Sun, 3 Sep 2023 21:19:14 +0530 Message-ID: <20230903155034.211476-14-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.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1693756243912100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- src/conf/virnwfilterobj.c | 46 +++++++++++++++++++++++++++++++++++++++ src/conf/virnwfilterobj.h | 5 +++++ src/libvirt_private.syms | 1 + 3 files changed, 52 insertions(+) diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index 6456add593..eab864fe2e 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -635,3 +635,49 @@ virNWFilterObjUnlock(virNWFilterObj *obj) { virMutexUnlock(&obj->lock); } + + +char * +virNWFilterObjGetMetadata(virNWFilterObj *obj, + int type, + const char *uri) +{ + virNWFilterDef *def; + char *ret =3D NULL; + + if (type >=3D VIR_NWFILTER_METADATA_LAST) { + virReportError(VIR_ERR_INVALID_ARG, + _("unknown metadata type '%1$d'"), type); + return NULL; + } + + if (!(def =3D virNWFilterObjGetDef(obj))) + return NULL; + + switch ((virNWFilterMetadataType) type) { + case VIR_NWFILTER_METADATA_DESCRIPTION: + ret =3D g_strdup(def->description); + break; + + case VIR_NWFILTER_METADATA_TITLE: + ret =3D g_strdup(def->title); + break; + + case VIR_NWFILTER_METADATA_ELEMENT: + if (!def->metadata) + break; + + if (virXMLExtractNamespaceXML(def->metadata, uri, &ret) < 0) + return NULL; + break; + + case VIR_NWFILTER_METADATA_LAST: + break; + } + + if (!ret) + virReportError(VIR_ERR_NO_NWFILTER_METADATA, "%s", + _("Requested metadata element is not present")); + + return ret; +} diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h index b67dc017c5..dd4dd63cee 100644 --- a/src/conf/virnwfilterobj.h +++ b/src/conf/virnwfilterobj.h @@ -117,3 +117,8 @@ virNWFilterObjLock(virNWFilterObj *obj); =20 void virNWFilterObjUnlock(virNWFilterObj *obj); + +char * +virNWFilterObjGetMetadata(virNWFilterObj *obj, + int type, + const char *uri); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1e3e407097..8c4983ae17 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1408,6 +1408,7 @@ virNWFilterBindingObjListRemove; =20 # conf/virnwfilterobj.h virNWFilterObjGetDef; +virNWFilterObjGetMetadata; virNWFilterObjGetNewDef; virNWFilterObjListAssignDef; virNWFilterObjListExport; --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756244; cv=none; d=zohomail.com; s=zohoarc; b=mhQVOnHz6WkAOtFEqTu9GmhA8OL3rgHlJgA16jkAk43/7ZqNaclzZoU9mNb3QfIVOPJ6TVEYvVdM3tmPyoskq2iKXvBZIDvGMhoaWeTACJOZb3bFsQFkhUU8jX2LN5kEVioZTquNF2Ev/iLPVD191SEw2s1Rqld6ikHd4+jxlsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756244; 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=Sq4L9qYjeNa6+z/jRLWeiEZ1/K5FWsL3b/+Kc1/uovM=; b=R2otPtzsyhivtVR5zrVu2iHymJ2XB3OoWEAThTAfg8NMO1dv+m3CYbAEE66SZftcTNTjckHGKxMnfISvdejeZjHVafu3GjuNB05Kp2LupRhIthrdRwyRVa6mhCI6WMYkDMSNx70604iTKP+RMNCZn/ya/vG/bjabIlBRclmKXzM= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756244061256.73962073481925; Sun, 3 Sep 2023 08:50:44 -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-580-XbiY1zPUOPmtunDxj7uXqQ-1; Sun, 03 Sep 2023 11:50:38 -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 3A624803B25; Sun, 3 Sep 2023 15:50:33 +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 25FD8C77D9; Sun, 3 Sep 2023 15:50: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 EF1F71946597; Sun, 3 Sep 2023 15:50:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 77B0C1946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 66BA6D4781D; Sun, 3 Sep 2023 15:50:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E336D4781B for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 3F623800962 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:31 +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-619-Q7RNvoBxOF-Pct8HqP-OSw-1; Sun, 03 Sep 2023 11:50:28 -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 4Rdx773x9dz9tGn for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx762pvQzFpfK; Sun, 3 Sep 2023 15:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756243; 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=Sq4L9qYjeNa6+z/jRLWeiEZ1/K5FWsL3b/+Kc1/uovM=; b=SLRUQqFaJn3vPjgTMxeaqm9naa/ZgHY/IJV2LJfn+yEi/pTnXRxy/cd4ooY3Ii6uNpHLF+ XrQxwLdazNYixr8tmlQaYVuiIqTS83smTn+k+ds6bAS1VCStFM3N6i8tclioaRc6ckBIvJ LlM2IfULTR4MQaISwEsezVacm3X3zOI= X-MC-Unique: XbiY1zPUOPmtunDxj7uXqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Q7RNvoBxOF-Pct8HqP-OSw-1 X-Riseup-User-ID: CCAAD1223F656C70799F0F3C92E050DF8BD2AEA6ABC104AADD4FDBF7B2780098 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 14/16] virnwfilterobj: Add virNWFilterObjSetMetadata() Date: Sun, 3 Sep 2023 21:19:15 +0530 Message-ID: <20230903155034.211476-15-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.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1693756245967100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- src/conf/virnwfilterobj.c | 102 ++++++++++++++++++++++++++++++++++++++ src/conf/virnwfilterobj.h | 8 +++ src/libvirt_private.syms | 1 + 3 files changed, 111 insertions(+) diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index eab864fe2e..437df9631b 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -681,3 +681,105 @@ virNWFilterObjGetMetadata(virNWFilterObj *obj, =20 return ret; } + + +static int +virNWFilterDefSetMetadata(virNWFilterDef *def, + int type, + const char *metadata, + const char *key, + const char *uri) +{ + g_autoptr(xmlDoc) doc =3D NULL; + xmlNodePtr old; + g_autoptr(xmlNode) new =3D NULL; + + if (type >=3D VIR_NWFILTER_METADATA_LAST) { + virReportError(VIR_ERR_INVALID_ARG, + _("unknown metadata type '%1$d'"), type); + return -1; + } + + switch ((virNWFilterMetadataType) type) { + case VIR_NWFILTER_METADATA_DESCRIPTION: + g_clear_pointer(&def->description, g_free); + + if (STRNEQ_NULLABLE(metadata, "")) + def->description =3D g_strdup(metadata); + break; + + case VIR_NWFILTER_METADATA_TITLE: + g_clear_pointer(&def->title, g_free); + + if (STRNEQ_NULLABLE(metadata, "")) + def->title =3D g_strdup(metadata); + break; + + case VIR_NWFILTER_METADATA_ELEMENT: + if (metadata) { + + /* parse and modify the xml from the user */ + if (!(doc =3D virXMLParseStringCtxt(metadata, _("(metadata_xml= )"), NULL))) + return -1; + + if (virXMLInjectNamespace(doc->children, uri, key) < 0) + return -1; + + /* create the root node if needed */ + if (!def->metadata) + def->metadata =3D virXMLNewNode(NULL, "metadata"); + + if (!(new =3D xmlCopyNode(doc->children, 1))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to copy XML node")); + return -1; + } + } + + /* remove possible other nodes sharing the namespace */ + while ((old =3D virXMLFindChildNodeByNs(def->metadata, uri))) { + xmlUnlinkNode(old); + xmlFreeNode(old); + } + + if (new) { + if (!(xmlAddChild(def->metadata, new))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to add metadata to XML document")= ); + return -1; + } + new =3D NULL; + } + break; + + case VIR_NWFILTER_METADATA_LAST: + break; + } + + return 0; +} + + +int +virNWFilterObjSetMetadata(virNWFilterObj *obj, + int type, + const char *metadata, + const char *key, + const char *uri, + const char *configDir) +{ + virNWFilterDef *def; + + if (!(def =3D virNWFilterObjGetDef(obj))) + return -1; + + if (def) { + if (virNWFilterDefSetMetadata(def, type, metadata, key, uri) < 0) + return -1; + + if (virNWFilterSaveConfig(configDir, def) < 0) + return -1; + } + + return 0; +} diff --git a/src/conf/virnwfilterobj.h b/src/conf/virnwfilterobj.h index dd4dd63cee..4079c0ab3d 100644 --- a/src/conf/virnwfilterobj.h +++ b/src/conf/virnwfilterobj.h @@ -122,3 +122,11 @@ char * virNWFilterObjGetMetadata(virNWFilterObj *obj, int type, const char *uri); + +int +virNWFilterObjSetMetadata(virNWFilterObj *obj, + int type, + const char *metadata, + const char *key, + const char *uri, + const char *configDir); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8c4983ae17..628723f06d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1422,6 +1422,7 @@ virNWFilterObjListNew; virNWFilterObjListNumOfNWFilters; virNWFilterObjListRemove; virNWFilterObjLock; +virNWFilterObjSetMetadata; virNWFilterObjTestUnassignDef; virNWFilterObjUnlock; virNWFilterObjWantRemoved; --=20 2.42.0 From nobody Sun May 12 05:00:18 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=1693756244; cv=none; d=zohomail.com; s=zohoarc; b=LCURurtkeCl9GOoYBo0EcUEXdIeMZ2P16DUv/h8j5Mo5FEkGqlbxL9vvw5SUinpEfu5RCsAkCBhfqSoOxCq+NrzVQ81CS8ZemusLgsA+RX5WJ/QDJSKzG85wpirN+j82FcWJ48/uSeMmmmdidTQsusKzBEPeHTQhxsTpyFjQjG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756244; 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=YkI8OrlEmLXw437Ew9lW3v9UlMjTAOwhduPpyjY4dN4=; b=cZ//MmQF4vNl9xZBcjswvUppomeUkdIHkf+dOKjI8iLkVMPg1AfV3gNUKJuhoNbbCLIfS0GGgpwglAl+s6HfoB3vXn65eVC33wH/clpY8lF08Q70q6e5x3wLRw9JrN50awICSR37TXej84H3I5CUehJVCijas+qy6cu2QNYaAak= 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=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 1693756244114971.5737098738728; Sun, 3 Sep 2023 08:50:44 -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-590-N8x-m2f-PTyxrbL21S9ymQ-1; Sun, 03 Sep 2023 11:50:36 -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 9E68891C4E1; Sun, 3 Sep 2023 15:50:33 +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 8497152572E; Sun, 3 Sep 2023 15:50: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 746CA1946597; Sun, 3 Sep 2023 15:50: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 312131946588 for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 22E7C40C1258; Sun, 3 Sep 2023 15:50:32 +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 1B277400E13F for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:32 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-inbound-delivery-1.mimecast.com [207.211.31.120]) (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 F3B913C19365 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:31 +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-341-s-sUtj_pM5CXi1lGASvYVw-1; Sun, 03 Sep 2023 11:50:30 -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 4Rdx791GZhz9tDs for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx780FRQzFpfK; Sun, 3 Sep 2023 15:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756243; 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=YkI8OrlEmLXw437Ew9lW3v9UlMjTAOwhduPpyjY4dN4=; b=KzORZYpn2Sq8MMCjBBw9OY9urvAXgw1A1fZPKFSw0XgXNp0gzsqBUzHehv8Pi+Qv2mbdtJ Cj3ogsNlxCzCx5ybaJPfFyuDrOCHqiPRsJJnAz5gbjHHTMQ/n2E0IwluHUFaMFohOYTvEj WyJEnx4gQiPWesajYiZAZsqr868lggs= X-MC-Unique: N8x-m2f-PTyxrbL21S9ymQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: s-sUtj_pM5CXi1lGASvYVw-1 X-Riseup-User-ID: 759F7D88CE4DD842963D712FA3EECB3893A51D0D65815DE1A7B2D9C241902B87 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 15/16] nwfilter_driver: Add Driver implementation for metadata Date: Sun, 3 Sep 2023 21:19:16 +0530 Message-ID: <20230903155034.211476-16-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.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1693756246237100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- src/nwfilter/nwfilter_driver.c | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 09719edd75..3a28532ca2 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -812,6 +812,65 @@ nwfilterBindingDelete(virNWFilterBindingPtr binding) } =20 =20 +static int +nwfilterSetMetadata(virNWFilterPtr nwfilter, + int type, + const char *metadata, + const char *key, + const char *uri, + unsigned int flags) +{ + virNWFilterObj *obj =3D NULL; + virNWFilterDef *def =3D NULL; + int ret =3D -1; + + virCheckFlags(0, -1); + + if (!(obj =3D nwfilterObjFromNWFilter(nwfilter->uuid))) + return -1; + + def =3D virNWFilterObjGetDef(obj); + + if (virNWFilterSetMetadataEnsureACL(nwfilter->conn, def) < 0) + goto cleanup; + + ret =3D virNWFilterObjSetMetadata(obj, type, metadata, key, uri, + driver->configDir); + + cleanup: + virNWFilterObjUnlock(obj); + return ret; +} + + +static char * +nwfilterGetMetadata(virNWFilterPtr nwfilter, + int type, + const char *uri, + unsigned int flags) +{ + virNWFilterObj *obj =3D NULL; + virNWFilterDef *def =3D NULL; + char *ret =3D NULL; + + virCheckFlags(0, NULL); + + if (!(obj =3D nwfilterObjFromNWFilter(nwfilter->uuid))) + return NULL; + + def =3D virNWFilterObjGetDef(obj); + + if (virNWFilterGetMetadataEnsureACL(nwfilter->conn, def) < 0) + goto cleanup; + + ret =3D virNWFilterObjGetMetadata(obj, type, uri); + + cleanup: + virNWFilterObjUnlock(obj); + return ret; +} + + static virNWFilterDriver nwfilterDriver =3D { .name =3D "nwfilter", .connectNumOfNWFilters =3D nwfilterConnectNumOfNWFilters, /* 0.8.0 */ @@ -828,6 +887,8 @@ static virNWFilterDriver nwfilterDriver =3D { .nwfilterBindingGetXMLDesc =3D nwfilterBindingGetXMLDesc, /* 4.5.0 */ .nwfilterBindingCreateXML =3D nwfilterBindingCreateXML, /* 4.5.0 */ .nwfilterBindingDelete =3D nwfilterBindingDelete, /* 4.5.0 */ + .nwfilterGetMetadata =3D nwfilterGetMetadata, /* 9.8.0 */ + .nwfilterSetMetadata =3D nwfilterSetMetadata, /* 9.8.0 */ }; =20 =20 --=20 2.42.0 From nobody Sun May 12 05:00:18 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=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1693756245; cv=none; d=zohomail.com; s=zohoarc; b=llzZV/ABADJqPn5DUN8KPDYAvTQ8FpB9DLONm++FJsMiDVGq0Fq40Ka+eX92wLLE68nbSePSJJGhJXkGhmlWt67pFkl9wHe6CsiAddH9WfR8Liu4bx+o46w4urJYhv7vCQrmPnPQcn5Xx8IyJZ2BFdN9/d9Hy3oM0lCRJAfg5BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693756245; 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=6dSY7crvv7bPPIn4zcaNTSBgpn4SgS2V9QvZ9MSOJ6Q=; b=EvM3KxpcDSq+sIpjBdYZSqknWrYx31JPvXMz7R4o98aod0ppuhDXZxrFZsUz3r6I3xrv2K1JGCwD6N+6GVnOt1PNt48zNnUzRt1XOt0MPGLCBFPzYMXSbvJ7RZdVHjcK/5FJIN+1FJTtoanA3kk7vrAuTWgs2OjvV5FlE3LiQX4= 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=fail header.from=<shiva_kr@riseup.net> (p=none dis=none) Return-Path: <libvir-list-bounces@redhat.com> 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 169375624575682.14875515436097; Sun, 3 Sep 2023 08:50:45 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.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-623-DApu8RfXMnizScgVRZEGqQ-1; Sun, 03 Sep 2023 11:50:37 -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 E72A1299E74E; Sun, 3 Sep 2023 15:50:34 +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 D32E51460FFA; Sun, 3 Sep 2023 15:50: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 B0D591946597; Sun, 3 Sep 2023 15:50:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A1C2C1946A4F for <libvir-list@listman.corp.redhat.com>; Sun, 3 Sep 2023 15:50:33 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8284752572D; Sun, 3 Sep 2023 15:50:33 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 77E9D52572E for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:33 +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 5DC36800C78 for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:33 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-AKN5mWI2OF2f52zzSEzu1w-1; Sun, 03 Sep 2023 11:50:31 -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 mx1.riseup.net (Postfix) with ESMTPS id 4Rdx7B5lDKzDrCZ for <libvir-list@redhat.com>; Sun, 3 Sep 2023 15:50:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Rdx794jLYzFpfK; Sun, 3 Sep 2023 15:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693756244; 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=6dSY7crvv7bPPIn4zcaNTSBgpn4SgS2V9QvZ9MSOJ6Q=; b=Wqn+S5yVzvFVDvlrrHG2lKtgbOJpu+SSU5ye/sRXjxNPFURwBWmgRWY8AxZ+X/Z11NA3o1 zd/HRrHW0SHym1QQh7R+mv4h+TCsDaU7HKHtkA2OjTgetJlppV4RXWfARxMNvipH0nYaSR fLSGHWa4d1vudrzQUnSQpYywzoiD+F0= X-MC-Unique: DApu8RfXMnizScgVRZEGqQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: AKN5mWI2OF2f52zzSEzu1w-1 X-Riseup-User-ID: 0481F0603DF392C8D46873BBF7A597C36BC4295F0DE7E7777FD3487B92E5AE96 From: K Shiva Kiran <shiva_kr@riseup.net> To: libvir-list@redhat.com Subject: [PATCH 16/16] NEWS: Introduce user-defined metadata fields for NWFilter object Date: Sun, 3 Sep 2023 21:19:17 +0530 Message-ID: <20230903155034.211476-17-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.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools <libvir-list.redhat.com> List-Unsubscribe: <https://listman.redhat.com/mailman/options/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=unsubscribe> List-Archive: <http://listman.redhat.com/archives/libvir-list/> List-Post: <mailto:libvir-list@redhat.com> List-Help: <mailto:libvir-list-request@redhat.com?subject=help> List-Subscribe: <https://listman.redhat.com/mailman/listinfo/libvir-list>, <mailto:libvir-list-request@redhat.com?subject=subscribe> Cc: K Shiva Kiran <shiva_kr@riseup.net> Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" <libvir-list-bounces@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1693756247856100007 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: K Shiva Kiran <shiva_kr@riseup.net> --- NEWS.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index a03ef20bc2..bd38efb43c 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -17,6 +17,24 @@ v9.8.0 (unreleased) =20 * **New features** =20 + * nwfilter: Support for user-defined metadata + + The network filter object adds three user-defined metadata fields: + 1) ``<title>``: Stores a short description (title) and can't contain= newlines. + 2) ``<description>``: Can store any documentation the user wants. + 3) ``<metadata>``: Can store custom metadata in form of XML nodes. + + Two new APIs have been added to manage the above fields: + 1) ``virNWFilterGetMetadata()`` + 2) ``virNWFilterSetMetadata()`` + + virsh adds two new commands: + 1) ``nwfilter-desc``: To view or modify the title or description. + 2) ``nwfilter-metadata``: To view or modify ``<metadata>``. + + ``nwfilter-list`` adds a new option ``--title`` that prints the conten= t of ``<title>`` + in an extra column within the default ``--table`` output. + * **Improvements** =20 * **Bug fixes** --=20 2.42.0